GEOADD

Since 1.1.0Geospatial

Syntax

GEOADD key [NX | XX] [CH] longitude latitude member [longitude latitude member ...]
  • Flags: write
  • ACL categories: @geo, @slow, @write
  • Arity: -5

Adds places, each a longitude, a latitude and a name, to the geospatial index at key: a sorted set whose scores encode positions, so that it can be searched by distance. A missing key is created.

Options

OptionEffect
NXOnly add new members; do not move existing ones.
XXOnly move existing members; do not add new ones.
CHCount moved members as well as added ones in the reply.

Longitudes go from -180 to 180, latitudes from -85.05112878 to 85.05112878.

Reply

  • The number of members added; with CH, added or moved.
  • ERR invalid longitude,latitude pair for a position out of range.

Examples

> GEOADD g 13.361389 38.115556 Palermo 15.087269 37.502669 Catania
(integer) 2
> GEOADD g NX 13.4 38.1 Palermo 12.5 41.9 Rome
(integer) 1
> GEOADD g 200 100 bad
(error) ERR invalid longitude,latitude pair 200.000000,100.000000