首页 > 编程知识 正文

经纬度算弧度,php公里换算

时间:2023-05-04 17:36:27 阅读:130274 作者:1614

传递参数:

地址1纬度: $lat1,经度: $lng1,

地址2的纬度$lat2、经度: $lng2、

示例:

封装方法:

/** *个纬度与经度的距离*/publicfunctiongetdistance ($ la t1、$lng1、$lat2、$lng2) ) { $earthRadius=6367000; //approximateradiusofearthinmeters $ la t1=($ la t1 * pi ) )/180; $LNG1=($LNG1*pi ) ) ) )/180; $lat2=($lat2*pi ) ) )/180; $LNG2=($LNG2*pi ) ) ) )/180; $calcLongitude=$lng2 - $lng1; $calcLatitude=$lat2 - $lat1; $Stepone=pow(sin ) $calclatitude/2 )、2 ) cos ) $laT1 )、cos ) $laT2 )、pow ) sin ) $calclongitude/2 )、2; $steptwo=2*Asin(min(1,sqrt ) $Stepone ); $ calculated distance=$ earth radius * $ step two; 返回旋转($ calculated distance; }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。