diff --git a/src/osm/osm_map.cpp b/src/osm/osm_map.cpp index bc6ed6c88fa2cde0f66f5c8613eaef23ac8a0ec6..804e9f9f72f01599636666f1960d3c9bc671e8c4 100644 --- a/src/osm/osm_map.cpp +++ b/src/osm/osm_map.cpp @@ -73,6 +73,7 @@ void COSMMap::process_map(void) { std::vector<COSMNode *>::iterator node_it; std::vector<COSMWay *>::iterator way_it; + double x,y; // remove all nodes that do not belong to any road for(node_it=this->nodes.begin();node_it!=this->nodes.end();) @@ -102,6 +103,20 @@ void COSMMap::process_map(void) // remove nodes inside other ways width for(unsigned int i=0;i<this->nodes.size();i++) 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) @@ -239,6 +254,9 @@ void COSMMap::normalize_locations(void) this->min_x-=center_x; this->max_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) @@ -264,11 +282,6 @@ void COSMMap::load(const std::string &filename) osmium::apply(relation_reader,*this); 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->create_road_segments(); this->create_junctions(); @@ -277,20 +290,9 @@ void COSMMap::load(const std::string &filename) void COSMMap::node(const osmium::Node& node) { COSMNode *new_node; - double x,y; // create and add the new node 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); }