public class GeodeticCalculator extends Object
The calculation uses the following information:
Note: This class is not thread-safe. If geodetic calculations are needed in a multi-threads
environment, create one distinct instance of GeodeticCalculator
for each thread.
Constructor and Description |
---|
GeodeticCalculator()
Constructs a new geodetic calculator associated with the WGS84 ellipsoid.
|
GeodeticCalculator(CoordinateReferenceSystem crs)
Constructs a new geodetic calculator expecting coordinates in the supplied CRS.
|
GeodeticCalculator(Ellipsoid ellipsoid)
Constructs a new geodetic calculator associated with the specified ellipsoid.
|
Modifier and Type | Method and Description |
---|---|
double |
getAzimuth()
Returns the azimuth.
|
CoordinateReferenceSystem |
getCoordinateReferenceSystem()
Returns the coordinate reference system for all methods working on
Position objects. |
Point2D |
getDestinationGeographicPoint()
Returns the destination point.
|
DirectPosition |
getDestinationPosition()
Returns the destination position in user coordinates, which doesn't need to be geographic.
|
Ellipsoid |
getEllipsoid()
Returns the referenced ellipsoid.
|
Shape |
getGeodeticCurve()
Calculates the geodetic curve between two points in the referenced ellipsoid.
|
Shape |
getGeodeticCurve(int numberOfPoints)
Calculates the geodetic curve between two points in the referenced ellipsoid.
|
List<Point2D> |
getGeodeticPath(int numPoints)
Calculates the geodetic curve between two points in the referenced ellipsoid.
|
GeographicCRS |
getGeographicCRS()
Returns the geographic coordinate reference system for all methods working on
Point2D
objects. |
double |
getMeridianArcLength(double latitude1,
double latitude2)
Calculates the meridian arc length between two points in the same meridian in the referenced
ellipsoid.
|
double |
getOrthodromicDistance()
Returns the orthodromic distance (expressed in meters).
|
Point2D |
getStartingGeographicPoint()
Returns the starting point in geographic coordinates.
|
DirectPosition |
getStartingPosition()
Returns the starting position in user coordinates, which doesn't need to be geographic.
|
void |
setDestinationGeographicPoint(double longitude,
double latitude)
Set the destination point in geographic coordinates.
|
void |
setDestinationGeographicPoint(Point2D point)
Set the destination point in geographic coordinates.
|
void |
setDestinationPosition(Position position)
Set the destination position in user coordinates, which doesn't need to be geographic.
|
void |
setDirection(double azimuth,
double distance)
Set the azimuth and the distance from the starting
point.
|
void |
setStartingGeographicPoint(double longitude,
double latitude)
Set the starting point in geographic coordinates.
|
void |
setStartingGeographicPoint(Point2D point)
Set the starting point in geographic coordinates.
|
void |
setStartingPosition(Position position)
Set the starting position in user coordinates, which doesn't need to be geographic.
|
String |
toString()
Returns a string representation of the current state of this calculator.
|
public GeodeticCalculator()
public GeodeticCalculator(Ellipsoid ellipsoid)
ellipsoid
- The ellipsoid onto which calculates distances and azimuths.public GeodeticCalculator(CoordinateReferenceSystem crs)
crs
- The reference system for the Position
objects.public CoordinateReferenceSystem getCoordinateReferenceSystem()
Position
objects.
This is the CRS specified at construction time.Position
s.public GeographicCRS getGeographicCRS()
Point2D
objects. This is inferred from the CRS specified at construction time.Point2D
s.public Ellipsoid getEllipsoid()
public void setStartingGeographicPoint(double longitude, double latitude) throws IllegalArgumentException
longitude
- The longitude in decimal degrees between -180 and +180°latitude
- The latitude in decimal degrees between -90 and +90°IllegalArgumentException
- if the longitude or the latitude is out of bounds.public void setStartingGeographicPoint(Point2D point) throws IllegalArgumentException
This is a convenience method for
setStartingGeographicPoint(x,y)
.
point
- The starting point.IllegalArgumentException
- if the longitude or the latitude is out of bounds.public void setStartingPosition(Position position) throws TransformException
position
- The position in user coordinate reference system.TransformException
- if the position can't be transformed.public Point2D getStartingGeographicPoint()
public DirectPosition getStartingPosition() throws TransformException
TransformException
- if the position can't be transformed to user coordinates.public void setDestinationGeographicPoint(double longitude, double latitude) throws IllegalArgumentException
getAzimuth()
or getOrthodromicDistance()
are invoked.longitude
- The longitude in decimal degreeslatitude
- The latitude in decimal degrees between -90 and +90°IllegalArgumentException
- if the longitude or the latitude is out of bounds.public void setDestinationGeographicPoint(Point2D point) throws IllegalArgumentException
This is a convenience method for
setDestinationGeographicPoint(x,y)
.
point
- The destination point.IllegalArgumentException
- if the longitude or the latitude is out of bounds.public void setDestinationPosition(Position position) throws TransformException
position
- The position in user coordinate reference system.TransformException
- if the position can't be transformed.public Point2D getDestinationGeographicPoint() throws IllegalStateException
setDestinationGeographicPoint(...)
method, except if
setDirection(...)
has been invoked after. In
this later case, the destination point will be computed from the starting point to the azimuth and distance specified.IllegalStateException
- if the azimuth and the distance have not been set.public DirectPosition getDestinationPosition() throws TransformException
TransformException
- if the position can't be transformed to user coordinates.public void setDirection(double azimuth, double distance) throws IllegalArgumentException
getDestinationGeographicPoint()
is invoked.azimuth
- The azimuth in decimal degreesdistance
- The orthodromic distance in the same units as the ellipsoid axis (meters by default)IllegalArgumentException
- if the azimuth or the distance is out of bounds.getAzimuth()
,
getOrthodromicDistance()
public double getAzimuth() throws IllegalStateException
setDirection(azimuth,distance)
,
except if setDestinationGeographicPoint(...)
has been invoked after. In this later case, the
azimuth will be computed from the starting point to
the destination point.IllegalStateException
- if the destination point has not been set.public double getOrthodromicDistance() throws IllegalStateException
setDirection(azimuth,distance)
,
except if setDestinationGeographicPoint(...)
has been invoked after. In this later case, the
distance will be computed from the starting point to
the destination point.IllegalStateException
- if the destination point has not been set.public double getMeridianArcLength(double latitude1, double latitude2)
latitude1
- The latitude of the first point (in decimal degrees).latitude2
- The latitude of the second point (in decimal degrees).public Shape getGeodeticCurve(int numberOfPoints)
numberOfPoints
- The number of vertex in the geodetic curve. NOTE: This
argument is only a hint and may be ignored in future version (if we compute a real curve
rather than a list of line segments).public Shape getGeodeticCurve()
public List<Point2D> getGeodeticPath(int numPoints)
numPoints
- The number of vertices between the start and destination
pointsCopyright © 1996–2019 Geotools. All rights reserved.