微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

c#-4.0 – 计算bing贴图中两点之间的距离

我有一张bing地图,还有两点:
Point1,Point2和我想计算这两点之间的距离?那可能吗?
如果我想在point1和point2之间以及point2附近的路径的三分之一处放一个圆圈……我怎么能做到?

解决方法

Haversine甚至更好的 Vincenty公式如何解决这个问题.

以下代码使用hasrsines方法获取距离:

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
    }

你可以找到一个信息here的好网站.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐