GEOHASH

Syntax
GEOHASH key [member [member ...]]
Available since:
3.2.0
Time complexity:
O(1) for each member requested.
ACL categories:
@read, @geo, @slow,

返回有效的Geohash字符串,表示在表示地理空间索引的排序集合值中一个或多个元素的位置(其中元素是使用GEOADD添加的)。

通常,Redis 使用 Geohash 技术的一种变体来表示元素的位置,其中位置使用 52 位整数进行编码。与标准相比,编码也有所不同,因为在编码和解码过程中使用的初始最小和最大坐标是不同的。然而,此命令返回一个标准的 Geohash,以字符串的形式,如维基百科文章中所述,并与geohash.org网站兼容。

Geohash字符串属性

该命令返回11个字符的Geohash字符串,因此与Redis内部的52位表示相比,不会丢失精度。返回的Geohash具有以下属性:

  1. 它们可以通过从右侧移除字符来缩短。这将失去精度,但仍将指向同一区域。
  2. 可以在geohash.org URL中使用它们,例如http://geohash.org/。这是一个此类URL的示例
  3. 具有相似前缀的字符串彼此靠近,但反之则不然,不同前缀的字符串也可能彼此靠近。

示例

GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania" GEOHASH Sicily Palermo Catania

RESP2 回复

Array reply: an array where each element is the Geohash corresponding to each member name passed as an argument to the command.

RESP3 回复

Array reply: An array where each element is the Geohash corresponding to each member name passed as an argument to the command.
RATE THIS PAGE
Back to top ↑