计算bing贴图中两点之间的距离 [英] Calculate distance between two points in bing maps
本文介绍了计算bing贴图中两点之间的距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个bing地图,和两个点:$ b $ b Point1,Point2和我想计算这两点之间的距离?那可能吗?
,如果我想在point1和point2之间的路径的三分之一和point2附近放一个圆...我怎么能做呢?
Ihave a bing map, and a two points : Point1,Point2 and i want to calculate the distance between these two points? is that possible? and if i want to put a circle on the two third of the path between point1 and point2 and near point2 ...how can i make it?
推荐答案
请参阅 Haversine 或更好的 Vincenty 公式如何解决这个问题。
See Haversine or even better the Vincenty formula how to solve this problem.
下面的代码使用haversines方式获取距离:
The following code uses haversines way to get the distance:
public double GetDistanceBetweenPoints(double lat1, double long1, double lat2, double long2)
{
double distance = 0;
double dLat = (lat2 - lat1) / 180* Math.PI;
double dLong = (long2 - long1) / 180 * Math.PI;
double a = Math.Sin(dLat / 2) * Math.Sin(dLat / 2)
+ Math.Cos(lat1 / 180* Math.PI) * Math.Cos(lat2 / 180* Math.PI)
* Math.Sin(dLong/2) * Math.Sin(dLong/2);
double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
//Calculate radius of earth
// For this you can assume any of the two points.
double radiusE = 6378135; // Equatorial radius, in metres
double radiusP = 6356750; // Polar Radius
//Numerator part of function
double nr = Math.Pow(radiusE * radiusP * Math.Cos(lat1 / 180 * Math.PI), 2);
//Denominator part of the function
double dr = Math.Pow(radiusE * Math.Cos(lat1 / 180 * Math.PI), 2)
+ Math.Pow(radiusP * Math.Sin(lat1 / 180 * Math.PI), 2);
double radius = Math.Sqrt(nr / dr);
//Calculate distance in meters.
distance = radius * c;
return distance; // distance in meters
}
您可以找到一个包含信息此处。
You can find a good site with infos here.
这篇关于计算bing贴图中两点之间的距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文