provide a little more fault-tolerance when input data is fishy

This commit is contained in:
Dennis Luxen 2011-03-30 12:26:38 +00:00
parent ac6583906d
commit ed608f9f13
2 changed files with 11 additions and 5 deletions

View File

@ -148,13 +148,19 @@ NodeID readBinaryOSRMGraphFromStream(istream &in, vector<EdgeT>& edgeList, vecto
// translate the external NodeIDs to internal IDs // translate the external NodeIDs to internal IDs
ExternalNodeMap::iterator intNodeID = ext2IntNodeMap.find(source); ExternalNodeMap::iterator intNodeID = ext2IntNodeMap.find(source);
if( ext2IntNodeMap.find(source) == ext2IntNodeMap.end()) { if( ext2IntNodeMap.find(source) == ext2IntNodeMap.end()) {
cerr << "after " << edgeList.size() << " edges" << endl; #ifndef NDEBUG
cerr << "->" << source << "," << target << "," << length << "," << dir << "," << weight << endl; cerr << "[warning] unresolved source NodeID: " << source << endl;
cerr << "unresolved source NodeID: " << source << endl; exit(0); #endif
continue;
} }
source = intNodeID->second; source = intNodeID->second;
intNodeID = ext2IntNodeMap.find(target); intNodeID = ext2IntNodeMap.find(target);
if(ext2IntNodeMap.find(target) == ext2IntNodeMap.end()) { cerr << "unresolved target NodeID : " << target << endl; exit(0); } if(ext2IntNodeMap.find(target) == ext2IntNodeMap.end()) {
#ifndef NDEBUG
cerr << "unresolved target NodeID : " << target << endl;
#endif
continue;
}
target = intNodeID->second; target = intNodeID->second;
if(source == UINT_MAX || target == UINT_MAX) { cerr << "nonexisting source or target" << endl; exit(0); } if(source == UINT_MAX || target == UINT_MAX) { cerr << "nonexisting source or target" << endl; exit(0); }

View File

@ -251,7 +251,7 @@ int main (int argc, char *argv[]) {
continue; continue;
} }
if(edgeIT->target == nodesIT->id) { if(edgeIT->target == nodesIT->id) {
if(edgeIT->startCoord.lat != INT_MIN) { if(edgeIT->startCoord.lat != INT_MIN && edgeIT->startCoord.lon != INT_MIN) {
edgeIT->targetCoord.lat = nodesIT->lat; edgeIT->targetCoord.lat = nodesIT->lat;
edgeIT->targetCoord.lon = nodesIT->lon; edgeIT->targetCoord.lon = nodesIT->lon;