纬度相同,1经度距离

    /**
     * 纬度相同,1经度距离
     * @param latitude
     * @param longitude
     * @return
     */
    public static double oneLongitudeDistance(double latitude, double longitude){
        LatLonReq latLonReq = new LatLonReq(latitude, longitude);
        double longitudeEnd = longitude + 1.0;
        return getDistance(latLonReq, new LatLonReq(latitude, longitudeEnd));
    }
    /**
     * 计算两点距离
     * @param latLonReq1
     * @param latLonReq2
     * @return
     */
    public static double getDistance(LatLonReq latLonReq1, LatLonReq latLonReq2) {
        GlobalCoordinates source = new GlobalCoordinates(latLonReq1.getLatitude(), latLonReq1.getLongitude());
        GlobalCoordinates target = new GlobalCoordinates(latLonReq2.getLatitude(), latLonReq2.getLongitude());
        return new GeodeticCalculator().calculateGeodeticCurve(Ellipsoid.Sphere, source, target).getEllipsoidalDistance();
    }

 

posted on 2021-11-25 11:41  我是你爷爷的爷爷  阅读(57)  评论(0编辑  收藏  举报

导航