From 01a6e3c6192b3cd81c406e357e3ec7cf8b18a6ca Mon Sep 17 00:00:00 2001 From: DennisOSRM Date: Sun, 27 Jan 2013 14:21:42 +0100 Subject: [PATCH] Fixed the computation of reverse edge weight --- DataStructures/NNGrid.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/DataStructures/NNGrid.h b/DataStructures/NNGrid.h index 92a6594e6..8c0747448 100644 --- a/DataStructures/NNGrid.h +++ b/DataStructures/NNGrid.h @@ -218,7 +218,7 @@ public: // } // INFO("startCoord: " << smallestEdge.startCoord << "; targetCoord: " << smallestEdge.targetCoord << "; newEndpoint: " << resultNode.location); - double ratio = (foundNode ? std::min(1., ApproximateDistance(smallestEdge.startCoord, resultNode.location)/ApproximateDistance(smallestEdge.startCoord, smallestEdge.targetCoord)) : 0); + const double ratio = (foundNode ? std::min(1., ApproximateDistance(smallestEdge.startCoord, resultNode.location)/ApproximateDistance(smallestEdge.startCoord, smallestEdge.targetCoord)) : 0); resultNode.location.lat = round(100000.*(y2lat(static_cast(resultNode.location.lat)/100000.))); // INFO("Length of vector: " << ApproximateDistance(smallestEdge.startCoord, resultNode.location)/ApproximateDistance(smallestEdge.startCoord, smallestEdge.targetCoord)); //Hack to fix rounding errors and wandering via nodes. @@ -229,12 +229,13 @@ public: resultNode.weight1 *= ratio; if(INT_MAX != resultNode.weight2) { - resultNode.weight2 -= resultNode.weight1; + resultNode.weight2 *= (1.-ratio); } resultNode.ratio = ratio; -// INFO("New weight1: " << resultNode.weight1 << ", new weight2: " << resultNode.weight2 << ", ratio: " << ratio); // INFO("start: " << edgeStartCoord << ", end: " << edgeEndCoord); -// INFO("selected node: " << resultNode.edgeBasedNode << ", bidirected: " << (resultNode.isBidirected() ? "yes" : "no") << "\n--"); +// INFO("selected node: " << resultNode.edgeBasedNode << ", bidirected: " << (resultNode.isBidirected() ? "yes" : "no")); +// INFO("New weight1: " << resultNode.weight1 << ", new weight2: " << resultNode.weight2 << ", ratio: " << ratio); + // INFO("distance to input coordinate: " << ApproximateDistance(location, resultNode.location) << "\n--"); // double time2 = get_timestamp(); // INFO("NN-Lookup in " << 1000*(time2-time1) << "ms"); return foundNode;