Skip to content

Commit

Permalink
Replacing uses of std::map::at() since it's not supported in pre-c++1…
Browse files Browse the repository at this point in the history
…1 compilers

To be able to compile with python 2.7 on Windows we need to use a
pre-c++11 compiler, so we can't use at().
  • Loading branch information
Federico J. Fernandez committed Nov 3, 2017
1 parent d5a2318 commit c578b03
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 21 deletions.
8 changes: 5 additions & 3 deletions src/accessibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,12 @@ Accessibility::findNearestPOIs(int srcnode, float maxradius, unsigned number,
maxradius, number, omp_get_thread_num());

vector<distance_node_pair> distance_node_pairs;
if(accessibilityVarsForPOIs.find(cat) == accessibilityVarsForPOIs.end())
std::map<POIKeyType, accessibility_vars_t>::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 */
Expand Down
45 changes: 27 additions & 18 deletions src/contraction_hierarchies/src/libch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,75 +312,84 @@ 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<BucketEntry>& 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<BucketEntry>& 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<BucketEntry>& 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);
}


void ContractionHierarchies::getNearestWithUpperBoundOnDistanceAndLocations(const POIKeyType &category, NodeID node,
EdgeWeight maxDistance, unsigned maxLocations,
std::vector<BucketEntry>& 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);
}


/** POI queries multi-threaded */
void ContractionHierarchies::getNearest(const POIKeyType &category, NodeID node, std::vector<BucketEntry>& 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);
}


void ContractionHierarchies::getNearestWithUpperBoundOnDistance(const POIKeyType &category, NodeID node,
EdgeWeight maxDistance, std::vector<BucketEntry>& 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<BucketEntry>& 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);
}


void ContractionHierarchies::getNearestWithUpperBoundOnDistanceAndLocations(const POIKeyType &category, NodeID node,
EdgeWeight maxDistance, unsigned maxLocations,
std::vector<BucketEntry>& 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);
}

}

0 comments on commit c578b03

Please sign in to comment.