Location { public Location interpolateAlongPath(Location endLocation, @WorldWind.PathType int pathType, double amount, Location result) { if (endLocation == null) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "Location", "interpolateAlongPath", "missingLocation")); } if (result == null) { throw new IllegalArgumentException( Logger.logMessage(Logger.ERROR, "Location", "interpolateAlongPath", "missingResult")); } if (this.equals(endLocation)) { result.latitude = this.latitude; result.longitude = this.longitude; return this; } if (pathType == WorldWind.GREAT_CIRCLE) { double azimuthDegrees = this.greatCircleAzimuth(endLocation); double distanceRadians = this.greatCircleDistance(endLocation) * amount; return this.greatCircleLocation(azimuthDegrees, distanceRadians, result); } else if (pathType == WorldWind.RHUMB_LINE) { double azimuthDegrees = this.rhumbAzimuth(endLocation); double distanceRadians = this.rhumbDistance(endLocation) * amount; return this.rhumbLocation(azimuthDegrees, distanceRadians, result); } else { double azimuthDegrees = this.linearAzimuth(endLocation); double distanceRadians = this.linearDistance(endLocation) * amount; return this.linearLocation(azimuthDegrees, distanceRadians, result); } } 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 testInterpolateAlongPath() throws Exception { Location lax = Location.fromRadians(0.592539, -2.066470); Location jfk = Location.fromRadians(0.709185, -1.287762); double distanceToJfk = lax.greatCircleDistance(jfk); double azimuthToJfk = lax.greatCircleAzimuth(jfk); double amount = 0.25; Location result = lax.interpolateAlongPath(jfk, WorldWind.GREAT_CIRCLE, amount, new Location()); double distanceToResult = lax.greatCircleDistance(result); Location test = lax.greatCircleLocation(azimuthToJfk, distanceToResult, new Location()); assertEquals("interpolated distance", distanceToJfk * amount, distanceToResult, TOLERANCE); assertEquals("latitude", test.latitude, result.latitude, 0); assertEquals("longitude", test.longitude, result.longitude, 0); }
@Test(expected = IllegalArgumentException.class) public void testInterpolateAlongPath_NullEnd() throws Exception { Location location = new Location(); location.interpolateAlongPath(null, WorldWind.GREAT_CIRCLE, 0.25, new Location()); fail("Expected a InvalidArgumentException."); }
@Test(expected = IllegalArgumentException.class) public void testInterpolateAlongPath_NullResult() throws Exception { Location location = new Location(); location.interpolateAlongPath(location, WorldWind.GREAT_CIRCLE, 0.25, null); fail("Expected a InvalidArgumentException."); }