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

How can I geo search by non-axis box? #13344

Open
sapirshamun opened this issue Jun 13, 2024 · 2 comments
Open

How can I geo search by non-axis box? #13344

sapirshamun opened this issue Jun 13, 2024 · 2 comments

Comments

@sapirshamun
Copy link

Hi,
I would like to add points on the map using geo add and then searching all points in a rectangle which isn't axis-aligned.
There is any option to do it?

@sapirshamun sapirshamun changed the title How can I do geo search by non-axis box? How can I geo search by non-axis box? Jun 13, 2024
@LiorKogan
Copy link
Member

LiorKogan commented Jun 13, 2024

With Redis Stack, you can use FT.SEARCH for such geographical queries: find all points within a specified polygon. See https://redis.io/docs/latest/develop/interact/search-and-query/query/geo-spatial/, https://github.com/redis-developer/redis-polygon-search-trains-demo, https://www.youtube.com/watch?v=CegTSglMUks

@sapirshamun
Copy link
Author

Thanks!
At the end I have an envelope which is axis-aligned, it is defined by x1,x2,y1,y2.
I understand that I can use GEOSEARCH with the BYBOX option(which seems to be more efficient), but it seems to require converting the envelope's width and height from degrees to kilometers.
Can I directly provide the minimum and maximum latitude and longitude values to GEOSEARCH BYBOX instead of having to calculate distances in kilometers? I believe that Redis internally needs the latitude/longitude definition of the rectangle to perform the search, so I'm not sure why this functionality isn't exposed in the command.

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