phpredis扩展实现LBS距离计算和范围筛选

来源

public function geo(){ $redis = new edis(); $redis -> connect('127.0.0.1',6379); //位置增加 $res= $redis->geoAdd("cs",13.361389,38.115556,'peter',13.361389,38.125566,'peter1'); //位置获取 $redis->geoPos("cs",'peter'); //两点之间的距离 $redis->geoDist("cs",'peter','peter1','m'); //范围查询:200m内的坐标点 $potion=['WITHHASH','count'=>2,'ASC'];//空字符串 返回key,WITHCOORD 返回key和经纬度 WITHHASH 返回key和距离 count返回几条 ASC和DESC降序和升序 return $redis->geoRadius("cs",13.361389,38.115556,'200','m',$potion); //m 米 km千米 }
原文地址:https://www.cnblogs.com/chengfengchi/p/10756086.html