From 6eab47d76889d177478b9bb0e3fc45b6126fff24 Mon Sep 17 00:00:00 2001 From: DennisOSRM Date: Fri, 5 Oct 2012 15:25:12 +0200 Subject: [PATCH] Fixing origin (0,0) tests --- DataStructures/NNGrid.h | 15 +++++++++++---- features/testbot/origin.feature | 4 ++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/DataStructures/NNGrid.h b/DataStructures/NNGrid.h index 45285c424..51144c8c6 100644 --- a/DataStructures/NNGrid.h +++ b/DataStructures/NNGrid.h @@ -156,7 +156,7 @@ public: bool FindPhantomNodeForCoordinate( const _Coordinate & location, PhantomNode & resultNode, const unsigned zoomLevel) { bool ignoreTinyComponents = (zoomLevel <= 14); -// INFO("ZoomLevel: " << zoomLevel << ", ignoring tinyComponentents: " << (ignoreTinyComponents ? "yes" : "no")); +// INFO("Coordinate: " << location << ", zoomLevel: " << zoomLevel << ", ignoring tinyComponentents: " << (ignoreTinyComponents ? "yes" : "no")); // double time1 = get_timestamp(); bool foundNode = false; const _Coordinate startCoord(100000*(lat2y(static_cast(location.lat)/100000.)), location.lon); @@ -166,7 +166,9 @@ public: const int lowerBoundForLoop = (fileIndex < 32768 ? 0 : -32768); for(int j = lowerBoundForLoop; (j < (32768+1)) && (fileIndex != UINT_MAX); j+=32768) { for(int i = -1; i < 2; ++i){ +// unsigned oldSize = candidates.size(); GetContentsOfFileBucketEnumerated(fileIndex+i+j, candidates); +// INFO("Getting fileIndex=" << fileIndex+i+j << " with " << candidates.size() - oldSize << " candidates"); } } _GridEdge smallestEdge; @@ -179,6 +181,7 @@ public: continue; r = 0.; tmpDist = ComputeDistance(startCoord, candidate.startCoord, candidate.targetCoord, tmp, &r); +// INFO("Looking at edge " << candidate.edgeBasedNode << " at distance " << tmpDist); if(tmpDist < dist && !DoubleEpsilonCompare(dist, tmpDist)) { // INFO("a) " << candidate.edgeBasedNode << ", dist: " << tmpDist << ", tinyCC: " << (candidate.belongsToTinyComponent ? "yes" : "no")); dist = tmpDist; @@ -225,7 +228,8 @@ public: resultNode.weight2 -= resultNode.weight1; } resultNode.ratio = ratio; - // INFO("New weight1: " << resultNode.weight1 << ", new weight2: " << resultNode.weight2 << ", 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--"); // double time2 = get_timestamp(); // INFO("NN-Lookup in " << 1000*(time2-time1) << "ms"); @@ -466,7 +470,7 @@ private: #endif inline double ComputeDistance(const _Coordinate& inputPoint, const _Coordinate& source, const _Coordinate& target, _Coordinate& nearest, double *r) { - +// INFO("comparing point " << inputPoint << " to edge [" << source << "-" << target << "]"); const double x = static_cast(inputPoint.lat); const double y = static_cast(inputPoint.lon); const double a = static_cast(source.lat); @@ -474,6 +478,7 @@ private: const double c = static_cast(target.lat); const double d = static_cast(target.lon); double p,q,mX,nY; +// INFO("x=" << x << ", y=" << y << ", a=" << a << ", b=" << b << ", c=" << c << ", d=" << d); if(fabs(a-c) > FLT_EPSILON){ const double m = (d-b)/(c-a); // slope // Projection of (x,y) on line joining (a,b) and (c,d) @@ -486,7 +491,9 @@ private: } nY = (d*p - c*q)/(a*d - b*c); mX = (p - nY*a)/c;// These values are actually n/m+n and m/m+n , we neednot calculate the values of m an n as we are just interested in the ratio - *r = mX; +// INFO("p=" << p << ", q=" << q << ", nY=" << nY << ", mX=" << mX); + *r = std::isnan(mX) ? 0. : mX; +// INFO("r=" << *r); if(*r<=0.){ nearest.lat = source.lat; nearest.lon = source.lon; diff --git a/features/testbot/origin.feature b/features/testbot/origin.feature index 2971cc8cf..9f3979540 100644 --- a/features/testbot/origin.feature +++ b/features/testbot/origin.feature @@ -53,7 +53,7 @@ Feature: Routing close to the [0,0] origin When I route I should get | from | to | route | distance | - | b | d | abcde | 200m +-1 | + | b | d | abcde | 200m +-2 | | d | b | | | Scenario: North-south oneways crossing the origin @@ -71,5 +71,5 @@ Feature: Routing close to the [0,0] origin When I route I should get | from | to | route | distance | - | b | d | abcde | 200m +-1 | + | b | d | abcde | 200m +-2 | | d | b | | |