先贴代码:
/**
*
* geoadd beijing 116.318427 39.986771 中钢大厦 116.318227 39.986271 新中关村大厦
*/
RedisGeoCommands.GeoLocation geoLocation=new RedisGeoCommands.GeoLocation("中钢大厦",new Point(111,111));
redisTemplate.opsForGeo().add("beijing",geoLocation);
RedisGeoCommands.GeoLocation geoLocation1=new RedisGeoCommands.GeoLocation("良乡大学城",new Point(111,111));;
RedisGeoCommands.GeoLocation geoLocation2=new RedisGeoCommands.GeoLocation("新中关村大厦",new Point(111,111));;
/**
* 返回两点之间的距离
* geodist 良乡大学城 新中关村大厦
*/
redisTemplate.opsForGeo().distance("beijing",geoLocation1,geoLocation2);
/**
* 返回点的hash表示
* geohash 良乡大学城 新中关村大厦
*/
redisTemplate.opsForGeo().hash("beijing",geoLocation1,geoLocation2);
/**
* 获取position
* geopos 良乡大学城 新中关村大厦
*/
redisTemplate.opsForGeo().position("beijing",geoLocation1,geoLocation2);
/**
* 使用输入的经度和纬度来决定中心点。
*
* georadius 116.4554 39.3432 6 km
*/
Circle radius=new Circle(new Point(116.4554 ,39.3432),6);
redisTemplate.opsForGeo().radius("beijing",radius).getContent();
/**
* 使用已有的点作为中心点
* georadiusbymember beijing liangxiang 6 km
*/
redisTemplate.opsForGeo().radius("beijing",geoLocation1,6).getContent();