地图位置附近资源使用redis geo实现

 

先贴代码:
 

 /**
         *
         * 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();

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大巨魔战将

如果对您有帮助,请打赏1分钱

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值