Retrieve all points within a given radius using quadkeys

416 views Asked by At

Im new to GIS concepts and im learning about Quadkeys and usage.

I am inserting few points with its quadkey into DB, and want to retrieve all points within a given radius using quadkeys.

Assume i have a point (46,46) whose quad key on a zoom level 23 is, 12122022101301320022121 (using this link)

Now i want to search all the points in DB that are at a radius of 100km to a reference point, say (47,47)

My idea is, use the given distance (100km) to find a zoom level, form a quadkey for (47,47) with that level, and query the DB with this key to retrive all keys that has the given prefix.

Any reference across web gives only conversion between Tile to Quad and vice versa.

How to efficiently calculate this Zoom level? Is this the right way of doing? Or is there a better way to deal with this using quadkeys.

1

There are 1 answers

0
Perfa On

Using quadkeys for querying the database is an interesting idea. Especially when I know which tiles you are targeting.

However, I would just searched distance to get items. STDistance (https://learn.microsoft.com/en-us/sql/t-sql/spatial-geography/stdistance-geography-data-type?view=sql-server-2017) for searching objects within a distance. Make sure you use spatial index for performance if you have perf issues.