[OSM-dev] spatial index - B-Tree over z-order curves vs R-Tree over GIST

Matt Amos zerebubuth at gmail.com
Thu Apr 9 15:29:19 BST 2009


On Thu, Apr 9, 2009 at 3:17 PM, pablo platt <pablo.platt at gmail.com> wrote:
> How do I query this db?
> For example, if I want to find all records in a distance <= 1.5KM from a
> (lat, lng) point.

find all quadtiles within 1.5km from a point by using the fact that
they're in a regular grid. query the db to find all the records having
a tilecode in that list. finally, add a filter to remove any points
which might be in one of the tiles but is >1.5km from your point.

have a look at how OSM server builds the query for bounding boxes:
http://trac.openstreetmap.org/browser/sites/rails_port/lib/osm.rb#L241
http://trac.openstreetmap.org/browser/sites/rails_port/lib/quad_tile.rb#L44

cheers,

matt




More information about the dev mailing list