From a558f447cfb6ccae6ec8a33c13ec2545ac19e5cb Mon Sep 17 00:00:00 2001 From: DennisOSRM Date: Thu, 22 Mar 2012 10:22:23 +0100 Subject: [PATCH] Fixes issue #198 --- DataStructures/NNGrid.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/DataStructures/NNGrid.h b/DataStructures/NNGrid.h index a2e7575ea..3054c176f 100644 --- a/DataStructures/NNGrid.h +++ b/DataStructures/NNGrid.h @@ -163,7 +163,7 @@ public: unsigned fileIndex = GetFileIndexForLatLon(startCoord.lat, startCoord.lon); std::vector<_GridEdge> candidates; boost::unordered_map< unsigned, unsigned, IdenticalHashFunction > cellMap; - for(int j = -32768; j < (32768+1); j+=32768) { + for(int j = -32768; (j < (32768+1)) && (fileIndex != UINT_MAX); j+=32768) { for(int i = -1; i < 2; ++i){ GetContentsOfFileBucket(fileIndex+i+j, candidates, cellMap); } @@ -497,8 +497,10 @@ private: double x = ( lon + 180.0 ) / 360.0; double y = ( lat + 180.0 ) / 360.0; - assert( x<=1.0 && x >= 0); - assert( y<=1.0 && y >= 0); + if( x>1.0 || x < 0.) + return UINT_MAX; + if( y>1.0 || y < 0.) + return UINT_MAX; unsigned line = (32768 * (32768-1))*y; line = line - (line % 32768);