Skip to content
Snippets Groups Projects
Commit 4deb4763 authored by Sergi Hernandez's avatar Sergi Hernandez
Browse files

Solved a bug when computing the (x,y) center of the imported map.

parent 2cac3c19
No related branches found
No related tags found
1 merge request!2Solved a bug when creating a new geometry object: the sale factor is...
...@@ -73,6 +73,7 @@ void COSMMap::process_map(void) ...@@ -73,6 +73,7 @@ void COSMMap::process_map(void)
{ {
std::vector<COSMNode *>::iterator node_it; std::vector<COSMNode *>::iterator node_it;
std::vector<COSMWay *>::iterator way_it; std::vector<COSMWay *>::iterator way_it;
double x,y;
// remove all nodes that do not belong to any road // remove all nodes that do not belong to any road
for(node_it=this->nodes.begin();node_it!=this->nodes.end();) for(node_it=this->nodes.begin();node_it!=this->nodes.end();)
...@@ -102,6 +103,20 @@ void COSMMap::process_map(void) ...@@ -102,6 +103,20 @@ void COSMMap::process_map(void)
// remove nodes inside other ways width // remove nodes inside other ways width
for(unsigned int i=0;i<this->nodes.size();i++) for(unsigned int i=0;i<this->nodes.size();i++)
this->nodes[i]->remove_in_junction_nodes(); this->nodes[i]->remove_in_junction_nodes();
for(unsigned int i=0;i<this->nodes.size();i++)
{
this->nodes[i]->get_location(x,y);
// get the coordinates
if(x>this->max_x)
this->max_x=x;
if(x<this->min_x)
this->min_x=x;
if(y>this->max_y)
this->max_y=y;
if(y<this->min_y)
this->min_y=y;
}
this->normalize_locations();
} }
void COSMMap::create_junctions(void) void COSMMap::create_junctions(void)
...@@ -239,6 +254,9 @@ void COSMMap::normalize_locations(void) ...@@ -239,6 +254,9 @@ void COSMMap::normalize_locations(void)
this->min_x-=center_x; this->min_x-=center_x;
this->max_y-=center_y; this->max_y-=center_y;
this->min_y-=center_y; this->min_y-=center_y;
// compute the width and heigth
this->width=this->max_x-this->min_x;
this->height=this->max_y-this->min_y;
} }
void COSMMap::load(const std::string &filename) void COSMMap::load(const std::string &filename)
...@@ -264,11 +282,6 @@ void COSMMap::load(const std::string &filename) ...@@ -264,11 +282,6 @@ void COSMMap::load(const std::string &filename)
osmium::apply(relation_reader,*this); osmium::apply(relation_reader,*this);
relation_reader.close(); relation_reader.close();
// normalize locations
this->normalize_locations();
// compute the width and heigth
this->width=this->max_x-this->min_x;
this->height=this->max_y-this->min_y;
this->process_map(); this->process_map();
this->create_road_segments(); this->create_road_segments();
this->create_junctions(); this->create_junctions();
...@@ -277,20 +290,9 @@ void COSMMap::load(const std::string &filename) ...@@ -277,20 +290,9 @@ void COSMMap::load(const std::string &filename)
void COSMMap::node(const osmium::Node& node) void COSMMap::node(const osmium::Node& node)
{ {
COSMNode *new_node; COSMNode *new_node;
double x,y;
// create and add the new node // create and add the new node
new_node = new COSMNode(node,this); new_node = new COSMNode(node,this);
new_node->get_location(x,y);
// get the coordinates
if(x>this->max_x)
this->max_x=x;
if(x<this->min_x)
this->min_x=x;
if(y>this->max_y)
this->max_y=y;
if(y<this->min_y)
this->min_y=y;
this->add_node(new_node); this->add_node(new_node);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment