Repository navigation
Description
I have an issue in which I'm using the LocationIndexTree to find the closest node, but I am using my own EdgeFilter such that sometimes the default search region bounded by the deltaLat and deltaLon is not sufficiently large to find a node that passes my filter and as such the findClosest() routine comes back "null". Ultimately I would love for the search to maybe auto-expand it's scope until it finds something, or maybe to be able to pass in some kind of parameter to the findClosest routine to tell it how big to look.
Right now, very inefficiently but it works for my problem at the moment, I have added a "regionSize" variable to the LocationIndexTree and I use it as follows in the findNetworkEntries method. If my QueryResult comes back as invalid I up the parameter (I have a setRegionSize() method on LocationIndexTree) and rerun the search. I continue until I find something. Most of the time the original value of 1 (default) is fine, very occasionally it needs to be 2 or 3 and once (out of a couple thousand times) it needs to be 11 with my current dataset. So the inefficiency of rerunning the search over the same nodes is not that critical for me at the moment and this seemed to be the quickest solution. But wondering if you have any thoughts on a more permanent and better solution and one that you would be happy incorporating back into the codebase.
protected TIntHashSet findNetworkEntries( double queryLat, double queryLon )
{
TIntHashSet storedNetworkEntryIds = new TIntHashSet();
if (regionSearch)
{
// search all rasters around minResolutionInMeter as we did not fill empty entries
double maxLat = queryLat + 1.5 * regionSize * deltaLat;
double maxLon = queryLon + 1.5 * regionSize * deltaLon;
for (double tmpLat = queryLat - ( deltaLat * regionSize ); tmpLat < maxLat; tmpLat += deltaLat)
{
for (double tmpLon = queryLon - ( deltaLon * regionSize); tmpLon < maxLon; tmpLon += deltaLon)
{
long keyPart = createReverseKey(tmpLat, tmpLon);
// System.out.println(BitUtilLittle.toBitString(key, keyAlgo.bits()));
fillIDs(keyPart, START_POINTER, storedNetworkEntryIds, 0);
}
}
} else
{
long keyPart = createReverseKey(queryLat, queryLon);
fillIDs(keyPart, START_POINTER, storedNetworkEntryIds, 0);
}
return storedNetworkEntryIds;
}
Cheers,
Ken
Activity
karussell commentedon Jun 14, 2014
Yes, I would really like to have something like this. Instead of rerunning the query, why not increase the scope of the search automatically. Here is some pseudocode with a nice pic ;)
As we search with a box and not with a circle this can lead to slightly incorrect results so we have to filter the returned nodes via new Circle(lat,lon,boxWidth/2).contains(query):
All in all we will improve the location index lookup to be faster in a lot cases and more dynamic in some rare cases. Faster, because we can decrease index.highResolution to e.g. 200 and we only query one tile (currently 9 by default)
karussell commentedon Jun 22, 2014
Closing. Will be fixed in #221, where also more details about a correct and fast procedure is described.
cleaner error message and do not break app if unparsable coordinates,…
error message must not disappear in general (graphhopper#218), and th…