纬度相同,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(); }