计算距离

//根据经纬度计算附近商家距离   
/* @param $lng,经度
*  @param $lat,纬度
*  @param $distance  计算的距离
*  @param $sort   根据距离排序
*/

function NearStore( l n g , lng, lng,lat, d i s t a n c e , distance, distance,sort){
s q l = &quot; s e l e c t ∗ , s q r t ( ( ( ( &quot; . sql = &quot;select *, sqrt( ( ((&quot;. sql="select,sqrt((((".lng."-lng)*PI()12656cos(((". l a t . &quot; + l a t ) / 2 ) ∗ P I ( ) / 180 ) / 180 ) ∗ ( ( &quot; . lat.&quot;+lat)/2)*PI()/180)/180) * ((&quot;. lat."+lat)/2)PI()/180)/180)((".lng."-lng)*PI()12656cos (((". l a t . &quot; + l a t ) / 2 ) ∗ P I ( ) / 180 ) / 180 ) ) + ( ( ( &quot; . lat.&quot;+lat)/2)*PI()/180)/180) ) + ( ((&quot;. lat."+lat)/2)PI()/180)/180))+(((".lat."-lat)*PI()*12656/180) * ((".$lat."- lat)*PI()*12656/180) ) )/2 as distancefrom 表名 group by distance s o r t h a v i n g d i s t a n c e &lt; &quot; . sort having distance &lt;&quot;. sorthavingdistance<".distance;
p d o − &gt; q u e r y ( pdo-&gt;query( pdo>query(sql);}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值