• Java根据经纬度算出附近正方形的四个角的经纬度


    项目开发中csv文件转化为geojson文件中,涉及到路测图的打点生成,打点是由一个个正方形组成,而正方形是由四个点组成的,这四个点根据经纬度和范围生成,实现代码参考网上:

    /**
         * 
         * @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;
        }
    

    参考:JAVA 根据经纬度算出附近的正方形的四个角的经纬度

  • 相关阅读:
    针对C#、VB.NET、VB6的WINDOWS API引用
    VBNET的一些特殊能力
    [模块]可以搜索内存中存在的PE结构
    将Excel和XML导入数据库
    VB.NET中使用List
    VBNET使用EXCEL常见操作
    Linux下的C编程实战之开辟平台搭建
    若何进步Linux桌面零碎的速度4
    Linux把持体系中若何布置Tomcat
    如何进步Linux桌面系统的速率1
  • 原文地址:https://www.cnblogs.com/liaoguanwang/p/10575490.html
Copyright © 2020-2023  润新知