Delphi 计算两个坐标点之间的距离(高德地图)  
官方Delphi 学习QQ群: 682628230(三千人)
频道

Delphi 计算两个坐标点之间的距离(高德地图)


Delphi 计算两个坐标点之间的距离(高德地图)
参考这个文章,Java写的,改写成Delphi版本:

function MeasuerDistance(const startLongitude,startLatitude,endLongitude,endLatitude:Double):Integer;
begin
 const Earth_RAdius=6378137;
 var radLatitude1 := startLatitude * PI / 180.0;
 var radLatitude2 := endLatitude * PI / 180.0;
 var a := abs(radLatitude1 - radLatitude2);
 var b := abs(startLongitude * PI / 180.0 - endLongitude * PI / 180.0);
 var s := 2 * arcsin(sqrt(power(sin(a / 2), 2) + cos(radLatitude1) * cos(radLatitude2) * power(sin(b / 2), 2)));
     s := s * EARTH_RADIUS;
     result :=round(round(s * 10000) / 10000); // 返回距离单位是米
end;

向作者表示感谢!


来源:https://www.cnblogs.com/kinglandsoft/p/16516295.html


推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.15146398544312 seconds