Package gov.nasa.worldwind.geom
Class Location
- java.lang.Object
-
- gov.nasa.worldwind.geom.Location
-
- Direct Known Subclasses:
Position
public class Location extends java.lang.Object
Geographic location with a latitude and longitude in degrees.
-
-
Constructor Summary
Constructors Constructor Description Location()
Constructs a location with latitude and longitude both 0.Location(double latitude, double longitude)
Constructs a location with a specified latitude and longitude in degrees.Location(Location location)
Constructs a location with the latitude and longitude of a specified location.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static double
clampLatitude(double degrees)
Restricts an angle to the range [-90, +90] degrees, clamping angles outside the range.static double
clampLongitude(double degrees)
Restricts an angle to the range [-180, +180] degrees, clamping angles outside the range.boolean
equals(java.lang.Object o)
static Location
fromDegrees(double latitudeDegrees, double longitudeDegrees)
Constructs a location with a specified latitude and longitude in degrees.static Location
fromRadians(double latitudeRadians, double longitudeRadians)
Constructs a location with a specified latitude and longitude in radians.static Location
fromTimeZone(java.util.TimeZone timeZone)
Constructs an approximate location for a specified time zone.double
greatCircleAzimuth(Location location)
Computes the azimuth angle (clockwise from North) for the great circle path between this location and a specified location.double
greatCircleDistance(Location location)
Computes the angular distance of the great circle path between this location and a specified location.Location
greatCircleLocation(double azimuthDegrees, double distanceRadians, Location result)
Computes the location on the great circle path starting at this location and traversing with the specified azimuth and angular distance.int
hashCode()
Location
interpolateAlongPath(Location endLocation, int pathType, double amount, Location result)
Compute a location along a path between two locations.double
linearAzimuth(Location location)
Computes the azimuth angle (clockwise from North) for the linear path between this location and a specified location.double
linearDistance(Location location)
Computes the angular distance of the linear path between this location and a specified location.Location
linearLocation(double azimuthDegrees, double distanceRadians, Location result)
Computes the location on the linear path starting at this location and traversing with the specified azimuth and angular distance.static boolean
locationsCrossAntimeridian(java.util.List<? extends Location> locations)
Determines whether a list of locations crosses the antimeridian.static double
normalizeLatitude(double degrees)
Restricts an angle to the range [-90, +90] degrees, wrapping angles outside the range.static double
normalizeLongitude(double degrees)
Restricts an angle to the range [-180, +180] degrees, wrapping angles outside the range.double
rhumbAzimuth(Location location)
Computes the azimuth angle (clockwise from North) for the rhumb path (line of constant azimuth) between this location and a specified location.double
rhumbDistance(Location location)
Computes the angular distance of the rhumb path (line of constant azimuth) between this location and a specified location.Location
rhumbLocation(double azimuthDegrees, double distanceRadians, Location result)
Computes the location on a rhumb path (line of constant azimuth) starting at this location and traversing with the specified azimuth and angular distance.Location
set(double latitude, double longitude)
Sets this location to a specified latitude and longitude in degrees.Location
set(Location location)
Sets this location to the latitude and longitude of a specified location.java.lang.String
toString()
-
-
-
Constructor Detail
-
Location
public Location()
Constructs a location with latitude and longitude both 0.
-
Location
public Location(double latitude, double longitude)
Constructs a location with a specified latitude and longitude in degrees.- Parameters:
latitude
- the latitude in degreeslongitude
- the longitude in degrees
-
Location
public Location(Location location)
Constructs a location with the latitude and longitude of a specified location.- Parameters:
location
- the location specifying the coordinates- Throws:
java.lang.IllegalArgumentException
- If the location is null
-
-
Method Detail
-
fromDegrees
public static Location fromDegrees(double latitudeDegrees, double longitudeDegrees)
Constructs a location with a specified latitude and longitude in degrees.- Parameters:
latitudeDegrees
- the latitude in degreeslongitudeDegrees
- the longitude in degrees- Returns:
- the new location
-
fromRadians
public static Location fromRadians(double latitudeRadians, double longitudeRadians)
Constructs a location with a specified latitude and longitude in radians.- Parameters:
latitudeRadians
- the latitude in radianslongitudeRadians
- the longitude in radians- Returns:
- the new location
-
fromTimeZone
public static Location fromTimeZone(java.util.TimeZone timeZone)
Constructs an approximate location for a specified time zone. Used when selecting an initial camera position based on the device's current time zone.- Parameters:
timeZone
- the time zone in question- Returns:
- the new location
-
normalizeLatitude
public static double normalizeLatitude(double degrees)
Restricts an angle to the range [-90, +90] degrees, wrapping angles outside the range. Wrapping takes place along a line of constant longitude which may pass through the poles. In which case, 135 degrees normalizes to 45 degrees; 181 degrees normalizes to -1 degree.- Parameters:
degrees
- the angle to wrap in degrees- Returns:
- the specified angle wrapped to the range [-90, +90] degrees
-
normalizeLongitude
public static double normalizeLongitude(double degrees)
Restricts an angle to the range [-180, +180] degrees, wrapping angles outside the range. Wrapping takes place as though traversing a line of constant latitude which may pass through the antimeridian; angles less than -180 wrap back to +180, while angles greater than +180 wrap back to -180.- Parameters:
degrees
- the angle to wrap in degrees- Returns:
- the specified angle wrapped to the range [-180, +180] degrees
-
clampLatitude
public static double clampLatitude(double degrees)
Restricts an angle to the range [-90, +90] degrees, clamping angles outside the range. Angles less than -90 are returned as -90, and angles greater than +90 are returned as +90. Angles within the range are returned unmodified.- Parameters:
degrees
- the angle to clamp in degrees- Returns:
- the specified angle clamped to the range [-90, +90] degrees
-
clampLongitude
public static double clampLongitude(double degrees)
Restricts an angle to the range [-180, +180] degrees, clamping angles outside the range. Angles less than -180 are returned as 0, and angles greater than +180 are returned as +180. Angles within the range are returned unmodified.- Parameters:
degrees
- the angle to clamp in degrees- Returns:
- the specified angle clamped to the range [-180, +180] degrees
-
locationsCrossAntimeridian
public static boolean locationsCrossAntimeridian(java.util.List<? extends Location> locations)
Determines whether a list of locations crosses the antimeridian.- Parameters:
locations
- the locations to test- Returns:
- true if the antimeridian is crossed, false otherwise
- Throws:
java.lang.IllegalArgumentException
- If the locations list is null
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
@NonNull public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
set
public Location set(double latitude, double longitude)
Sets this location to a specified latitude and longitude in degrees.- Parameters:
latitude
- the new latitude in degreeslongitude
- the new longitude in degrees- Returns:
- this location with its latitude and longitude set to the specified values
-
set
public Location set(Location location)
Sets this location to the latitude and longitude of a specified location.- Parameters:
location
- the location specifying the new coordinates- Returns:
- this location with its latitude and longitude set to that of the specified location
- Throws:
java.lang.IllegalArgumentException
- If the location is null
-
interpolateAlongPath
public Location interpolateAlongPath(Location endLocation, int pathType, double amount, Location result)
Compute a location along a path between two locations. The amount indicates the fraction of the path at which to compute a location. This value is typically between 0 and 1, where 0 indicates the begin location (this location) and 1 indicates the end location.- Parameters:
endLocation
- the path's end locationpathType
-WorldWind.PathType
indicating type of path to assumeamount
- the fraction of the path at which to compute a locationresult
- a pre-allocated Location in which to return the computed location- Returns:
- the result argument set to the computed location
- Throws:
java.lang.IllegalArgumentException
- If either of the end location or the result argument is null
-
greatCircleAzimuth
public double greatCircleAzimuth(Location location)
Computes the azimuth angle (clockwise from North) for the great circle path between this location and a specified location. This angle can be used as the starting azimuth for a great circle path beginning at this location, and passing through the specified location. This function uses a spherical model, not elliptical.- Parameters:
location
- the great circle path's ending location- Returns:
- the computed azimuth in degrees
- Throws:
java.lang.IllegalArgumentException
- If the location is null
-
greatCircleDistance
public double greatCircleDistance(Location location)
Computes the angular distance of the great circle path 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.- Parameters:
location
- the great circle path's ending location- Returns:
- the computed angular distance in radians
- Throws:
java.lang.IllegalArgumentException
- If the location is null
-
greatCircleLocation
public Location greatCircleLocation(double azimuthDegrees, double distanceRadians, Location result)
Computes the location on the great circle path starting at this location and traversing with the specified azimuth and angular distance. This function uses a spherical model, not elliptical.- Parameters:
azimuthDegrees
- the starting azimuth in degreesdistanceRadians
- the angular distance along the path in radiansresult
- a pre-allocated Location in which to return the computed location- Returns:
- the result argument set to the computed location
- Throws:
java.lang.IllegalArgumentException
- If either the location or the result is null
-
rhumbAzimuth
public double rhumbAzimuth(Location location)
Computes the azimuth angle (clockwise from North) for the rhumb path (line of constant azimuth) between this location and a specified location. This angle can be used as the starting azimuth for a rhumb path beginning at this location, and passing through the specified location. This function uses a spherical model, not elliptical.- Parameters:
location
- the rhumb path's ending location- Returns:
- the computed azimuth in degrees
- Throws:
java.lang.IllegalArgumentException
- If the location is null
-
rhumbDistance
public double rhumbDistance(Location location)
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.- Parameters:
location
- the great circle path's ending location- Returns:
- the computed angular distance in radians
- Throws:
java.lang.IllegalArgumentException
- If the location is null
-
rhumbLocation
public Location rhumbLocation(double azimuthDegrees, double distanceRadians, Location result)
Computes the location on a rhumb path (line of constant azimuth) starting at this location and traversing with the specified azimuth and angular distance. This function uses a spherical model, not elliptical.- Parameters:
azimuthDegrees
- the starting azimuth in degreesdistanceRadians
- the angular distance along the path in radiansresult
- a pre-allocated Location in which to return the computed location- Returns:
- the result argument set to the computed location
- Throws:
java.lang.IllegalArgumentException
- If either the location or the result is null
-
linearAzimuth
public double linearAzimuth(Location location)
Computes the azimuth angle (clockwise from North) for the linear path between this location and a specified location. This angle can be used as the starting azimuth for a linear path beginning at this location, and passing through the specified location. This function uses a flat-earth approximation proximal to this location.- Parameters:
location
- the linear path's ending location- Returns:
- the computed azimuth in degrees
- Throws:
java.lang.IllegalArgumentException
- If the location is null
-
linearDistance
public double linearDistance(Location location)
Computes the angular distance of the linear path 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 flat-earth approximation proximal to this location.- Parameters:
location
- the great circle path's ending location- Returns:
- the computed angular distance in radians
- Throws:
java.lang.IllegalArgumentException
- If the location is null
-
linearLocation
public Location linearLocation(double azimuthDegrees, double distanceRadians, Location result)
Computes the location on the linear path starting at this location and traversing with the specified azimuth and angular distance. This function uses a flat-earth approximation proximal to this location.- Parameters:
azimuthDegrees
- the starting azimuth in degreesdistanceRadians
- the angular distance along the path in radiansresult
- a pre-allocated Location in which to return the computed location- Returns:
- the result argument set to the computed location
- Throws:
java.lang.IllegalArgumentException
- If either the location or the result is null
-
-