SphericalGeometryLibrary { public static double getOrientation(double latFrom, double lonFrom, double latTo, double lonTo) { double d = distance(latFrom, lonFrom, latTo, lonTo); CoordinateBounds bounds = bounds(latFrom, lonFrom, d); XYPoint origin = new XYPoint(lonFrom, latFrom); XYPoint axis = new XYPoint(bounds.getMaxLon(), latFrom); XYPoint target = new XYPoint(lonTo, latTo); double angle = GeometryLibrary.getAngle(origin, axis, target); if (latTo < latFrom) angle = 2 * Math.PI - angle; return Math.toDegrees(angle); }  static double distanceFaster(double lat1, double lon1, double lat2,
      double lon2); static final double distance(double lat1, double lon1, double lat2,
      double lon2); static final double distance(CoordinatePoint a, CoordinatePoint b); static final double distance(double lat1, double lon1, double lat2,
      double lon2, double radius); static final CoordinateBounds bounds(CoordinatePoint point,
      double distance); static CoordinateBounds bounds(CoordinateBounds b, double distance); static final CoordinateBounds bounds(double lat, double lon,
      double distance); static final CoordinateBounds bounds(double lat, double lon,
      double latDistance, double lonDistance); static final CoordinateBounds boundsFromLatLonOffset(double lat,
      double lon, double latOffset, double lonOffset); static final CoordinateBounds boundsFromLatLonSpan(double lat,
      double lon, double latSpan, double lonSpan); static CoordinatePoint getCenterOfBounds(CoordinateBounds b); static double getOrientation(double latFrom, double lonFrom,
      double latTo, double lonTo); static CoordinatePoint projectPointToSegmentAppropximate(
      CoordinatePoint point, CoordinatePoint segmentStart,
      CoordinatePoint segmentEnd); static final double RADIUS_OF_EARTH_IN_KM; static final double COS_MAX_LAT; static final double METERS_PER_DEGREE_AT_EQUATOR; }
@Test public void testGetOrientation() { double lat0 = 47.6538286680302; double lon0 = -122.30780805044554; double orientation = SphericalGeometryLibrary.getOrientation(lat0, lon0, 47.65385757615516, -122.30632747106932); assertEquals(1.1, orientation, 0.1); orientation = SphericalGeometryLibrary.getOrientation(lat0, lon0, 47.65415388351328, -122.3063596575775); assertEquals(12.6, orientation, 0.1); orientation = SphericalGeometryLibrary.getOrientation(lat0, lon0, 47.65441405444146, -122.30704630308531); assertEquals(37.5, orientation, 0.1); orientation = SphericalGeometryLibrary.getOrientation(lat0, lon0, 47.65435623879166, -122.30780805044554); assertEquals(90.0, orientation, 0.1); orientation = SphericalGeometryLibrary.getOrientation(lat0, lon0, 47.65405270558003, -122.30883265428923); assertEquals(167.6, orientation, 0.1); orientation = SphericalGeometryLibrary.getOrientation(lat0, lon0, 47.653510677599435, -122.30930472307585); assertEquals(192.0, orientation, 0.1); orientation = SphericalGeometryLibrary.getOrientation(lat0, lon0, 47.65312041396976, -122.30780805044554); assertEquals(270.0, orientation, 0.1); }