Bing 地图根据已知点经纬度 距离 方位 计算另一点的经纬度的方法 转载自Bing官网

Calculate destination coordinate

Theory

Sometimes it’s useful to be able to calculate the coordinates of a destination based off a point of origin, a bearing (β) and a distance. One popular activity that uses this is orienteering. Orienteering is a competition which is a timed race where participants use a map, and a compass to navigate between check points. At each check point the participant will receive the bearing and distance to the next check point based on the current location of the check point. The distance that is used is the arc length (L) between the two points. Knowing this we can derive the central angle (δ) between the two points based at the center of the Earth.

clip_image002

Using the central angle and trigonometry we can calculate the latitude of the destination point using the following formula:

clip_image004

Now that we know the latitude of the destination point we can calculate the longitude by using the following formula:

clip_image006

 

Application

The function to calculate the destination coordinate will take in three parameters; a point of origin, a bearing, and a distance. With these parameters we can calculate the latitude and longitude coordinates of the destination point. This function returns a VELatLong object.

var earthRadius = 6367; //radius in km
function calculateCoord(origin, brng, arcLength){    
 var lat1 = DegtoRad(origin.Latitude);    
 var lon1 = DegtoRad(origin.Longitude);    
 var centralAngle = arcLength /earthRadius;
    var lat2 = Math.asin( Math.sin(lat1)*Math.cos(centralAngle) + Math.cos(lat1)*Math.sin(centralAngle)*Math.cos(DegtoRad(brng)));    
 var lon2 = lon1+ Math.atan2(Math.sin(DegToRad(brng))*Math.sin(centralAngle)*Math.cos(lat1),Math.cos(centralAngle)-Math.sin(lat1)*Math.sin(lat2));
    return new VELatLong(RadtoDeg(lat2),RadtoDeg(lon2));
}

Listing 1 Function to calculate a destination coordinate

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值