ActionScript 3 AS3获取两个地理点之间的距离
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ActionScript 3 AS3获取两个地理点之间的距离相关的知识,希望对你有一定的参考价值。
private const RADIUS_OF_EARTH_IN_MILES:int = 3963;
private const RADIUS_OF_EARTH_IN_FEET:int =20925525;
private const RADIUS_OF_EARTH_IN_KM:int =6378;
private const RADIUS_OF_EARTH_IN_M:int =6378000;
private function distanceBetweenCoordinates(lat1:Number,lon1:Number,
lat2:Number,lon2:Number,
units:String="miles"):Number{
var R:int = RADIUS_OF_EARTH_IN_MILES;
if (units == "km"){
R = RADIUS_OF_EARTH_IN_KM;
}
if (units == "meters"){
R = RADIUS_OF_EARTH_IN_M;
}
if (units =="feet"){
R= RADIUS_OF_EARTH_IN_FEET;
}
var dLat:Number = (lat2-lat1) * Math.PI/180;
var dLon:Number = (lon2-lon1) * Math.PI/180;
var lat1inRadians:Number = lat1 * Math.PI/180;
var lat2inRadians:Number = lat2 * Math.PI/180;
var a:Number = Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.sin(dLon/2) * Math.sin(dLon/2) *
Math.cos(lat1inRadians) * Math.cos(lat2inRadians);
var c:Number = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
var d:Number = R * c;
return d;
}
以上是关于ActionScript 3 AS3获取两个地理点之间的距离的主要内容,如果未能解决你的问题,请参考以下文章
ActionScript 3 AS3按类名获取类引用
ActionScript 3 通过ActionScript 3(和as3corelib)获取美味的JSON提要
ActionScript 3 AS3在0,0处绘制一个点以显示DisplayObject的中心
ActionScript 3 AS3:获取指定对象的所有子项
ActionScript 3 AS3从GetObjectsUnderPoint获取对象名称
ActionScript 3 AS3获取MC的所有孩子