小编dmd*_*733的帖子

C#查找两个纬度/经度的中点

我需要找到两个纬度/经度点之间的中点.

我试图将我绘制的两个位置之间的地图居中,并且需要找到该点.

我已经从我找到的其他示例中编写了这个函数,但似乎没有用.

    public static void midPoint(double lat1, double lon1, double lat2, double lon2, out double lat3_OUT, out double lon3_OUT)
    {
        //http:// stackoverflow.com/questions/4656802/midpoint-between-two-latitude-and-longitude
        double dLon = DistanceAlgorithm.Radians(lon2 - lon1);

        //convert to radians
        lat1 = DistanceAlgorithm.Radians(lat1);
        lat2 = DistanceAlgorithm.Radians(lat2);
        lon1 = DistanceAlgorithm.Radians(lon1);

        double Bx = Math.Cos(lat2) * Math.Cos(dLon);
        double By = Math.Cos(lat2) * Math.Sin(dLon);
        double lat3 = Math.Atan2(Math.Sin(lat1) + Math.Sin(lat2), Math.Sqrt((Math.Cos(lat1) + Bx) * (Math.Cos(lat1) + Bx) + By * By));
        double lon3 = lon1 + Math.Atan2(By, Math.Cos(lat1) + Bx);

        lat3_OUT …
Run Code Online (Sandbox Code Playgroud)

c# geolocation latitude-longitude

7
推荐指数
1
解决办法
2501
查看次数

标签 统计

c# ×1

geolocation ×1

latitude-longitude ×1