redis GEO use

First, the concept

  1. GEO characteristics redis in Redis3.2 release, this function can be given by the user's location information stored, and these information operations.
  2. GEO common language LBS (Location Based Service), location-based services.

Two, GEO-related commands

  • Command name: geoadd
  • 语法:geoadd key longitude latitude member [longitude latitude member……]
  • Features:
    • Given spatial elements (latitude, longitude, name) to the specified key inside.
    • Effective longitude between -180 degrees to 180 degrees.
    • Effective dimension between 85.05112878 -85.05112878 degrees and degrees.
  • return value:
    • The new element is added to the amount of space inside the key, but does not include those elements are updated already exists.

 

  • Command name: geopos
  • 语法:geopos key member [member……]
  • Features:
    • Returns all elements from a given position inside the key position (longitude and latitude)
  • return value:
    • Returns an array, each entry in the array consists of two elements: a first element to a predetermined longitude position of the element, the second element is a given latitude position of the element.

 

  • Command name: geodist
  • 语法:geodist key member1 member2 [unit]
  • Features:
    • Returns the distance between the two given positions.
    • If one of the positions between the two does not exist, then return null.
    • Parameter unit designated units must be about one unit :( default m, km, mi, ft)
  • return value:
    • Calculated distance will be returned in the form of double precision floating point. If a given position element does not exist, then the command returns a null value.

 

  • Command name: GeoRadius
  • 语法:georadius key longitude latitude radius m|km|gt|mi [WITHCOORD] [WITHDIST] [WITHHASH] [ASC|DESC] [COUNT count]
  • Function: 1) at a given latitude and longitude as the center, from the position of the element which contains the return key, the center positions of all the elements but does not exceed a given maximum distance.
  • Options:
    • WITHDIST: while the return position of the element, the distance between the center position of the elements is also returned together.
    • WITHCOORD: the longitude and latitude position of the element together also return.
    • WITHHASH: 52 in the form of a signed integer, the position of the element through the return value of the original ordered set of encoded geohash. This option is mainly used for debugging or underlying application, the role of practice is not significant.
    • ASC: The position of the center, according to the return from a position near to far way an element
    • DESC: The position of the center, according to the embodiment near to far from the position of the return element

 

  • Command name: georadiusbymember
  • 语法:georadiusbymemeber key member radius m|km|ft|mi [WITHCOORD] [WITHDIST] [WITHHASH] [ASC|DESC] [COUNT count]
  • Features:
    • This command and georadius command.
    • The difference is that the central point is determined by the position of a given element.
  • return value:
    • An array, each entry in the array represents the position of elements within a range.

 

  • Command name: geohash
  • 语法:geohash key member [member……]
  • Features:
    • Return one or more location elements geohash FIG.
  • return value:
    • An array, the array is a geohash each item. Geohash position command returns the position of the user with the given position of the elements correspond.

Guess you like

Origin www.cnblogs.com/lxhyty/p/11511718.html
GEO