Skip to content

Allow Broader Search in LocationIndexTree #218

Closed

Description

@crowmagnumb

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

  1. karussell commented on Jun 14, 2014

    @karussell
    Member

    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 ;)

    | A | B | C | D | E | 
    | F | G | H | I | J | 
    | K | L | M | N | O |
    | P | Q | R | S | T |
    | U | V | W | X | Y |
    
    1. Imagine the query comes to tile M, if already found some nodes then return
    2. Query the "+1 sourounding' tiles ala G, H, I, L, N, Q, R, S, if found some nodes then return
    3. Query the "+2 sourounding' tiles ala A, B, C, D, E, F, J, K, O, ..., if found some nodes then return

    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):

    newNodeSet = circleFilter(returnedNodes)
    if !newNodeSet.isEmpty
       return newNodeSet
    else
       continue
    

    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)

  2. karussell commented on Jun 22, 2014

    @karussell
    Member

    Closing. Will be fixed in #221, where also more details about a correct and fast procedure is described.

  3. added this to the 0.4 milestone on Jun 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions