zoukankan      html  css  js  c++  java
  • 空间距离计算

    /**
       *
       * @param lat1     The y coordinate of the first point, in radians
       * @param lon1     The x coordinate of the first point, in radians
       * @param lat2     The y coordinate of the second point, in radians
       * @param lon2     The x coordinate of the second point, in radians
       * @return The distance between the two points, as determined by the Haversine formula, in radians.
       */
      public static double distHaversineRAD(double lat1, double lon1, double lat2, double lon2) {
        //TODO investigate slightly different formula using asin() and min() http://www.movable-type.co.uk/scripts/gis-faq-5.1.html
     
        // Check for same position
        if (lat1 == lat2 && lon1 == lon2)
          return 0.0;
        double hsinX = Math.sin((lon1 - lon2) * 0.5);
        double hsinY = Math.sin((lat1 - lat2) * 0.5);
        double h = hsinY * hsinY +
                (Math.cos(lat1) * Math.cos(lat2) * hsinX * hsinX);
        return 2 * Math.atan2(Math.sqrt(h), Math.sqrt(1 - h));
      }
    

      

  • 相关阅读:
    语言基础
    进制转换
    添加
    查找
    继承
    封装
    面向基础 c#小复习
    主外键
    三个表的关系
    插入信息,模糊查询,聚合函数,时间函数,排序,字符串函数,数学函数,求个数,球最大
  • 原文地址:https://www.cnblogs.com/echojson/p/11353087.html
Copyright © 2011-2022 走看看