puzhibing
2024-02-05 640ff18d2d7f4be02ddb7f8f75e899f05545eb98
cloud-server-course/src/main/java/com/dsh/course/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();