Skip to content

Latest commit

 

History

History
78 lines (60 loc) · 2.05 KB

08.经纬度数据操作.md

File metadata and controls

78 lines (60 loc) · 2.05 KB

1. geoadd 添加地理位置信息

geoadd key longitude latitude member [longitude latitude member ...]
# longitude表示经度,latitude表示纬度,member表示成员

# 示例
127.0.0.1:6379> geoadd Guangdong-cities 113.2278442 23.1255978 Guangzhou 113.106308 23.0088312 Foshan 113.7943267 22.9761989 Dongguan 114.0538788 22.5551603 Shenzhen
(integer) 4

2. geopos 查询位置的坐标

geopos location-set name [name ...]

# 示例
127.0.0.1:6379> geopos Guangdong-cities Guangzhou Shenzhen
1) 1) "113.22784155607223511"
   2) "23.1255982020608073"
2) 1) "114.05388146638870239"
   2) "22.55515920515157546"

3. geodist 查询位置距离

geodist key member1 member2 [m|km|mi|ft]
# 查询两个位置之间的距离

# 示例
127.0.0.1:6379> geodist Guangdong-cities Guangzhou Shenzhen
"105806.7782"

4. georadius 查询某点的附近点

georadius key longitude latitude radius m|km|mi|ft
# 指定经纬度作为中心来查询附近的点

# 示例
127.0.0.1:6379> georadius Guangdong-cities 113.2278442 23.1255978 100 km
1) "Foshan"
2) "Guangzhou"
3) "Dongguan"

5. georadiusbymember 查询某位置距离的附近点

georadiusbymember key member radius m|km|ft|mi
# 指定成员作为中心来查询附近的点

# 示例
127.0.0.1:6379> georadiusbymember Guangdong-cities Guangzhou 100 km
1) "Foshan"
2) "Guangzhou"
3) "Dongguan"

6. geohash 查询位置GEOHASH编码

geohash key member [member ...]
# 返回位置元素的哈希值

# 示例
127.0.0.1:6379> geohash Guangdong-cities Guangzhou
1) "ws0e89curg0"