fixing a silly endless loop that occurred when an edge had a starting node that was not present in node data (Thanks Frederik)
This commit is contained in:
parent
878e837679
commit
ac6583906d
@ -250,48 +250,49 @@ int main (int argc, char *argv[]) {
|
|||||||
nodesIT++;
|
nodesIT++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(edgeIT->startCoord.lat != INT_MIN && edgeIT->target == nodesIT->id) {
|
if(edgeIT->target == nodesIT->id) {
|
||||||
edgeIT->targetCoord.lat = nodesIT->lat;
|
if(edgeIT->startCoord.lat != INT_MIN) {
|
||||||
edgeIT->targetCoord.lon = nodesIT->lon;
|
edgeIT->targetCoord.lat = nodesIT->lat;
|
||||||
|
edgeIT->targetCoord.lon = nodesIT->lon;
|
||||||
|
|
||||||
double distance = ApproximateDistance(edgeIT->startCoord.lat, edgeIT->startCoord.lon, nodesIT->lat, nodesIT->lon);
|
double distance = ApproximateDistance(edgeIT->startCoord.lat, edgeIT->startCoord.lon, nodesIT->lat, nodesIT->lon);
|
||||||
if(edgeIT->speed == -1)
|
if(edgeIT->speed == -1)
|
||||||
edgeIT->speed = settings.speedProfile.speed[edgeIT->type];
|
edgeIT->speed = settings.speedProfile.speed[edgeIT->type];
|
||||||
double weight = ( distance * 10. ) / (edgeIT->speed / 3.6);
|
double weight = ( distance * 10. ) / (edgeIT->speed / 3.6);
|
||||||
int intWeight = max(1, (int) weight);
|
int intWeight = max(1, (int) weight);
|
||||||
int intDist = max(1, (int)distance);
|
int intDist = max(1, (int)distance);
|
||||||
int ferryIndex = settings.indexInAccessListOf("ferry");
|
int ferryIndex = settings.indexInAccessListOf("ferry");
|
||||||
assert(ferryIndex != -1);
|
assert(ferryIndex != -1);
|
||||||
short zero = 0;
|
short zero = 0;
|
||||||
short one = 1;
|
short one = 1;
|
||||||
|
|
||||||
fout.write((char*)&edgeIT->start, sizeof(unsigned));
|
fout.write((char*)&edgeIT->start, sizeof(unsigned));
|
||||||
fout.write((char*)&edgeIT->target, sizeof(unsigned));
|
fout.write((char*)&edgeIT->target, sizeof(unsigned));
|
||||||
fout.write((char*)&intDist, sizeof(int));
|
fout.write((char*)&intDist, sizeof(int));
|
||||||
switch(edgeIT->direction) {
|
switch(edgeIT->direction) {
|
||||||
case _Way::notSure:
|
case _Way::notSure:
|
||||||
fout.write((char*)&zero, sizeof(short));
|
fout.write((char*)&zero, sizeof(short));
|
||||||
break;
|
break;
|
||||||
case _Way::oneway:
|
case _Way::oneway:
|
||||||
fout.write((char*)&one, sizeof(short));
|
fout.write((char*)&one, sizeof(short));
|
||||||
break;
|
break;
|
||||||
case _Way::bidirectional:
|
case _Way::bidirectional:
|
||||||
fout.write((char*)&zero, sizeof(short));
|
fout.write((char*)&zero, sizeof(short));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case _Way::opposite:
|
case _Way::opposite:
|
||||||
fout.write((char*)&one, sizeof(short));
|
fout.write((char*)&one, sizeof(short));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
std::cerr << "[error] edge with no direction: " << edgeIT->direction << std::endl;
|
std::cerr << "[error] edge with no direction: " << edgeIT->direction << std::endl;
|
||||||
assert(false);
|
assert(false);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
fout.write((char*)&intWeight, sizeof(int));
|
||||||
|
short edgeType = edgeIT->type;
|
||||||
|
fout.write((char*)&edgeType, sizeof(short));
|
||||||
|
fout.write((char*)&edgeIT->nameID, sizeof(unsigned));
|
||||||
}
|
}
|
||||||
fout.write((char*)&intWeight, sizeof(int));
|
|
||||||
short edgeType = edgeIT->type;
|
|
||||||
fout.write((char*)&edgeType, sizeof(short));
|
|
||||||
fout.write((char*)&edgeIT->nameID, sizeof(unsigned));
|
|
||||||
|
|
||||||
usedEdgeCounter++;
|
usedEdgeCounter++;
|
||||||
edgeIT++;
|
edgeIT++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user