Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bounding box search? #8

Open
JoseExposito opened this issue Jul 29, 2019 · 1 comment
Open

Bounding box search? #8

JoseExposito opened this issue Jul 29, 2019 · 1 comment

Comments

@JoseExposito
Copy link

Hi,

First, thank you very much for the library :)

I'm storing items in my DB associated to a geohash with precision 6 and I need to get all items inside a rectangular area in the map.

Is there any API to get all the geohashes inside a rectangle defined by 2 (or 4) coordinates?
I am not sure if I can use neighbours to archive this.

Thank you very much in advance.

@WhiskeyTuesday
Copy link

geohashes are infinite precision so the result of such an operation would always be an infinite set unless you specify the precision in the query. There's probably more efficient ways to do it but the first thing that comes to mind is you'd use a loop to generate "lines" incremented at the desired precision along a straight trajectory from one corner to the next, then you could then construct a loop which increments the geohash by one and checks if the current position is in the "lines" array. Essentially you're doing a raster scan like an old TV. If it's not in the lines array, add it to an "inside" array, if it is, jump to one increment south of the start position of that line, if that's also a line, you've hit the end.

Something like that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants