zoukankan      html  css  js  c++  java
  • JAVA 根据经纬度算出附近的正方形的四个角的经纬度

      /**
         * 
         * @param longitude    经度
         * @param latitude    纬度
         * @param distance    范围(米)
         * @return
         */
        public static Map<String, double[]> returnLLSquarePoint(double longitude,  double latitude, double distance) {
            Map<String, double[]> squareMap = new HashMap<String, double[]>();
            // 计算经度弧度,从弧度转换为角度
            double dLongitude = 2 * (Math.asin(Math.sin(distance
                    / (2 * 6378137))
                    / Math.cos(Math.toRadians(latitude))));
            dLongitude = Math.toDegrees(dLongitude);
            // 计算纬度角度
            double dLatitude = distance / 6378137;
            dLatitude = Math.toDegrees(dLatitude);
            // 正方形
            double[] leftTopPoint = { latitude + dLatitude, longitude - dLongitude };
            double[] rightTopPoint = { latitude + dLatitude, longitude + dLongitude };
            double[] leftBottomPoint = { latitude - dLatitude,
                    longitude - dLongitude };
            double[] rightBottomPoint = { latitude - dLatitude,
                    longitude + dLongitude };
            squareMap.put("leftTopPoint", leftTopPoint);
            squareMap.put("rightTopPoint", rightTopPoint);
            squareMap.put("leftBottomPoint", leftBottomPoint);
            squareMap.put("rightBottomPoint", rightBottomPoint);
            System.out.println("leftTop:"+leftTopPoint[0]+"======"+leftTopPoint[1]);
            System.out.println("rightTop:"+rightTopPoint[0]+"======"+rightTopPoint[1]);
            System.out.println("leftBottom:"+leftBottomPoint[0]+"======"+leftBottomPoint[1]);
            System.out.println("rightBottom:"+rightBottomPoint[0]+"======"+rightBottomPoint[1]);
            return squareMap;
        }
  • 相关阅读:
    【go语言学习】标准库之time
    【go语言学习】文件操作file
    【go语言学习】反射reflect
    【go语言学习】通道channel
    soap添加
    ubuntu apache 启用gzip
    git 版本回退
    ubuntu打开crontab日志及不执行常见原因
    Ionic3 怎么打开第三方 app,最简单粗暴的方法
    Windows安装使用Openssl创建pks p12证书
  • 原文地址:https://www.cnblogs.com/chen-lhx/p/5800187.html
Copyright © 2011-2022 走看看