/** * Compute distance point and other location given by its latitude and longitude in decimal degrees * * @param latitude in decimal degrees * @param longitude in decimal degrees * @return the distance between the points * @see <a href="http://www.movable-type.co.uk/scripts/latlong.html">Distance haversine formula</a> */ public double getDistanceTo(final double latitude,final double longitude) { double destinationLatitudeRadians = normalizeLatitude( latitude ) * GeometricConstants.TO_RADIANS_RATIO; double destinationLongitudeRadians = normalizeLongitude( longitude ) * GeometricConstants.TO_RADIANS_RATIO; final double dLat = ( destinationLatitudeRadians - getLatitudeRad() ) / 2.0d; final double dLon = ( destinationLongitudeRadians - getLongitudeRad() ) / 2.0d; final double a = Math.pow( Math.sin( dLat ), 2 ) + Math.pow( Math.sin( dLon ), 2 ) * Math.cos( getLatitudeRad() ) * Math.cos( destinationLatitudeRadians ); final double c = 2.0d * Math.atan2( Math.sqrt( a ), Math.sqrt( 1.0d - a ) ); return c * GeometricConstants.EARTH_MEAN_RADIUS_KM; }
/** * @param latitude in degrees * @param longitude in degrees * @return a point with coordinates given in degrees */ public static Point fromDegreesInclusive(double latitude, double longitude) { return new Point( normalizeLatitude( latitude ), normalizeLongitudeInclusive( longitude ) ); }
/** * @param latitude in degrees * @param longitude in degrees * @return a point with coordinates given in degrees */ public static Point fromDegrees(double latitude, double longitude) { return new Point( normalizeLatitude( latitude ), normalizeLongitude( longitude ) ); }
/** * @param latitude in degrees * @param longitude in degrees * @return a point with coordinates given in degrees */ public static Point fromDegreesInclusive(double latitude, double longitude) { return new Point( normalizeLatitude( latitude ), normalizeLongitudeInclusive( longitude ) ); }
/** * @param latitude in degrees * @param longitude in degrees * @return a point with coordinates given in degrees */ public static Point fromDegrees(double latitude, double longitude) { return new Point( normalizeLatitude( latitude ), normalizeLongitude( longitude ) ); }
/** * Compute distance point and other location given by its latitude and longitude in decimal degrees * * @param latitude in decimal degrees * @param longitude in decimal degrees * @return the distance between the points * @see <a href="http://www.movable-type.co.uk/scripts/latlong.html">Distance haversine formula</a> */ public double getDistanceTo(final double latitude,final double longitude) { double destinationLatitudeRadians = normalizeLatitude( latitude ) * GeometricConstants.TO_RADIANS_RATIO; double destinationLongitudeRadians = normalizeLongitude( longitude ) * GeometricConstants.TO_RADIANS_RATIO; final double dLat = ( destinationLatitudeRadians - getLatitudeRad() ) / 2.0d; final double dLon = ( destinationLongitudeRadians - getLongitudeRad() ) / 2.0d; final double a = Math.pow( Math.sin( dLat ), 2 ) + Math.pow( Math.sin( dLon ), 2 ) * Math.cos( getLatitudeRad() ) * Math.cos( destinationLatitudeRadians ); final double c = 2.0d * Math.atan2( Math.sqrt( a ), Math.sqrt( 1.0d - a ) ); return c * GeometricConstants.EARTH_MEAN_RADIUS_KM; }