数据迁移至www.chinaoc.com.cn,点击查看详细:
Google Maps API V3学习(例子不断增加中)
1 楼
sword88
2010-11-03
如果知道两点的坐标,如何求两点之间的距离? 新手较菜忽喷~~
2 楼
huangxin5257
2011-12-17
sword88 写道
如果知道两点的坐标,如何求两点之间的距离? 新手较菜忽喷~~
mysql function 实现版本
CREATE DEFINER=`root`@`%` FUNCTION `F_calculate_distance`(Lat1 float,Lon1 float,Lat2 float,Lon2 float) RETURNS float
BEGIN
declare ret float;
declare r float;
declare A float;
declare B float;
declare RA float;
declare RB float;
declare RL1 float;
declare RL2 float;
set r = 6378137;
set A = abs(Lat1 - Lat2);
set B = abs(Lon1 - Lon2);
set RA = A * pi() / 180.0;
set RB = B * pi() / 180.0;
set RL1 = Lat1 * pi() / 180.0;
set RL2 = Lat2 * pi() / 180.0;
set ret = cast(2 * r * asin(sqrt(sin(RA/2) * sin(RA/2) + cos(RL1) * cos(RL2) * sin(RB/2) * sin(RB/2))) as decimal(8,0));
return ret;
END;