/**
*
* @Description 获取两个成员之间的距离
* @Date 16:52 2021/6/24
* @Param [key, member1, member2]
* @return java.lang.Double
**/
public Double getDistance(Object key,Object member1,Object member2){
GeoOperations geoOperations = stringRedisTemplate.opsForGeo();
Distance distance = geoOperations.distance(key, member1, member2);
return distance.getValue();
}
/**
*
* @Description 获取成员的坐标
* @Date 17:57 2021/6/24
* @Param [key, members]
* @return java.util.List<org.springframework.data.geo.Point>
**/
public List<Point> getPoints(String key,String...members){
List<Point> points = stringRedisTemplate.opsForGeo().position(key,members);
return points;
}
/**
* 依据给定地理名称获取指定范畴内的地理位置汇合
* @param member 名称
* @param distance 间隔范畴
* @param args {@link RedisGeoCommands.GeoRadiusCommandArgs} 限度返回的个数和排序形式, 能够是 null
* @return
*/
public GeoResults<RedisGeoCommands.GeoLocation<String>> getMemberRadius(String key, String member, Distance distance, RedisGeoCommands.GeoRadiusCommandArgs args) {
GeoOperations<String, String> ops = stringRedisTemplate.opsForGeo();
return args == null ?
ops.radius(key, member, distance) : ops.radius(key, member, distance, args);
}
/**
* 依据给定地理坐标获取指定范畴内的地理位置汇合
* @param within 坐标
* @param distance 间隔范畴
* @param args {@link RedisGeoCommands.GeoRadiusCommandArgs} 限度返回的个数和排序形式, 能够是 null
* @return
*/
public GeoResults<RedisGeoCommands.GeoLocation<String>> getPointRadius(String key,Circle within, RedisGeoCommands.GeoRadiusCommandArgs args) {
GeoOperations<String, String> ops = stringRedisTemplate.opsForGeo();
return args == null ?
ops.radius(key, within) : ops.radius(key, within, args);
}
/**
* 获取某个地理名称的 geohash 值
* @param serviceStations 给定油站 key
* @return city geohashs
* */
public List<String> getServiceStationGeoHash(String key,String[] serviceStations) {
GeoOperations<String, String> ops = stringRedisTemplate.opsForGeo();
return ops.hash(key, serviceStations);
}
redis关于地理信息坐标距离计算的工具类.zip
版权申诉
62 浏览量
2023-03-09
14:12:49
上传
评论
收藏 1KB ZIP 举报
N201871643
- 粉丝: 795
- 资源: 2280
最新资源
- vscode-1.64.1.tar源码文件
- vscode-1.64.0.tar源码文件
- vscode-1.52.0.tar源码文件
- Music-Player +PlayerActivity+ rockplayer+ SeeJoPlayer 播放器JAVA源码
- vscode-1.46.0.tar源码文件
- 最近很火植物大战僵尸杂交版2.08苹果+安卓+PC+防闪退工具V2+修改工具+高清工具+通关存档整合包更新
- 超级好用的截图工具PixPin,可录制Gif图
- Screenshot_2024-05-21-17-06-42-64_2332cb9b27b851b548ba47a91682926c.jpg
- 毕业设计参考 - 基于树莓派、OpenCV及Python的人脸识别
- node-v18.20.2-linux-arm64
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈