/**=========================================================================
* CLASS CONSTANTS
*
* Constants used throughout this program and their comments.
*========================================================================*/
public static final double RADIUS = 3956.6;
/**=========================================================================
* CLASS METHODS
*
* Program methods are listed below in alphabetical order or the order in
* which they are used in main below.
*========================================================================*/
/**
* Returns spherical distance in miles between two points
* @param lat1 - Latitude of first point
* @param long1 - Longitude of first point
* @param lat2 - Latitude of second point
* @param long2 - longitude of second point
* @return
*/
public static double calculateDistance(double lat1, double long1,
double lat2, double long2) {
lat1 = Math.toRadians(lat1);
long1 = Math.toRadians(long1);
lat2 = Math.toRadians(lat2);
long2 = Math.toRadians(long2);
double theCos = Math.sin(lat1) * Math.sin(lat2) +
Math.cos(lat1) * Math.cos(lat2) *
Math.cos(long1 - long2);
double arcLength = Math.acos(theCos);
return arcLength * RADIUS;
}