Class LatLon
- java.lang.Object
-
- gov.nasa.worldwind.geom.LatLon
-
- Direct Known Subclasses:
Position
,SurfacePolygon.Vertex
public class LatLon extends java.lang.Object
Represents a point on the two-dimensional surface of a globe. Latitude is the degrees North and ranges between [-90, 90], while longitude refers to degrees East, and ranges between (-180, 180].Instances of
LatLon
are immutable.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LatLon
add(LatLon that)
LatLon
add(Position that)
double[]
asDegreesArray()
Returns an array of this object's latitude and longitude in degrees.double[]
asRadiansArray()
Returns an array of this object's latitude and longitude in radians.static java.util.List<LatLon>
computeShiftedLocations(Position oldLocation, Position newLocation, java.lang.Iterable<? extends LatLon> locations)
Computes a new set of locations translated from a specified location to a new location.static java.util.List<LatLon>
computeShiftedLocations(Globe globe, LatLon oldLocation, LatLon newLocation, java.lang.Iterable<? extends LatLon> locations)
static java.util.List<LatLon>
cutLocationsAlongDateLine(java.lang.Iterable<? extends LatLon> locations, java.lang.String pole, Globe globe)
Divides a sequence of geographic locations that encloses a pole along the international dateline.static double
ellipsoidalDistance(LatLon p1, LatLon p2, double equatorialRadius, double polarRadius)
Computes the distance between two points on an ellipsoid iteratively.static Angle
ellipsoidalForwardAzimuth(LatLon p1, LatLon p2, double equatorialRadius, double polarRadius)
Compute the forward azimuth between two positionsstatic boolean
equals(LatLon a, LatLon b)
boolean
equals(java.lang.Object o)
static LatLon
fromDegrees(double latitude, double longitude)
Factory method for obtaining a newLatLon
from two angles expressed in degrees.static LatLon
fromRadians(double latitude, double longitude)
Factor method for obtaining a newLatLon
from two angles expressed in radians.static Angle
getAverageDistance(Globe globe, LatLon center, java.lang.Iterable<? extends LatLon> locations)
Computes the average distance between a specified center point and a list of locations.static Angle
getAverageDistance(java.lang.Iterable<? extends LatLon> locations)
Compute the average rhumb distance between locations.static LatLon
getCenter(Globe globe, java.lang.Iterable<? extends LatLon> locations)
Computes the average location of a specified list of locations.static LatLon
getCenter(java.lang.Iterable<? extends LatLon> locations)
Computes the average location of a specified list of locations.Angle
getLatitude()
Obtains the latitude of thisLatLon
.Angle
getLongitude()
Obtains the longitude of thisLatLon
.static LatLon[]
greatCircleArcExtremeLocations(LatLon begin, LatLon end)
Returns two locations with the most extreme latitudes on the great circle arc defined by, and limited to, the two locations.static LatLon[]
greatCircleArcExtremeLocations(java.lang.Iterable<? extends LatLon> locations)
Returns two locations with the most extreme latitudes on the sequence of great circle arcs defined by each pair of locations in the specified iterable.static Angle
greatCircleAzimuth(LatLon p1, LatLon p2)
Computes the azimuth angle (clockwise from North) that points from the first location to the second location.static Angle
greatCircleDistance(LatLon p1, LatLon p2)
Computes the great circle angular distance between two locations.static LatLon
greatCircleEndPosition(LatLon p, double greatCircleAzimuthRadians, double pathLengthRadians)
Computes the location on a great circle arc with the given starting location, azimuth, and arc distance.static LatLon
greatCircleEndPosition(LatLon p, Angle greatCircleAzimuth, Angle pathLength)
Computes the location on a great circle arc with the given starting location, azimuth, and arc distance.static LatLon[]
greatCircleExtremeLocations(LatLon location, Angle azimuth)
Returns two locations with the most extreme latitudes on the great circle with the given starting location and azimuth.int
hashCode()
static LatLon
interpolate(double amount, LatLon value1, LatLon value2)
Returns the linear interpolation ofvalue1
andvalue2
, treating the geographic locations as simple 2D coordinate pairs.static LatLon
interpolate(java.lang.String pathType, double amount, LatLon value1, LatLon value2)
Returns an interpolated location betweenvalue1
andvalue2
, according to the specified path type.static LatLon
interpolateGreatCircle(double amount, LatLon value1, LatLon value2)
Returns the an interpolated location along the great-arc betweenvalue1
andvalue2
.static LatLon
interpolateRhumb(double amount, LatLon value1, LatLon value2)
Returns the an interpolated location along the rhumb line betweenvalue1
andvalue2
.static LatLon
intersectionWithMeridian(LatLon p1, LatLon p2, Angle meridian)
Determine where a line between two locations crosses a given meridian.static LatLon
intersectionWithMeridian(LatLon p1, LatLon p2, Angle meridian, Globe globe)
Determine where a line between two locations crosses a given meridian.static Angle
linearAzimuth(LatLon p1, LatLon p2)
Computes the azimuth angle (clockwise from North) of a linear path two locations.static Angle
linearDistance(LatLon p1, LatLon p2)
Computes the length of the linear path between two locations.static LatLon
linearEndPosition(LatLon p, Angle linearAzimuth, Angle pathLength)
Computes the location on a linear path given a starting location, azimuth, and arc distance along the line.static java.lang.String
locationsContainPole(java.lang.Iterable<? extends LatLon> locations)
Determines if a sequence of geographic locations encloses either the North or South pole.static boolean
locationsCrossDateline(LatLon p1, LatLon p2)
static boolean
locationsCrossDateLine(java.lang.Iterable<? extends LatLon> locations)
static java.util.List<LatLon>
makeDatelineCrossingLocationsPositive(java.lang.Iterable<? extends LatLon> locations)
Transform the negative longitudes of a dateline-spanning location list to positive values that maintain the relationship with the other locations in the list.LatLon
parseLatLon(java.lang.String latLonString)
Parses a string containing latitude and longitude coordinates in either Degrees-minutes-seconds or decimal degrees.static Angle
pathDistance(java.lang.String pathType, LatLon value1, LatLon value2)
Returns the length of the path betweenvalue1
andvalue2
, according to the specified path type.static java.util.List<java.util.List<LatLon>>
repeatLocationsAroundDateline(java.lang.Iterable<? extends LatLon> locations)
Returns a list containing two copies of a sequence of geographic locations that cross the dateline: one that extends across the -180 longitude boundary and one that extends across the +180 longitude boundary.static Angle
rhumbAzimuth(LatLon p1, LatLon p2)
Computes the azimuth angle (clockwise from North) of a rhumb line (a line of constant heading) between two locations.static Angle
rhumbDistance(LatLon p1, LatLon p2)
Computes the length of the rhumb line between two locations.static LatLon
rhumbEndPosition(LatLon p, double rhumbAzimuthRadians, double pathLengthRadians)
Computes the location on a rhumb line with the given starting location, rhumb azimuth, and arc distance along the line.static LatLon
rhumbEndPosition(LatLon p, Angle rhumbAzimuth, Angle pathLength)
Computes the location on a rhumb line with the given starting location, rhumb azimuth, and arc distance along the line.LatLon
subtract(LatLon that)
LatLon
subtract(Position that)
java.lang.String
toString()
-
-
-
Field Detail
-
ZERO
public static final LatLon ZERO
-
NEAR_ZERO_THRESHOLD
protected static final double NEAR_ZERO_THRESHOLD
A near zero threshold used in some of the rhumb line calculations where floating point calculations cause errors.- See Also:
- Constant Field Values
-
latitude
public final Angle latitude
-
longitude
public final Angle longitude
-
-
Constructor Detail
-
LatLon
public LatLon(Angle latitude, Angle longitude)
Constructs a newLatLon
from two angles. Neither angle may be null.- Parameters:
latitude
- latitudelongitude
- longitude- Throws:
java.lang.IllegalArgumentException
- iflatitude
orlongitude
is null
-
LatLon
public LatLon(LatLon latLon)
-
-
Method Detail
-
fromRadians
public static LatLon fromRadians(double latitude, double longitude)
Factor method for obtaining a newLatLon
from two angles expressed in radians.- Parameters:
latitude
- in radianslongitude
- in radians- Returns:
- a new
LatLon
from the given angles, which are expressed as radians
-
fromDegrees
public static LatLon fromDegrees(double latitude, double longitude)
Factory method for obtaining a newLatLon
from two angles expressed in degrees.- Parameters:
latitude
- in degreeslongitude
- in degrees- Returns:
- a new
LatLon
from the given angles, which are expressed as degrees
-
getLatitude
public final Angle getLatitude()
Obtains the latitude of thisLatLon
.- Returns:
- this
LatLon
's latitude
-
getLongitude
public final Angle getLongitude()
Obtains the longitude of thisLatLon
.- Returns:
- this
LatLon
's longitude
-
asDegreesArray
public double[] asDegreesArray()
Returns an array of this object's latitude and longitude in degrees.- Returns:
- the array of latitude and longitude, arranged in that order.
-
asRadiansArray
public double[] asRadiansArray()
Returns an array of this object's latitude and longitude in radians.- Returns:
- the array of latitude and longitude, arranged in that order.
-
interpolate
public static LatLon interpolate(java.lang.String pathType, double amount, LatLon value1, LatLon value2)
Returns an interpolated location betweenvalue1
andvalue2
, according to the specified path type. If the path type isAVKey.GREAT_CIRCLE
this returns an interpolated value on the great arc that spans the two locations (seeinterpolateGreatCircle(double, LatLon, LatLon)
). If the path type isAVKey.RHUMB_LINE
orAVKey.LOXODROME
this returns an interpolated value on the rhumb line that spans the two locations (seeinterpolateRhumb(double, LatLon, LatLon)
. Otherwise, this returns the linear interpolation of the two locations (seeinterpolate(double, LatLon, LatLon)
.- Parameters:
pathType
- the path type used to interpolate between geographic locations.amount
- the interpolation factorvalue1
- the first location.value2
- the second location.- Returns:
- an interpolated location between
value1
andvalue2
, according to the specified path type. - Throws:
java.lang.IllegalArgumentException
- if the path type or either location is null.
-
interpolate
public static LatLon interpolate(double amount, LatLon value1, LatLon value2)
Returns the linear interpolation ofvalue1
andvalue2
, treating the geographic locations as simple 2D coordinate pairs.- Parameters:
amount
- the interpolation factorvalue1
- the first location.value2
- the second location.- Returns:
- the linear interpolation of
value1
andvalue2
. - Throws:
java.lang.IllegalArgumentException
- if either location is null.
-
interpolateGreatCircle
public static LatLon interpolateGreatCircle(double amount, LatLon value1, LatLon value2)
Returns the an interpolated location along the great-arc betweenvalue1
andvalue2
. The interpolation factoramount
defines the weight given to each value, and is clamped to the range [0, 1]. Ifa
is 0 or less, this returnsvalue1
. Ifamount
is 1 or more, this returnsvalue2
. Otherwise, this returns the location on the great-arc betweenvalue1
andvalue2
corresponding to the specified interpolation factor. This method uses a spherical model, not elliptical.- Parameters:
amount
- the interpolation factorvalue1
- the first location.value2
- the second location.- Returns:
- an interpolated location along the great-arc between
value1
andvalue2
. - Throws:
java.lang.IllegalArgumentException
- if either location is null.
-
interpolateRhumb
public static LatLon interpolateRhumb(double amount, LatLon value1, LatLon value2)
Returns the an interpolated location along the rhumb line betweenvalue1
andvalue2
. The interpolation factoramount
defines the weight given to each value, and is clamped to the range [0, 1]. Ifa
is 0 or less, this returnsvalue1
. Ifamount
is 1 or more, this returnsvalue2
. Otherwise, this returns the location on the rhumb line betweenvalue1
andvalue2
corresponding to the specified interpolation factor. This method uses a spherical model, not elliptical.- Parameters:
amount
- the interpolation factorvalue1
- the first location.value2
- the second location.- Returns:
- an interpolated location along the rhumb line between
value1
andvalue2
- Throws:
java.lang.IllegalArgumentException
- if either location is null.
-
pathDistance
public static Angle pathDistance(java.lang.String pathType, LatLon value1, LatLon value2)
Returns the length of the path betweenvalue1
andvalue2
, according to the specified path type. If the path type isAVKey.GREAT_CIRCLE
this returns the length of the great arc that spans the two locations (seegreatCircleDistance(LatLon, LatLon)
). If the path type isAVKey.RHUMB_LINE
orAVKey.LOXODROME
this returns the length of the rhumb line that spans the two locations (seerhumbDistance(LatLon, LatLon)
). Otherwise, this returns the linear distance between the two locations (seelinearDistance(LatLon, LatLon)
).- Parameters:
pathType
- the path type used to interpolate between geographic locations.value1
- the first location.value2
- the second location.- Returns:
- an length of the path between
value1
andvalue2
, according to the specified path type. - Throws:
java.lang.IllegalArgumentException
- if the path type or either location is null.
-
greatCircleDistance
public static Angle greatCircleDistance(LatLon p1, LatLon p2)
Computes the great circle angular distance between two locations. The return value gives the distance as the angle between the two positions on the pi radius circle. In radians, this angle is also the arc length of the segment between the two positions on that circle. To compute a distance in meters from this value, multiply it by the radius of the globe. This method uses a spherical model, not elliptical.- Parameters:
p1
- LatLon of the first locationp2
- LatLon of the second location- Returns:
- the angular distance between the two locations. In radians, this value is the arc length on the radius pi circle.
-
greatCircleAzimuth
public static Angle greatCircleAzimuth(LatLon p1, LatLon p2)
Computes the azimuth angle (clockwise from North) that points from the first location to the second location. This angle can be used as the starting azimuth for a great circle arc that begins at the first location, and passes through the second location. This method uses a spherical model, not elliptical.- Parameters:
p1
- LatLon of the first locationp2
- LatLon of the second location- Returns:
- Angle that points from the first location to the second location.
-
greatCircleEndPosition
public static LatLon greatCircleEndPosition(LatLon p, Angle greatCircleAzimuth, Angle pathLength)
Computes the location on a great circle arc with the given starting location, azimuth, and arc distance. This method uses a spherical model, not elliptical.- Parameters:
p
- LatLon of the starting locationgreatCircleAzimuth
- great circle azimuth angle (clockwise from North)pathLength
- arc distance to travel- Returns:
- LatLon location on the great circle arc.
-
greatCircleEndPosition
public static LatLon greatCircleEndPosition(LatLon p, double greatCircleAzimuthRadians, double pathLengthRadians)
Computes the location on a great circle arc with the given starting location, azimuth, and arc distance. This method uses a spherical model, not elliptical.- Parameters:
p
- LatLon of the starting locationgreatCircleAzimuthRadians
- great circle azimuth angle (clockwise from North), in radianspathLengthRadians
- arc distance to travel, in radians- Returns:
- LatLon location on the great circle arc.
-
greatCircleExtremeLocations
public static LatLon[] greatCircleExtremeLocations(LatLon location, Angle azimuth)
Returns two locations with the most extreme latitudes on the great circle with the given starting location and azimuth. This method uses a spherical model, not elliptical.- Parameters:
location
- location on the great circle.azimuth
- great circle azimuth angle (clockwise from North).- Returns:
- two locations where the great circle has its extreme latitudes.
- Throws:
java.lang.IllegalArgumentException
- if eitherlocation
orazimuth
are null.
-
greatCircleArcExtremeLocations
public static LatLon[] greatCircleArcExtremeLocations(LatLon begin, LatLon end)
Returns two locations with the most extreme latitudes on the great circle arc defined by, and limited to, the two locations. This method uses a spherical model, not elliptical.- Parameters:
begin
- beginning location on the great circle arc.end
- ending location on the great circle arc.- Returns:
- two locations with the most extreme latitudes on the great circle arc.
- Throws:
java.lang.IllegalArgumentException
- if eitherbegin
orend
are null.
-
greatCircleArcExtremeLocations
public static LatLon[] greatCircleArcExtremeLocations(java.lang.Iterable<? extends LatLon> locations)
Returns two locations with the most extreme latitudes on the sequence of great circle arcs defined by each pair of locations in the specified iterable. This method uses a spherical model, not elliptical.- Parameters:
locations
- the pairs of locations defining a sequence of great circle arcs.- Returns:
- two locations with the most extreme latitudes on the great circle arcs.
- Throws:
java.lang.IllegalArgumentException
- iflocations
is null.
-
rhumbDistance
public static Angle rhumbDistance(LatLon p1, LatLon p2)
Computes the length of the rhumb line between two locations. The return value gives the distance as the angular distance between the two positions on the pi radius circle. In radians, this angle is also the arc length of the segment between the two positions on that circle. To compute a distance in meters from this value, multiply it by the radius of the globe. This method uses a spherical model, not elliptical.- Parameters:
p1
- LatLon of the first locationp2
- LatLon of the second location- Returns:
- the arc length of the rhumb line between the two locations. In radians, this value is the arc length on the radius pi circle.
-
rhumbAzimuth
public static Angle rhumbAzimuth(LatLon p1, LatLon p2)
Computes the azimuth angle (clockwise from North) of a rhumb line (a line of constant heading) between two locations. This method uses a spherical model, not elliptical.- Parameters:
p1
- LatLon of the first locationp2
- LatLon of the second location- Returns:
- azimuth Angle of a rhumb line between the two locations.
-
rhumbEndPosition
public static LatLon rhumbEndPosition(LatLon p, Angle rhumbAzimuth, Angle pathLength)
Computes the location on a rhumb line with the given starting location, rhumb azimuth, and arc distance along the line. This method uses a spherical model, not elliptical.- Parameters:
p
- LatLon of the starting locationrhumbAzimuth
- rhumb azimuth angle (clockwise from North)pathLength
- arc distance to travel- Returns:
- LatLon location on the rhumb line.
-
rhumbEndPosition
public static LatLon rhumbEndPosition(LatLon p, double rhumbAzimuthRadians, double pathLengthRadians)
Computes the location on a rhumb line with the given starting location, rhumb azimuth, and arc distance along the line. This method uses a spherical model, not elliptical.- Parameters:
p
- LatLon of the starting locationrhumbAzimuthRadians
- rhumb azimuth angle (clockwise from North), in radianspathLengthRadians
- arc distance to travel, in radians- Returns:
- LatLon location on the rhumb line.
-
linearDistance
public static Angle linearDistance(LatLon p1, LatLon p2)
Computes the length of the linear path between two locations. The return value gives the distance as the angular distance between the two positions on the pi radius circle. In radians, this angle is also the arc length of the segment between the two positions on that circle. To compute a distance in meters from this value, multiply it by the radius of the globe.- Parameters:
p1
- LatLon of the first locationp2
- LatLon of the second location- Returns:
- the arc length of the line between the two locations. In radians, this value is the arc length on the radius pi circle.
-
linearAzimuth
public static Angle linearAzimuth(LatLon p1, LatLon p2)
Computes the azimuth angle (clockwise from North) of a linear path two locations.- Parameters:
p1
- LatLon of the first locationp2
- LatLon of the second location- Returns:
- azimuth Angle of a linear path between the two locations.
-
linearEndPosition
public static LatLon linearEndPosition(LatLon p, Angle linearAzimuth, Angle pathLength)
Computes the location on a linear path given a starting location, azimuth, and arc distance along the line. A linear path is determined by treating latitude and longitude as a rectangular grid. This type of path is a straight line in the equidistant cylindrical map projection (also called equirectangular).- Parameters:
p
- LatLon of the starting locationlinearAzimuth
- azimuth angle (clockwise from North)pathLength
- arc distance to travel- Returns:
- LatLon location on the line.
-
getAverageDistance
public static Angle getAverageDistance(java.lang.Iterable<? extends LatLon> locations)
Compute the average rhumb distance between locations.- Parameters:
locations
- Locations of which to compute average.- Returns:
- Average rhumb line distance between locations, as an angular distance.
-
getAverageDistance
public static Angle getAverageDistance(Globe globe, LatLon center, java.lang.Iterable<? extends LatLon> locations)
Computes the average distance between a specified center point and a list of locations.- Parameters:
globe
- the globe to use for the computations.center
- the center point.locations
- the locations.- Returns:
- the average distance.
- Throws:
java.lang.IllegalArgumentException
- if any of the specified globe, center or locations are null.
-
getCenter
public static LatLon getCenter(java.lang.Iterable<? extends LatLon> locations)
Computes the average location of a specified list of locations.- Parameters:
locations
- the locations.- Returns:
- the average of the locations.
- Throws:
java.lang.IllegalArgumentException
- if the specified locations is null.
-
getCenter
public static LatLon getCenter(Globe globe, java.lang.Iterable<? extends LatLon> locations)
Computes the average location of a specified list of locations.- Parameters:
globe
- the globe to use for the computations.locations
- the locations.- Returns:
- the average of the locations.
- Throws:
java.lang.IllegalArgumentException
- if either the specified globe or locations is null.
-
locationsCrossDateLine
public static boolean locationsCrossDateLine(java.lang.Iterable<? extends LatLon> locations)
-
locationsContainPole
public static java.lang.String locationsContainPole(java.lang.Iterable<? extends LatLon> locations)
Determines if a sequence of geographic locations encloses either the North or South pole. The sequence is treated as a closed loop. (If the first and last positions are not equal the loop will be closed for purposes of this computation.)- Parameters:
locations
- The locations to test.- Returns:
- AVKey.NORTH if the North Pole is enclosed, AVKey.SOUTH if the South Pole is enclosed, or null if neither pole is enclosed.
- Throws:
java.lang.IllegalArgumentException
- if the locations are null.
-
repeatLocationsAroundDateline
public static java.util.List<java.util.List<LatLon>> repeatLocationsAroundDateline(java.lang.Iterable<? extends LatLon> locations)
Returns a list containing two copies of a sequence of geographic locations that cross the dateline: one that extends across the -180 longitude boundary and one that extends across the +180 longitude boundary. If the sequence does not cross the dateline this returns a list containing a copy of the original list.- Parameters:
locations
- The locations to repeat.- Returns:
- A list containing two new location lists, one copy for either side of the dateline.
- Throws:
java.lang.IllegalArgumentException
- if the locations are null.
-
cutLocationsAlongDateLine
public static java.util.List<LatLon> cutLocationsAlongDateLine(java.lang.Iterable<? extends LatLon> locations, java.lang.String pole, Globe globe)
Divides a sequence of geographic locations that encloses a pole along the international dateline. This method determines where the locations cross the dateline, and inserts locations to the pole, and then back to the intersection position. This allows the shape to be "unrolled" when projected in a lat-lon projection.- Parameters:
locations
- Locations to cut at dateline. This list is not modified.pole
- Pole contained by locations, either AVKey.NORTH or AVKey.SOUTH.globe
- Current globe, or null to treat geographic coordinates as linear for the purpose of computing the dateline intersection.- Returns:
- New location list with locations added to correctly handle dateline intersection.
- Throws:
java.lang.IllegalArgumentException
- if the locations are null or if the pole is null.
-
makeDatelineCrossingLocationsPositive
public static java.util.List<LatLon> makeDatelineCrossingLocationsPositive(java.lang.Iterable<? extends LatLon> locations)
Transform the negative longitudes of a dateline-spanning location list to positive values that maintain the relationship with the other locations in the list. Negative longitudes are transformed to values greater than 180 degrees, as though longitude spanned [0, 360] rather than [-180, 180]. This enables arithmetic operations to be performed on the locations without having to take into account the longitude jump at the dateline.- Parameters:
locations
- the locations to transform. This list is not modified.- Returns:
- a new list of locations transformed as described above.
- Throws:
java.lang.IllegalArgumentException
- if the location list is null.
-
intersectionWithMeridian
public static LatLon intersectionWithMeridian(LatLon p1, LatLon p2, Angle meridian, Globe globe)
Determine where a line between two locations crosses a given meridian. The intersection test is performed by intersecting a line in Cartesian space between the two positions with a plane through the meridian. Thus, it is most suitable for working with positions that are fairly close together as the calculation does not take into account great circle or rhumb paths.- Parameters:
p1
- The first location.p2
- The second location.meridian
- The line of constant longitude to intersect with.globe
- Globe used to compute intersection, or null to treat geographic coordinates as linear for the purpose of computing the intersection.- Returns:
- The intersection location along the meridian.
- Throws:
java.lang.IllegalArgumentException
- if either location is null, or if the meridian is null.
-
intersectionWithMeridian
public static LatLon intersectionWithMeridian(LatLon p1, LatLon p2, Angle meridian)
Determine where a line between two locations crosses a given meridian. The intersection test is performed by treating geographic coordinates as linear and computing the intersection of the linear segment with the vertical line indicated by the meridian. This computation correctly handles intersections with either side of the antimeridian.- Parameters:
p1
- The first location.p2
- The second location.meridian
- The line of constant longitude to intersect with.- Returns:
- The intersection location along the meridian.
- Throws:
java.lang.IllegalArgumentException
- if either location is null, or if the meridian is null.
-
parseLatLon
public LatLon parseLatLon(java.lang.String latLonString)
Parses a string containing latitude and longitude coordinates in either Degrees-minutes-seconds or decimal degrees. The latitude must precede the longitude and the angles must be separated by a comma.- Parameters:
latLonString
- a string containing the comma separated latitude and longitude in either DMS or decimal degrees.- Returns:
- a
LatLon
instance with the parsed angles. - Throws:
java.lang.IllegalArgumentException
- iflatLonString
is null.java.lang.NumberFormatException
- if the string does not form a latitude, longitude pair.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
ellipsoidalForwardAzimuth
public static Angle ellipsoidalForwardAzimuth(LatLon p1, LatLon p2, double equatorialRadius, double polarRadius)
Compute the forward azimuth between two positions- Parameters:
p1
- first positionp2
- second positionequatorialRadius
- the equatorial radius of the globe in meterspolarRadius
- the polar radius of the globe in meters- Returns:
- the azimuth
-
ellipsoidalDistance
public static double ellipsoidalDistance(LatLon p1, LatLon p2, double equatorialRadius, double polarRadius)
Computes the distance between two points on an ellipsoid iteratively.NOTE: This method was copied from the UniData NetCDF Java library. http://www.unidata.ucar.edu/software/netcdf-java/
Algorithm from U.S. National Geodetic Survey, FORTRAN program "inverse," subroutine "INVER1," by L. PFEIFER and JOHN G. GERGEN. See http://www.ngs.noaa.gov/TOOLS/Inv_Fwd/Inv_Fwd.html
Original documentation: SOLUTION OF THE GEODETIC INVERSE PROBLEM AFTER T.VINCENTY MODIFIED RAINSFORD'S METHOD WITH HELMERT'S ELLIPTICAL TERMS EFFECTIVE IN ANY AZIMUTH AND AT ANY DISTANCE SHORT OF ANTIPODAL STANDPOINT/FOREPOINT MUST NOT BE THE GEOGRAPHIC POLE
Requires close to 1.4 E-5 seconds wall clock time per call on a 550 MHz Pentium with Linux 7.2.
The algorithm used is iterative and will iterate only 10 times if it does not converge.
- Parameters:
p1
- first positionp2
- second positionequatorialRadius
- the equatorial radius of the globe in meterspolarRadius
- the polar radius of the globe in meters- Returns:
- distance in meters between the two points
-
computeShiftedLocations
public static java.util.List<LatLon> computeShiftedLocations(Position oldLocation, Position newLocation, java.lang.Iterable<? extends LatLon> locations)
Computes a new set of locations translated from a specified location to a new location.- Parameters:
oldLocation
- the original reference location.newLocation
- the new reference location.locations
- the locations to translate.- Returns:
- the translated locations, or null if the locations could not be translated.
- Throws:
java.lang.IllegalArgumentException
- if any argument is null.
-
-