I'm using redis geosearch
function to look for coordinates that were introduced in the database from differents points from my API, the problem is, because of some misunderstanding, some services used geoadd key fromlonlat latitude longitude
and others used geoadd key fromlonlat longitude latitude
and now my geosearch doesn't return the correct results, always parcially correct results. I would like to know why this happens, since when using redis geoadd
function, the longitude and latitude are transformed into 1 geohashed string, shouldn't it work even with inverted types of coordinates? Why does it have to be in this exact same order as the documentation.
Also considering most of the coordinates saved were using geoadd key fromlonlat latitude longitude
, should I implement the rest incorrectly to continue the pattern or start using it correctly and deal with the older coordinates?
CodePudding user response:
From the inception of the Geo data structure, the order has always been lon,lat. This is a pain point that many have encountered (including myself). Unfortunately, no you cannot just reverse all of the coordinates and expect the geo data structure to work properly, the command expects the longitude and latitude in the correct order, if they're out of order it won't know how to compile the geo hashes correctly, and there are wide ranges of valid longitudes that are illegal as latitudes (see the geoadd page you linked to)