无关风月
2024-07-11 eb6b6dbb35a9f029e0b7d269773685c19fd40976
cloud-server-other/src/main/java/com/dsh/other/util/GeodesyUtil.java
@@ -16,11 +16,12 @@
    /**
     * 获取直线距离
     *
     * @param fromLonLat
     * @param toLonLat
     * @return
     */
    public static Map<String, Double> getDistance(String fromLonLat, String toLonLat){
    public static Map<String, Double> getDistance(String fromLonLat, String toLonLat) {
        String[] from = fromLonLat.split(",");
        String[] to = toLonLat.split(",");
        GlobalCoordinates source = new GlobalCoordinates(Double.valueOf(from[1]), Double.valueOf(from[0]));
@@ -54,7 +55,7 @@
    }
    private static double getDistanceMeter(GlobalCoordinates gpsFrom, GlobalCoordinates gpsTo, Ellipsoid ellipsoid){
    private static double getDistanceMeter(GlobalCoordinates gpsFrom, GlobalCoordinates gpsTo, Ellipsoid ellipsoid) {
        //创建GeodeticCalculator,调用计算方法,传入坐标系、经纬度用于计算距离
        GeodeticCurve geoCurve = new GeodeticCalculator().calculateGeodeticCurve(ellipsoid, gpsFrom, gpsTo);
        return geoCurve.getEllipsoidalDistance();