Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Redis have a get ‘N geographically closest’ capability?

I’ve been working with GEORADIUS and the suite of functions but I’m curious if there’s a way to get the 100 closest members in a Z sorted GEORADIUS key.

For instance... I don’t know how many members are geographically close to a known member, so I don’t know how large of a radius to use with GEORADIUS in order to get 100 of the closest members.

How would I do this?

like image 595
Aaron Avatar asked Dec 01 '25 02:12

Aaron


2 Answers

Redis' GEO support is limited. There's no such command, and you need to do it on the client side:

  1. Use 1 meter as the radius to check if there're enough items.
  2. If there're enough items, get the N closest items from the result.
  3. If there're NOT enough items, double the radius, and goto step 1.
like image 131
for_stack Avatar answered Dec 05 '25 09:12

for_stack


JaguarDB has very strong support of geospatial data (2D and 3D). It allows you to store multi-measurements per point location while other databases support only one measurement (pointm). Many complex queries such as KNN, Voronoi polygon, convexhull are also supported. It is open source. The KNN k nearest neighbor query can help you. It also supports vector shapes in addition to raster shapes like linestrings polygons.

like image 21
Jon Avatar answered Dec 05 '25 10:12

Jon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!