Location { public double greatCircleAzimuth(Location location) { if (location == null) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "Location", "greatCircleAzimuth", "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; } if (lon1 == lon2) { return lat1 > lat2 ? 180 : 0; } double y = Math.cos(lat2) * Math.sin(lon2 - lon1); double x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1); double azimuthRadians = Math.atan2(y, x); return Double.isNaN(azimuthRadians) ? 0 : Math.toDegrees(azimuthRadians); } Location();  Location(double latitude, double longitude);  Location(Location location); static Location fromDegrees(double latitudeDegrees, double longitudeDegrees); static Location fromRadians(double latitudeRadians, double longitudeRadians); static Location fromTimeZone(TimeZone timeZone); static double normalizeLatitude(double degrees); static double normalizeLongitude(double degrees); static double clampLatitude(double degrees); static double clampLongitude(double degrees); static boolean locationsCrossAntimeridian(List<? extends Location> locations); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); Location set(double latitude, double longitude); Location set(Location location); Location interpolateAlongPath(Location endLocation, @WorldWind.PathType int pathType, double amount,
                                         Location result); double greatCircleAzimuth(Location location); double greatCircleDistance(Location location); Location greatCircleLocation(double azimuthDegrees, double distanceRadians, Location result); double rhumbAzimuth(Location location); double rhumbDistance(Location location); Location rhumbLocation(double azimuthDegrees, double distanceRadians, Location result); double linearAzimuth(Location location); double linearDistance(Location location); Location linearLocation(double azimuthDegrees, double distanceRadians, Location result); public double latitude; public double longitude; }
@Test public void testGreatCircleAzimuth_East() throws Exception { Location origin = new Location(); Location east = new Location(0, 180); double azimuth = origin.greatCircleAzimuth(east); assertEquals("east to dateline", 90, azimuth, TOLERANCE); }
@Ignore("NaN behavior TBD") @Test public void testGreatCircleAzimuth_WithNaN() throws Exception { Location origin = new Location(THETA, PHI); Location nanLat = new Location(Double.NaN, PHI); Location nanBoth = new Location(Double.NaN, Double.NaN); assertTrue("expecting NaN with equal longitudes", Double.isNaN(origin.greatCircleAzimuth(nanLat))); assertTrue("expecting NaN", Double.isNaN(origin.greatCircleAzimuth(nanBoth))); }
@Test(expected = IllegalArgumentException.class) public void testGreatCircleAzimuth_WithNull() throws Exception { PowerMockito.mockStatic(Logger.class); Location begin = new Location(34.2, -119.2); begin.greatCircleAzimuth(null); fail("Expected an IllegalArgumentException to be thrown."); }