Problems were partially caused by the limits of floating point accuracy.
This commit is contained in:
parent
f94ebf5296
commit
8d16c047cc
@ -185,17 +185,18 @@ public:
|
||||
}
|
||||
}
|
||||
// INFO("startcoord: " << smallestEdge.startCoord << ", tgtcoord" << smallestEdge.targetCoord << "result: " << newEndpoint);
|
||||
// INFO("length of old edge: " << LengthOfVector(smallestEdge.startCoord, smallestEdge.targetCoord));
|
||||
// INFO("Length of new edge: " << LengthOfVector(smallestEdge.startCoord, newEndpoint));
|
||||
// INFO("length of old edge: " << ApproximateDistance(smallestEdge.startCoord, smallestEdge.targetCoord));
|
||||
// INFO("Length of new edge: " << ApproximateDistance(smallestEdge.startCoord, newEndpoint));
|
||||
// assert(!resultNode.isBidirected() || (resultNode.weight1 == resultNode.weight2));
|
||||
// if(resultNode.weight1 != resultNode.weight2) {
|
||||
// INFO("-> Weight1: " << resultNode.weight1 << ", weight2: " << resultNode.weight2);
|
||||
// INFO("-> node: " << resultNode.edgeBasedNode << ", bidir: " << (resultNode.isBidirected() ? "yes" : "no"));
|
||||
// }
|
||||
|
||||
double ratio = std::min(1., LengthOfVector(smallestEdge.startCoord, newEndpoint)/LengthOfVector(smallestEdge.startCoord, smallestEdge.targetCoord) );
|
||||
assert(ratio >= 0 && ratio <=1);
|
||||
double ratio = std::min(1., ApproximateDistance(smallestEdge.startCoord, newEndpoint)/ApproximateDistance(smallestEdge.startCoord, smallestEdge.targetCoord));
|
||||
|
||||
// INFO("startCoord: " << smallestEdge.startCoord << "; targetCoord: " << smallestEdge.targetCoord << ", newEndpoint: " << newEndpoint);
|
||||
// INFO("Length of vector: " << ApproximateDistance(smallestEdge.startCoord, newEndpoint)/ApproximateDistance(smallestEdge.startCoord, smallestEdge.targetCoord));
|
||||
//Hack to fix rounding errors and wandering via nodes.
|
||||
if(std::abs(location.lon - resultNode.location.lon) == 1)
|
||||
resultNode.location.lon = location.lon;
|
||||
@ -207,8 +208,8 @@ public:
|
||||
resultNode.weight2 -= resultNode.weight1;
|
||||
}
|
||||
resultNode.ratio = ratio;
|
||||
// INFO("New weight1: " << resultNode.weight1 << ", new weight2: " << resultNode.weight2);
|
||||
// INFO("selected node: " << resultNode.edgeBasedNode << ", bidirected: " << (resultNode.isBidirected() ? "yes" : "no") << "\n--")
|
||||
// INFO("New weight1: " << resultNode.weight1 << ", new weight2: " << resultNode.weight2 << ", ratio: " << ratio);
|
||||
// INFO("selected node: " << resultNode.edgeBasedNode << ", bidirected: " << (resultNode.isBidirected() ? "yes" : "no") << "\n--");
|
||||
return foundNode;
|
||||
}
|
||||
|
||||
@ -278,12 +279,6 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
inline double LengthOfVector(const _Coordinate & c1, const _Coordinate & c2) {
|
||||
double length1 = std::sqrt(c1.lat/100000.*c1.lat/100000. + c1.lon/100000.*c1.lon/100000.);
|
||||
double length2 = std::sqrt(c2.lat/100000.*c2.lat/100000. + c2.lon/100000.*c2.lon/100000.);
|
||||
return std::fabs(length1-length2);
|
||||
}
|
||||
|
||||
inline bool DoubleEpsilonCompare(const double d1, const double d2) {
|
||||
return (std::fabs(d1 - d2) < 0.0001);
|
||||
}
|
||||
|
@ -312,15 +312,15 @@ public:
|
||||
_forwardHeap->Insert(phantomNodes.startPhantom.edgeBasedNode, -phantomNodes.startPhantom.weight1, phantomNodes.startPhantom.edgeBasedNode);
|
||||
// INFO("a) forw insert " << phantomNodes.startPhantom.edgeBasedNode << ", weight: " << -phantomNodes.startPhantom.weight1);
|
||||
if(phantomNodes.startPhantom.isBidirected() ) {
|
||||
// INFO("b) forw insert " << phantomNodes.startPhantom.edgeBasedNode+1 << ", weight: " << -phantomNodes.startPhantom.weight2);
|
||||
// INFO("b) forw insert " << phantomNodes.startPhantom.edgeBasedNode+1 << ", weight: " << -phantomNodes.startPhantom.weight2);
|
||||
_forwardHeap->Insert(phantomNodes.startPhantom.edgeBasedNode+1, -phantomNodes.startPhantom.weight2, phantomNodes.startPhantom.edgeBasedNode+1);
|
||||
}
|
||||
//insert start and/or target node of target edge id
|
||||
_backwardHeap->Insert(phantomNodes.targetPhantom.edgeBasedNode, phantomNodes.targetPhantom.weight1, phantomNodes.targetPhantom.edgeBasedNode);
|
||||
// INFO("c) back insert " << phantomNodes.targetPhantom.edgeBasedNode << ", weight: " << phantomNodes.targetPhantom.weight1);
|
||||
// INFO("c) back insert " << phantomNodes.targetPhantom.edgeBasedNode << ", weight: " << phantomNodes.targetPhantom.weight1);
|
||||
if(phantomNodes.targetPhantom.isBidirected() ) {
|
||||
_backwardHeap->Insert(phantomNodes.targetPhantom.edgeBasedNode+1, phantomNodes.targetPhantom.weight2, phantomNodes.targetPhantom.edgeBasedNode+1);
|
||||
// INFO("d) back insert " << phantomNodes.targetPhantom.edgeBasedNode+1 << ", weight: " << phantomNodes.targetPhantom.weight2);
|
||||
// INFO("d) back insert " << phantomNodes.targetPhantom.edgeBasedNode+1 << ", weight: " << phantomNodes.targetPhantom.weight2);
|
||||
}
|
||||
int offset = (phantomNodes.startPhantom.isBidirected() ? std::max(phantomNodes.startPhantom.weight1, phantomNodes.startPhantom.weight2) : phantomNodes.startPhantom.weight1) ;
|
||||
offset += (phantomNodes.targetPhantom.isBidirected() ? std::max(phantomNodes.targetPhantom.weight1, phantomNodes.targetPhantom.weight2) : phantomNodes.targetPhantom.weight1) ;
|
||||
@ -354,6 +354,7 @@ public:
|
||||
// for(unsigned i = 0; i < packedPath.size(); ++i)
|
||||
// std::cout << packedPath[i] << " ";
|
||||
// std::cout << std::endl;
|
||||
|
||||
_UnpackPath(packedPath, path);
|
||||
return _upperbound;
|
||||
}
|
||||
|
@ -98,7 +98,8 @@ void DescriptionFactory::Run(const unsigned zoomLevel, const unsigned duration)
|
||||
|
||||
//Post-processing to remove empty or nearly empty path segments
|
||||
if(0. == startPhantom.ratio || 0 == pathDescription[0].length) {
|
||||
pathDescription.erase(pathDescription.begin());
|
||||
if(pathDescription.size() > 2)
|
||||
pathDescription.erase(pathDescription.begin());
|
||||
pathDescription[0].turnInstruction = TurnInstructions.HeadOn;
|
||||
pathDescription[0].necessary = true;
|
||||
startPhantom.nodeBasedEdgeNameID = pathDescription[0].nameID;
|
||||
@ -106,7 +107,8 @@ void DescriptionFactory::Run(const unsigned zoomLevel, const unsigned duration)
|
||||
pathDescription[0].duration *= startPhantom.ratio;
|
||||
}
|
||||
if(1. == targetPhantom.ratio || 0 == pathDescription.back().length) {
|
||||
pathDescription.pop_back();
|
||||
if(pathDescription.size() > 2)
|
||||
pathDescription.pop_back();
|
||||
pathDescription.back().necessary = true;
|
||||
pathDescription.back().turnInstruction = TurnInstructions.NoTurn;
|
||||
targetPhantom.nodeBasedEdgeNameID = (pathDescription.end()-2)->nameID;
|
||||
|
Loading…
Reference in New Issue
Block a user