summaryrefslogtreecommitdiffstats
path: root/iredis/data/commands/geodecode.md
blob: f083fd946090cfa97c9016c22e50d879008a2b83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Geospatial Redis commands encode positions of objects in a single 52 bit
integer, using a technique called geohash. Those 52 bit integers are:

1. Returned by `GEOAENCODE` as return value.
2. Used by `GEOADD` as sorted set scores of members.

The `GEODECODE` command is able to translate the 52 bit integers back into a
position expressed as longitude and latitude. The command also returns the
corners of the box that the 52 bit integer identifies on the earth surface,
since each 52 integer actually represent not a single point, but a small area.

This command usefulness is limited to the rare situations where you want to
fetch raw data from the sorted set, for example with `ZRANGE`, and later need to
decode the scores into positions. The other obvious use is debugging.

@return

@array-reply, specifically:

The command returns an array of three elements. Each element of the main array
is an array of two elements, specifying a longitude and a latitude. So the
returned value is in the following form:

- center-longitude, center-latitude
- min-longitude, min-latitude
- max-longitude, max-latitude

@examples

```cli
GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania"
ZSCORE Sicily "Palermo"
GEODECODE 3479099956230698
```