DennisOSRM/Project-OSRM — Issue #79: Function NNGrid::GetFileIndexForLatLon does not return the correct FileIndex
Author: DrVanScott
Created: 2012-01-16 00:02:28+00:00
State: open

NNGrid::GetFileIndexForLatLon returns a fileIndex one row apart of the correct grid position. In NNGrid.h at line 487 it says

unsigned line = 1073741824.0*y;

1073741824 is the square of 32768. The correct value here must be 32768 * 32768 - 32768:

unsigned line = 1073709056.0*y;

I stumbled upon that problem while analyzing all points checked by NNGrid::FindNearestPointOnEdge, which is used by the NearestPlugin. This functions checks all Edges on a 3x3 field. The center field should be the one, in which the requested lat/lon lies. But it doesn't. So the 3x3 field is not 'balanced'. As a result, the NNGrid::FindNearestPointOnEdge is not always able to get the nearest point on edge.