zoukankan      html  css  js  c++  java
  • 计算两点经纬度之间的距离

          /// <summary>
          /// distance (in km) between two points specified by latitude/longitude
          /// The Haversine formula, http://www.movable-type.co.uk/scripts/latlong.html
          /// </summary>
          /// <param name="p1"></param>
          /// <param name="p2"></param>
          /// <returns></returns>
          public double GetDistance(PointLatLng p1, PointLatLng p2)
          {
             double dLat1InRad = p1.Lat * (Math.PI / 180);
             double dLong1InRad = p1.Lng * (Math.PI / 180);
             double dLat2InRad = p2.Lat * (Math.PI / 180);
             double dLong2InRad = p2.Lng * (Math.PI / 180);
             double dLongitude = dLong2InRad - dLong1InRad;
             double dLatitude = dLat2InRad - dLat1InRad;
             double a = Math.Pow(Math.Sin(dLatitude / 2), 2) + Math.Cos(dLat1InRad) * Math.Cos(dLat2InRad) * Math.Pow(Math.Sin(dLongitude / 2), 2);
             double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
             double dDistance = (Axis / 1000.0) * c;
             return dDistance;
          }

    http://www.movable-type.co.uk/scripts/latlong.html 有详细的说明
  • 相关阅读:
    关于SuperSocket启动失败
    ffmpeg 常用命令
    Url中有中文参数需要编码解码
    单例模式
    c# 文件夹重命名
    一个既有winform又有webapi 的例子
    数据库查询字段的结构和长度
    Jquery 展开收起
    ajax即时修改
    EFCore 迁移
  • 原文地址:https://www.cnblogs.com/cglNet/p/3141734.html
Copyright © 2011-2022 走看看