diff --git a/src/accessibility.cpp b/src/accessibility.cpp index 43f6f38f..348cc383 100644 --- a/src/accessibility.cpp +++ b/src/accessibility.cpp @@ -136,10 +136,12 @@ Accessibility::findNearestPOIs(int srcnode, float maxradius, unsigned number, maxradius, number, omp_get_thread_num()); vector distance_node_pairs; - if(accessibilityVarsForPOIs.find(cat) == accessibilityVarsForPOIs.end()) + std::map::iterator cat_for_pois = + accessibilityVarsForPOIs.find(cat); + if(cat_for_pois == accessibilityVarsForPOIs.end()) return distance_node_pairs; - - accessibility_vars_t &vars = accessibilityVarsForPOIs.at(cat); + + accessibility_vars_t &vars = cat_for_pois->second; /* need to account for the possibility of having multiple locations at single node */ diff --git a/src/contraction_hierarchies/src/libch.cpp b/src/contraction_hierarchies/src/libch.cpp index 98dccfd3..b86a9314 100644 --- a/src/contraction_hierarchies/src/libch.cpp +++ b/src/contraction_hierarchies/src/libch.cpp @@ -312,31 +312,35 @@ inline ostream& operator<< (ostream& os, const Edge& e) { void ContractionHierarchies::addPOIToIndex(const POIKeyType &category, NodeID node) { CHASSERT(this->staticGraph != NULL, "Preprocessing not finished"); - if(poiIndexMap.find(category) != poiIndexMap.end()) - poiIndexMap.at(category).addPOIToIndex(node); + CHPOIIndexMap::iterator category_poi = poiIndexMap.find(category); + if(category_poi != poiIndexMap.end()) + category_poi->second.addPOIToIndex(node); } void ContractionHierarchies::getNearest(const POIKeyType &category, NodeID node, std::vector& resultingVenues) { CHASSERT(this->staticGraph != NULL, "Preprocessing not finished"); - if(poiIndexMap.find(category) != poiIndexMap.end()) - poiIndexMap.at(category).getNearestPOIs(node, resultingVenues); + CHPOIIndexMap::iterator category_poi = poiIndexMap.find(category); + if(category_poi != poiIndexMap.end()) + category_poi->second.getNearestPOIs(node, resultingVenues); } void ContractionHierarchies::getNearestWithUpperBoundOnDistance(const POIKeyType &category, NodeID node, EdgeWeight maxDistance, std::vector& resultingVenues) { CHASSERT(this->staticGraph != NULL, "Preprocessing not finished"); - if(poiIndexMap.find(category) != poiIndexMap.end()) - poiIndexMap.at(category).getNearestPOIsWithUpperBoundOnDistance(node, maxDistance, resultingVenues); + CHPOIIndexMap::iterator category_poi = poiIndexMap.find(category); + if(category_poi != poiIndexMap.end()) + category_poi->second.getNearestPOIsWithUpperBoundOnDistance(node, maxDistance, resultingVenues); } void ContractionHierarchies::getNearestWithUpperBoundOnLocations(const POIKeyType &category, NodeID node, unsigned maxLocations, std::vector& resultingVenues) { CHASSERT(this->staticGraph != NULL, "Preprocessing not finished"); - if(poiIndexMap.find(category) != poiIndexMap.end()) - poiIndexMap.at(category).getNearestPOIsWithUpperBoundOnLocations(node, maxLocations, resultingVenues); + CHPOIIndexMap::iterator category_poi = poiIndexMap.find(category); + if(category_poi != poiIndexMap.end()) + category_poi->second.getNearestPOIsWithUpperBoundOnLocations(node, maxLocations, resultingVenues); } @@ -344,8 +348,9 @@ inline ostream& operator<< (ostream& os, const Edge& e) { EdgeWeight maxDistance, unsigned maxLocations, std::vector& resultingVenues) { CHASSERT(this->staticGraph != NULL, "Preprocessing not finished"); - if(poiIndexMap.find(category) != poiIndexMap.end()) - poiIndexMap.at(category).getNearestPOIs(node, resultingVenues, maxDistance, maxLocations); + CHPOIIndexMap::iterator category_poi = poiIndexMap.find(category); + if(category_poi != poiIndexMap.end()) + category_poi->second.getNearestPOIs(node, resultingVenues, maxDistance, maxLocations); } @@ -353,8 +358,9 @@ inline ostream& operator<< (ostream& os, const Edge& e) { void ContractionHierarchies::getNearest(const POIKeyType &category, NodeID node, std::vector& resultingVenues, unsigned threadID) { CHASSERT(this->staticGraph != NULL, "Preprocessing not finished"); - if(poiIndexMap.find(category) != poiIndexMap.end()) - poiIndexMap.at(category).getNearestPOIs(node, resultingVenues, threadID); + CHPOIIndexMap::iterator category_poi = poiIndexMap.find(category); + if(category_poi != poiIndexMap.end()) + category_poi->second.getNearestPOIs(node, resultingVenues, threadID); } @@ -362,16 +368,18 @@ inline ostream& operator<< (ostream& os, const Edge& e) { EdgeWeight maxDistance, std::vector& resultingVenues, unsigned threadID) { CHASSERT(this->staticGraph != NULL, "Preprocessing not finished"); - if(poiIndexMap.find(category) != poiIndexMap.end()) - poiIndexMap.at(category).getNearestPOIsWithUpperBoundOnDistance(node, maxDistance, resultingVenues, threadID); + CHPOIIndexMap::iterator category_poi = poiIndexMap.find(category); + if(category_poi != poiIndexMap.end()) + category_poi->second.getNearestPOIsWithUpperBoundOnDistance(node, maxDistance, resultingVenues, threadID); } void ContractionHierarchies::getNearestWithUpperBoundOnLocations(const POIKeyType &category, NodeID node, unsigned maxLocations, std::vector& resultingVenues, unsigned threadID) { CHASSERT(this->staticGraph != NULL, "Preprocessing not finished"); - if(poiIndexMap.find(category) != poiIndexMap.end()) - poiIndexMap.at(category).getNearestPOIsWithUpperBoundOnLocations(node, maxLocations, resultingVenues, threadID); + CHPOIIndexMap::iterator category_poi = poiIndexMap.find(category); + if(category_poi != poiIndexMap.end()) + category_poi->second.getNearestPOIsWithUpperBoundOnLocations(node, maxLocations, resultingVenues, threadID); } @@ -379,8 +387,9 @@ inline ostream& operator<< (ostream& os, const Edge& e) { EdgeWeight maxDistance, unsigned maxLocations, std::vector& resultingVenues, unsigned threadID) { CHASSERT(this->staticGraph != NULL, "Preprocessing not finished"); - if(poiIndexMap.find(category) != poiIndexMap.end()) - poiIndexMap.at(category).getNearestPOIs(node, resultingVenues, maxDistance, maxLocations, threadID); + CHPOIIndexMap::iterator category_poi = poiIndexMap.find(category); + if(category_poi != poiIndexMap.end()) + category_poi->second.getNearestPOIs(node, resultingVenues, maxDistance, maxLocations, threadID); } }