I am looking to use Redis' GEORADIUS
command.
However, this command only searches within the range of a two-dimensional circle around a given longitude and latitude. I need to also search with an altitude, thus finding results within the range of a three-dimensional sphere.
How would I achieve this in Redis?
I believe what you're actually trying to do is search within a 3D cylinder (or some kind of a cone if you take into account the Earth's spherical nature).
An altitude search isn't natively included with Redis' geospatial indices, but you could store that property in its own Sorted Set as score. Then, you can perform a range search (ZRANGEBYSCORE
) on the altitude and intersect (ZINTER
) the results with those from the radius query (hint: use a temporary key to STORE
results).
For your reference, this is the approach I took with the xyzsets in geo.lua.