public double rhumbDistance(Location location){
  if (location == null) {
    throw new IllegalArgumentException(Logger.logMessage(Logger.ERROR,"Location","rhumbDistance","missingLocation"));
  }
  double lat1=Math.toRadians(this.latitude);
  double lon1=Math.toRadians(this.longitude);
  double lat2=Math.toRadians(location.latitude);
  double lon2=Math.toRadians(location.longitude);
  if (lat1 == lat2 && lon1 == lon2) {
    return 0;
  }
  double dLat=lat2 - lat1;
  double dLon=lon2 - lon1;
  double q;
  if (Math.abs(dLat) < NEAR_ZERO_THRESHOLD) {
    q=Math.cos(lat1);
  }
 else {
    double dPhi=Math.log(Math.tan(lat2 / 2.0 + Math.PI / 4) / Math.tan(lat1 / 2.0 + Math.PI / 4));
    q=dLat / dPhi;
  }
  if (Math.abs(dLon) > Math.PI) {
    dLon=dLon > 0 ? -(2 * Math.PI - dLon) : (2 * Math.PI + dLon);
  }
  double distanceRadians=Math.sqrt(dLat * dLat + q * q * dLon* dLon);
  return Double.isNaN(distanceRadians) ? 0 : distanceRadians;
}

public double rhumbDistance ( Location location ) { if ( location == null ) { throw new IllegalArgumentException ( Logger . logMessage ( Logger . ERROR , "Location" , "rhumbDistance" , "missingLocation" ) ) ; } double lat1 = Math . toRadians ( this . latitude ) ; double lon1 = Math . toRadians ( this . longitude ) ; double lat2 = Math . toRadians ( location . latitude ) ; double lon2 = Math . toRadians ( location . longitude ) ; if ( lat1 == lat2 && lon1 == lon2 ) { return 0 ; } double dLat = lat2 - lat1 ; double dLon = lon2 - lon1 ; double q ; if ( Math . abs ( dLat ) < NEAR_ZERO_THRESHOLD ) { q = Math . cos ( lat1 ) ; } else { double dPhi = Math . log ( Math . tan ( lat2 / 2.0 + Math . PI / 4 ) / Math . tan ( lat1 / 2.0 + Math . PI / 4 ) ) ; q = dLat / dPhi ; } if ( Math . abs ( dLon ) > Math . PI ) { dLon = dLon > 0 ? - ( 2 * Math . PI - dLon ) : ( 2 * Math . PI + dLon ) ; } double distanceRadians = Math . sqrt ( dLat * dLat + q * q * dLon * dLon ) ; return Double . isNaN ( distanceRadians ) ? 0 : distanceRadians ; }
computes the angular distance of the rhumb path ( line of constant azimuth ) between this location and a specified location . in radians , this angle is the arc length of the segment between the two locations . to compute a distance in meters from this value , multiply the return value by the radius of the globe . this function uses a spherical model , not elliptical .
