0

I want to do a bounding box query a Trie of geohashed strings where the points lie all around the center of the space. I can't seem to find a good way to query the trie when the points straddle the center point.

Say you have 4 bits per coordinate (8 total) of information on a 16x16 space where each box is 1x1. Essentially, a 16x16 grid.

The red line shows the most corse division of the quad tree which is used in the geohash.

Example image

Trie representing the graphic above.

bits=4, min=0, max=16, numBuckets=16.0, scaling=1.0, tree={
└── null
    ├── 0
    │   ├── (0110100) 00110100 = {(6, 6), hash=00110100}
    │   └── (1100000) 01100000 = {(6, 8), hash=01100000}
    └── 1
        ├── (0010101) 10010101 = {(8, 7), hash=10010101}
        └── (1000010) 11000010 = {(9, 8), hash=11000010}

A bounding box query is defined as a upper-left point and a length, width. e.g. (6,6 4x4) Should return 6,6 6,8 8,7 and 9,8.

One approach I thought of is: Start from the most precise box containing the upper-left coordinate and keep getting less precise until I can cover the 4x4 square. But if I do that I end up querying the whole tree in this example. I just don't see a "better" way to do it.

4

1 回答 1

1

If you can add extra information to the nodes of your trie structure I would ignore the GeoHash encoding and treat it as an arbitrary tree structure. Working from the leaves up you can compute a bounding box round each node that just encloses all the points beneath that node. Then when you search from the top down for a point (or area) you can stop searching at a node when its bounding box does not enclose (or intersect) your query point (or area).

If you can afford to keep this updated, then you will gain when your search point or area is not inside (or does not intersect) a bounding box that encloses all the points that are actually below some node, even if the search point or area could overlap some point could in theory GeoHash to that area.

于 2013-01-30T20:12:17.310 回答