zoukankan      html  css  js  c++  java
  • java 实现经纬度计算

    学习记录

    1、maven 依赖

    <dependency>
        <groupId>org.gavaghan</groupId>
        <artifactId>geodesy</artifactId>
        <version>1.1.3</version>
    </dependency>
    
    

    2、生产点坐标

    GlobalCoordinates center = new GlobalCoordinates(38.885791,121.858205);

    3、根据两点算距离

        /**
         * 根据坐标算距离
         * @param startLng
         * @param startLat
         * @param endLng
         * @param endLat
         * @return
         */
        public static double getDistanceMeter(double startLng,double startLat,double endLng,double endLat){
            GlobalCoordinates startGlobalCoordinates = new GlobalCoordinates(startLat, startLng);
            GlobalCoordinates endGlobalCoordinates = new GlobalCoordinates(endLat, endLng);
            GeodeticCurve geoCurve = new GeodeticCalculator().calculateGeodeticCurve(Ellipsoid.WGS84, startGlobalCoordinates, endGlobalCoordinates);
            return geoCurve.getEllipsoidalDistance();
        }

    4、根据开始点、方向、距离计算结束点

        /**
         * 根据开始坐标点,角度,计算结束点坐标
         * @param startGlobalCoordinates
         * @param startAngle
         * @param distance
         * @return
         */
        public static GlobalCoordinates getGlobalCoordinates(GlobalCoordinates startGlobalCoordinates, double startAngle, double distance){
            return new GeodeticCalculator().calculateEndingGlobalCoordinates(Ellipsoid.WGS84, startGlobalCoordinates, startAngle, distance);
        }

    学习备忘,好记性的烂笔头!!!

    
    
  • 相关阅读:
    ABAP语法篇1 DATA新用法
    SAP RFC和BAPI
    SAP标准屏幕中字段描述增强
    HoloLens开发手记 - 使用Windows设备控制台 Using Windows Device Portal
    HoloLens开发手记
    HoloLens开发手记
    HoloLens开发手记
    HoloLens开发手记
    HoloLens开发手记
    HoloLens开发手记
  • 原文地址:https://www.cnblogs.com/spqin/p/13363836.html
Copyright © 2011-2022 走看看