Location { public static double normalizeLatitude(double degrees) { double lat = degrees % 180; double normalizedLat = lat > 90 ? 180 - lat : (lat < -90 ? -180 - lat : lat); int numEquatorCrosses = (int) (degrees / 180); return (numEquatorCrosses % 2 == 0) ? normalizedLat : -normalizedLat; } 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 testNormalizeLatitude() throws Exception { assertEquals("zero", 0.0, Location.normalizeLatitude(0.0), 0); assertEquals("1", 1.0, Location.normalizeLatitude(1.0), 0); assertEquals("89", 89.0, Location.normalizeLatitude(89.0), 0); assertEquals("90", 90.0, Location.normalizeLatitude(90.0), 0); assertEquals("91", 89.0, Location.normalizeLatitude(91.0), 0); assertEquals("179", 1.0, Location.normalizeLatitude(179.0), 0); assertEquals("180", 0.0, Location.normalizeLatitude(180.0), 0); assertEquals("181", -1.0, Location.normalizeLatitude(181.0), 0); assertEquals("269", -89.0, Location.normalizeLatitude(269.0), 0); assertEquals("270", -90.0, Location.normalizeLatitude(270.0), 0); assertEquals("271", -89.0, Location.normalizeLatitude(271.0), 0); assertEquals("359", -1.0, Location.normalizeLatitude(359.0), 0); assertEquals("360", 0.0, Location.normalizeLatitude(360.0), 0); assertEquals("361", 1.0, Location.normalizeLatitude(361.0), 0); assertEquals("721", 1.0, Location.normalizeLatitude(721.0), 0); assertEquals("-1", -1.0, Location.normalizeLatitude(-1.0), 0); assertEquals("-89", -89.0, Location.normalizeLatitude(-89.0), 0); assertEquals("-90", -90.0, Location.normalizeLatitude(-90.0), 0); assertEquals("-91", -89.0, Location.normalizeLatitude(-91.0), 0); assertEquals("-179", -1.0, Location.normalizeLatitude(-179.0), 0); assertEquals("-180", 0.0, Location.normalizeLatitude(-180.0), 0); assertEquals("-181", 1.0, Location.normalizeLatitude(-181.0), 0); assertEquals("-269", 89.0, Location.normalizeLatitude(-269.0), 0); assertEquals("-270", 90.0, Location.normalizeLatitude(-270.0), 0); assertEquals("-271", 89.0, Location.normalizeLatitude(-271.0), 0); assertEquals("-359", 1.0, Location.normalizeLatitude(-359.0), 0); assertEquals("-360", 0.0, Location.normalizeLatitude(-360.0), 0); assertEquals("-361", -1.0, Location.normalizeLatitude(-361.0), 0); assertEquals("-719", 1.0, Location.normalizeLatitude(-719.0), 0); assertEquals("-721", -1.0, Location.normalizeLatitude(-721.0), 0); assertTrue("NaN", Double.isNaN(Location.normalizeLatitude(Double.NaN))); }