Classes | |
class | InverseData |
class | InverseStartV |
class | Lambda12V |
class | LengthsV |
Public Member Functions | |
GeodesicData | ArcDirect (double lat1, double lon1, double azi1, double a12) |
GeodesicData | ArcDirect (double lat1, double lon1, double azi1, double a12, int outmask) |
GeodesicLine | ArcDirectLine (double lat1, double lon1, double azi1, double a12) |
GeodesicLine | ArcDirectLine (double lat1, double lon1, double azi1, double a12, int caps) |
GeodesicData | Direct (double lat1, double lon1, double azi1, double s12) |
GeodesicData | Direct (double lat1, double lon1, double azi1, double s12, int outmask) |
GeodesicData | Direct (double lat1, double lon1, double azi1, boolean arcmode, double s12_a12, int outmask) |
GeodesicLine | DirectLine (double lat1, double lon1, double azi1, double s12) |
GeodesicLine | DirectLine (double lat1, double lon1, double azi1, double s12, int caps) |
double | EllipsoidArea () |
double | Flattening () |
GeodesicLine | GenDirectLine (double lat1, double lon1, double azi1, boolean arcmode, double s12_a12, int caps) |
Geodesic (double a, double f) | |
GeodesicData | Inverse (double lat1, double lon1, double lat2, double lon2) |
GeodesicData | Inverse (double lat1, double lon1, double lat2, double lon2, int outmask) |
GeodesicLine | InverseLine (double lat1, double lon1, double lat2, double lon2) |
GeodesicLine | InverseLine (double lat1, double lon1, double lat2, double lon2, int caps) |
GeodesicLine | Line (double lat1, double lon1, double azi1) |
GeodesicLine | Line (double lat1, double lon1, double azi1, int caps) |
double | MajorRadius () |
Static Public Attributes | |
static final Geodesic | WGS84 |
Protected Member Functions | |
void | A3coeff () |
double | A3f (double eps) |
void | C3coeff () |
void | C3f (double eps, double c[]) |
void | C4coeff () |
void | C4f (double eps, double c[]) |
Static Protected Member Functions | |
static double | A1m1f (double eps) |
static double | A2m1f (double eps) |
static void | C1f (double eps, double c[]) |
static void | C1pf (double eps, double c[]) |
static void | C2f (double eps, double c[]) |
static double | SinCosSeries (boolean sinp, double sinx, double cosx, double c[]) |
Protected Attributes | |
double | _a |
Static Protected Attributes | |
static final int | GEOGRAPHICLIB_GEODESIC_ORDER = 6 |
static final int | nA1_ = GEOGRAPHICLIB_GEODESIC_ORDER |
static final int | nA2_ = GEOGRAPHICLIB_GEODESIC_ORDER |
static final int | nA3_ = GEOGRAPHICLIB_GEODESIC_ORDER |
static final int | nA3x_ = nA3_ |
static final int | nC1_ = GEOGRAPHICLIB_GEODESIC_ORDER |
static final int | nC1p_ = GEOGRAPHICLIB_GEODESIC_ORDER |
static final int | nC2_ = GEOGRAPHICLIB_GEODESIC_ORDER |
static final int | nC3_ = GEOGRAPHICLIB_GEODESIC_ORDER |
static final int | nC3x_ = (nC3_ * (nC3_ - 1)) / 2 |
static final int | nC4_ = GEOGRAPHICLIB_GEODESIC_ORDER |
static final int | nC4x_ = (nC4_ * (nC4_ + 1)) / 2 |
static final double | tiny_ = Math.sqrt(GeoMath.min) |
Private Member Functions | |
InverseData | InverseInt (double lat1, double lon1, double lat2, double lon2, int outmask) |
InverseStartV | InverseStart (double sbet1, double cbet1, double dn1, double sbet2, double cbet2, double dn2, double lam12, double slam12, double clam12, double C1a[], double C2a[]) |
Lambda12V | Lambda12 (double sbet1, double cbet1, double dn1, double sbet2, double cbet2, double dn2, double salp1, double calp1, double slam120, double clam120, boolean diffp, double C1a[], double C2a[], double C3a[]) |
LengthsV | Lengths (double eps, double sig12, double ssig1, double csig1, double dn1, double ssig2, double csig2, double dn2, double cbet1, double cbet2, int outmask, double C1a[], double C2a[]) |
Static Private Member Functions | |
static double | Astroid (double x, double y) |
Private Attributes | |
double | _A3x [] |
double | _n |
Static Private Attributes | |
static final int | maxit1_ = 20 |
static final int | maxit2_ = maxit1_ + GeoMath.digits + 10 |
static final double | tol0_ = GeoMath.epsilon |
static final double | tol1_ = 200 * tol0_ |
static final double | tol2_ = Math.sqrt(tol0_) |
static final double | tolb_ = tol0_ * tol2_ |
static final double | xthresh_ = 1000 * tol2_ |
Geodesic calculations.
The shortest path between two points on a ellipsoid at (lat1, lon1) and (lat2, lon2) is called the geodesic. Its length is s12 and the geodesic from point 1 to point 2 has azimuths azi1 and azi2 at the two end points. (The azimuth is the heading measured clockwise from north. azi2 is the "forward" azimuth, i.e., the heading that takes you beyond point 2 not back to point 1.)
Given lat1, lon1, azi1, and s12, we can determine lat2, lon2, and azi2. This is the direct geodesic problem and its solution is given by the function Direct. (If s12 is sufficiently large that the geodesic wraps more than halfway around the earth, there will be another geodesic between the points with a smaller s12.)
Given lat1, lon1, lat2, and lon2, we can determine azi1, azi2, and s12. This is the inverse geodesic problem, whose solution is given by Inverse. Usually, the solution to the inverse problem is unique. In cases where there are multiple solutions (all with the same s12, of course), all the solutions can be easily generated once a particular solution is provided.
The standard way of specifying the direct problem is the specify the distance s12 to the second point. However it is sometimes useful instead to specify the arc length a12 (in degrees) on the auxiliary sphere. This is a mathematical construct used in solving the geodesic problems. The solution of the direct problem in this form is provided by ArcDirect. An arc length in excess of 180° indicates that the geodesic is not a shortest path. In addition, the arc length between an equatorial crossing and the next extremum of latitude for a geodesic is 90°.
This class can also calculate several other quantities related to geodesics. These are:
The quantities m12, M12, M21 which all specify the behavior of nearby geodesics obey addition rules. If points 1, 2, and 3 all lie on a single geodesic, then the following rules hold:
The results of the geodesic calculations are bundled up into a GeodesicData object which includes the input parameters and all the computed results, i.e., lat1, lon1, azi1, lat2, lon2, azi2, s12, a12, m12, M12, M21, S12.
The functions Direct, ArcDirect, and Inverse include an optional final argument outmask which allows you specify which results should be computed and returned. If you omit outmask, then the "standard" geodesic results are computed (latitudes, longitudes, azimuths, and distance). outmask is bitor'ed combination of GeodesicMask values. For example, if you wish just to compute the distance between two points you would call, e.g.,
Additional functionality is provided by the GeodesicLine class, which allows a sequence of points along a geodesic to be computed.
The shortest distance returned by the solution of the inverse problem is (obviously) uniquely defined. However, in a few special cases there are multiple azimuths which yield the same shortest distance. Here is a catalog of those cases:
The calculations are accurate to better than 15 nm (15 nanometers) for the WGS84 ellipsoid. See Sec. 9 of arXiv:1102.1215v1 for details. The algorithms used by this class are based on series expansions using the flattening f as a small parameter. These are only accurate for |f| < 0.02; however reasonably accurate results will be obtained for |f| < 0.2. Here is a table of the approximate maximum error (expressed as a distance) for an ellipsoid with the same equatorial radius as the WGS84 ellipsoid and different values of the flattening.
|f| error 0.01 25 nm 0.02 30 nm 0.05 10 um 0.1 1.5 mm 0.2 300 mm
The algorithms are described in
Example of use:
// Solve the direct geodesic problem.// This program reads in lines with lat1, lon1, azi1, s12 and prints// out lines with lat2, lon2, azi2 (for the WGS84 ellipsoid).import java.util.*;try {Scanner in = new Scanner(System.in);double lat1, lon1, azi1, s12;while (true) {lat1 = in.nextDouble(); lon1 = in.nextDouble();azi1 = in.nextDouble(); s12 = in.nextDouble();GeodesicData g = Geodesic.WGS84.Direct(lat1, lon1, azi1, s12);}}catch (Exception e) {}}}
Definition at line 202 of file Geodesic.java.
|
inline |
Constructor for a ellipsoid with
a | equatorial radius (meters). |
f | flattening of ellipsoid. Setting f = 0 gives a sphere. Negative f gives a prolate ellipsoid. |
GeographicErr | if a or (1 − f ) a is not positive. |
Definition at line 250 of file Geodesic.java.
|
inlinestaticprotected |
Definition at line 1676 of file Geodesic.java.
|
inlinestaticprotected |
Definition at line 1743 of file Geodesic.java.
|
inlineprotected |
Definition at line 1782 of file Geodesic.java.
|
inlineprotected |
Definition at line 1644 of file Geodesic.java.
|
inline |
Solve the direct geodesic problem where the length of the geodesic is specified in terms of arc length.
lat1 | latitude of point 1 (degrees). |
lon1 | longitude of point 1 (degrees). |
azi1 | azimuth at point 1 (degrees). |
a12 | arc length between point 1 and point 2 (degrees); it can be negative. |
lat1 should be in the range [−90°, 90°]. The values of lon2 and azi2 returned are in the range [−180°, 180°].
If either point is at a pole, the azimuth is defined by keeping the longitude fixed, writing lat = ±(90° − ε), and taking the limit ε → 0+. An arc length greater that 180° signifies a geodesic which is not a shortest path. (For a prolate ellipsoid, an additional condition is necessary for a shortest path: the longitudinal extent must not exceed of 180°.)
Definition at line 366 of file Geodesic.java.
|
inline |
Solve the direct geodesic problem where the length of the geodesic is specified in terms of arc length and with a subset of the geodesic results returned.
lat1 | latitude of point 1 (degrees). |
lon1 | longitude of point 1 (degrees). |
azi1 | azimuth at point 1 (degrees). |
a12 | arc length between point 1 and point 2 (degrees); it can be negative. |
outmask | a bitor'ed combination of GeodesicMask values specifying which results should be returned. |
lat1, lon1, azi1, and a12 are always included in the returned result. The value of lon2 returned is in the range [−180°, 180°], unless the outmask includes the GeodesicMask#LONG_UNROLL flag.
Definition at line 391 of file Geodesic.java.
|
inline |
Define a GeodesicLine in terms of the direct geodesic problem specified in terms of arc length with all capabilities included.
lat1 | latitude of point 1 (degrees). |
lon1 | longitude of point 1 (degrees). |
azi1 | azimuth at point 1 (degrees). |
a12 | arc length between point 1 and point 2 (degrees); it can be negative. |
This function sets point 3 of the GeodesicLine to correspond to point 2 of the direct geodesic problem.
lat1 should be in the range [−90°, 90°].
Definition at line 523 of file Geodesic.java.
|
inline |
Define a GeodesicLine in terms of the direct geodesic problem specified in terms of arc length with a subset of the capabilities included.
lat1 | latitude of point 1 (degrees). |
lon1 | longitude of point 1 (degrees). |
azi1 | azimuth at point 1 (degrees). |
a12 | arc length between point 1 and point 2 (degrees); it can be negative. |
caps | bitor'ed combination of GeodesicMask values specifying the capabilities the GeodesicLine object should possess, i.e., which quantities can be returned in calls to GeodesicLine.Position. |
This function sets point 3 of the GeodesicLine to correspond to point 2 of the direct geodesic problem.
lat1 should be in the range [−90°, 90°].
Definition at line 549 of file Geodesic.java.
|
inlinestaticprivate |
Definition at line 1324 of file Geodesic.java.
|
inlinestaticprotected |
Definition at line 1687 of file Geodesic.java.
|
inlinestaticprotected |
Definition at line 1715 of file Geodesic.java.
|
inlinestaticprotected |
Definition at line 1754 of file Geodesic.java.
|
inlineprotected |
Definition at line 1806 of file Geodesic.java.
|
inlineprotected |
Definition at line 1649 of file Geodesic.java.
|
inlineprotected |
Definition at line 1849 of file Geodesic.java.
|
inlineprotected |
Definition at line 1662 of file Geodesic.java.
|
inline |
Solve the direct geodesic problem where the length of the geodesic is specified in terms of distance.
lat1 | latitude of point 1 (degrees). |
lon1 | longitude of point 1 (degrees). |
azi1 | azimuth at point 1 (degrees). |
s12 | distance between point 1 and point 2 (meters); it can be negative. |
lat1 should be in the range [−90°, 90°]. The values of lon2 and azi2 returned are in the range [−180°, 180°].
If either point is at a pole, the azimuth is defined by keeping the longitude fixed, writing lat = ±(90° − ε), and taking the limit ε → 0+. An arc length greater that 180° signifies a geodesic which is not a shortest path. (For a prolate ellipsoid, an additional condition is necessary for a shortest path: the longitudinal extent must not exceed of 180°.)
Definition at line 313 of file Geodesic.java.
|
inline |
Solve the direct geodesic problem where the length of the geodesic is specified in terms of distance and with a subset of the geodesic results returned.
lat1 | latitude of point 1 (degrees). |
lon1 | longitude of point 1 (degrees). |
azi1 | azimuth at point 1 (degrees). |
s12 | distance between point 1 and point 2 (meters); it can be negative. |
outmask | a bitor'ed combination of GeodesicMask values specifying which results should be returned. |
lat1, lon1, azi1, s12, and a12 are always included in the returned result. The value of lon2 returned is in the range [−180°, 180°], unless the outmask includes the GeodesicMask#LONG_UNROLL flag.
Definition at line 337 of file Geodesic.java.
|
inline |
The general direct geodesic problem. Direct and ArcDirect are defined in terms of this function.
lat1 | latitude of point 1 (degrees). |
lon1 | longitude of point 1 (degrees). |
azi1 | azimuth at point 1 (degrees). |
arcmode | boolean flag determining the meaning of the s12_a12. |
s12_a12 | if arcmode is false, this is the distance between point 1 and point 2 (meters); otherwise it is the arc length between point 1 and point 2 (degrees); it can be negative. |
outmask | a bitor'ed combination of GeodesicMask values specifying which results should be returned. |
The GeodesicMask values possible for outmask are
The function value a12 is always computed and returned and this equals s12_a12 is arcmode is true. If outmask includes GeodesicMask#DISTANCE and arcmode is false, then s12 = s12_a12. It is not necessary to include GeodesicMask#DISTANCE_IN in outmask; this is automatically included is arcmode is false.
Definition at line 452 of file Geodesic.java.
|
inline |
Define a GeodesicLine in terms of the direct geodesic problem specified in terms of distance with all capabilities included.
lat1 | latitude of point 1 (degrees). |
lon1 | longitude of point 1 (degrees). |
azi1 | azimuth at point 1 (degrees). |
s12 | distance between point 1 and point 2 (meters); it can be negative. |
This function sets point 3 of the GeodesicLine to correspond to point 2 of the direct geodesic problem.
lat1 should be in the range [−90°, 90°].
Definition at line 477 of file Geodesic.java.
|
inline |
Define a GeodesicLine in terms of the direct geodesic problem specified in terms of distance with a subset of the capabilities included.
lat1 | latitude of point 1 (degrees). |
lon1 | longitude of point 1 (degrees). |
azi1 | azimuth at point 1 (degrees). |
s12 | distance between point 1 and point 2 (meters); it can be negative. |
caps | bitor'ed combination of GeodesicMask values specifying the capabilities the GeodesicLine object should possess, i.e., which quantities can be returned in calls to GeodesicLine.Position. |
This function sets point 3 of the GeodesicLine to correspond to point 2 of the direct geodesic problem.
lat1 should be in the range [−90°, 90°].
Definition at line 502 of file Geodesic.java.
|
inline |
Definition at line 1201 of file Geodesic.java.
|
inline |
Definition at line 1194 of file Geodesic.java.
|
inline |
Define a GeodesicLine in terms of the direct geodesic problem specified in terms of either distance or arc length with a subset of the capabilities included.
lat1 | latitude of point 1 (degrees). |
lon1 | longitude of point 1 (degrees). |
azi1 | azimuth at point 1 (degrees). |
arcmode | boolean flag determining the meaning of the s12_a12. |
s12_a12 | if arcmode is false, this is the distance between point 1 and point 2 (meters); otherwise it is the arc length between point 1 and point 2 (degrees); it can be negative. |
caps | bitor'ed combination of GeodesicMask values specifying the capabilities the GeodesicLine object should possess, i.e., which quantities can be returned in calls to GeodesicLine.Position. |
This function sets point 3 of the GeodesicLine to correspond to point 2 of the direct geodesic problem.
lat1 should be in the range [−90°, 90°].
Definition at line 577 of file Geodesic.java.
|
inline |
Solve the inverse geodesic problem.
lat1 | latitude of point 1 (degrees). |
lon1 | longitude of point 1 (degrees). |
lat2 | latitude of point 2 (degrees). |
lon2 | longitude of point 2 (degrees). |
lat1 and lat2 should be in the range [−90°, 90°]. The values of azi1 and azi2 returned are in the range [−180°, 180°].
If either point is at a pole, the azimuth is defined by keeping the longitude fixed, writing lat = ±(90° − ε), taking the limit ε → 0+.
The solution to the inverse problem is found using Newton's method. If this fails to converge (this is very unlikely in geodetic applications but does occur for very eccentric ellipsoids), then the bisection method is used to refine the solution.
Definition at line 615 of file Geodesic.java.
|
inline |
Solve the inverse geodesic problem with a subset of the geodesic results returned.
lat1 | latitude of point 1 (degrees). |
lon1 | longitude of point 1 (degrees). |
lat2 | latitude of point 2 (degrees). |
lon2 | longitude of point 2 (degrees). |
outmask | a bitor'ed combination of GeodesicMask values specifying which results should be returned. |
The GeodesicMask values possible for outmask are
lat1, lon1, lat2, lon2, and a12 are always included in the returned result.
Definition at line 1049 of file Geodesic.java.
|
inlineprivate |
Definition at line 629 of file Geodesic.java.
|
inline |
Define a GeodesicLine in terms of the inverse geodesic problem with all capabilities included.
lat1 | latitude of point 1 (degrees). |
lon1 | longitude of point 1 (degrees). |
lat2 | latitude of point 2 (degrees). |
lon2 | longitude of point 2 (degrees). |
This function sets point 3 of the GeodesicLine to correspond to point 2 of the inverse geodesic problem.
lat1 and lat2 should be in the range [−90°, 90°].
Definition at line 1077 of file Geodesic.java.
|
inline |
Define a GeodesicLine in terms of the inverse geodesic problem with a subset of the capabilities included.
lat1 | latitude of point 1 (degrees). |
lon1 | longitude of point 1 (degrees). |
lat2 | latitude of point 2 (degrees). |
lon2 | longitude of point 2 (degrees). |
caps | bitor'ed combination of GeodesicMask values specifying the capabilities the GeodesicLine object should possess, i.e., which quantities can be returned in calls to GeodesicLine.Position. |
This function sets point 3 of the GeodesicLine to correspond to point 2 of the inverse geodesic problem.
lat1 and lat2 should be in the range [−90°, 90°].
Definition at line 1102 of file Geodesic.java.
|
inlineprivate |
Definition at line 1387 of file Geodesic.java.
|
inlineprivate |
Definition at line 1556 of file Geodesic.java.
|
inlineprivate |
Definition at line 1262 of file Geodesic.java.
|
inline |
Set up to compute several points on a single geodesic with all capabilities included.
lat1 | latitude of point 1 (degrees). |
lon1 | longitude of point 1 (degrees). |
azi1 | azimuth at point 1 (degrees). |
lat1 should be in the range [−90°, 90°]. The full set of capabilities is included.
If the point is at a pole, the azimuth is defined by keeping the lon1 fixed, writing lat1 = ±(90 − ε), taking the limit ε → 0+.
Definition at line 1130 of file Geodesic.java.
|
inline |
Set up to compute several points on a single geodesic with a subset of the capabilities included.
lat1 | latitude of point 1 (degrees). |
lon1 | longitude of point 1 (degrees). |
azi1 | azimuth at point 1 (degrees). |
caps | bitor'ed combination of GeodesicMask values specifying the capabilities the GeodesicLine object should possess, i.e., which quantities can be returned in calls to GeodesicLine.Position. |
The GeodesicMask values are
If the point is at a pole, the azimuth is defined by keeping lon1 fixed, writing lat1 = ±(90 − ε), and taking the limit ε → 0+.
Definition at line 1180 of file Geodesic.java.
|
inline |
Definition at line 1188 of file Geodesic.java.
|
inlinestaticprotected |
Definition at line 1229 of file Geodesic.java.
|
protected |
Definition at line 237 of file Geodesic.java.
|
private |
Definition at line 239 of file Geodesic.java.
|
private |
Definition at line 238 of file Geodesic.java.
|
staticprotected |
The order of the expansions used by Geodesic.
Definition at line 207 of file Geodesic.java.
|
staticprivate |
Definition at line 220 of file Geodesic.java.
|
staticprivate |
Definition at line 221 of file Geodesic.java.
|
staticprotected |
Definition at line 209 of file Geodesic.java.
|
staticprotected |
Definition at line 212 of file Geodesic.java.
|
staticprotected |
Definition at line 214 of file Geodesic.java.
Definition at line 215 of file Geodesic.java.
|
staticprotected |
Definition at line 210 of file Geodesic.java.
|
staticprotected |
Definition at line 211 of file Geodesic.java.
|
staticprotected |
Definition at line 213 of file Geodesic.java.
|
staticprotected |
Definition at line 216 of file Geodesic.java.
Definition at line 217 of file Geodesic.java.
|
staticprotected |
Definition at line 218 of file Geodesic.java.
Definition at line 219 of file Geodesic.java.
|
staticprotected |
Definition at line 226 of file Geodesic.java.
|
staticprivate |
Definition at line 227 of file Geodesic.java.
|
staticprivate |
Definition at line 231 of file Geodesic.java.
Definition at line 232 of file Geodesic.java.
Definition at line 234 of file Geodesic.java.
|
static |
A global instantiation of Geodesic with the parameters for the WGS84 ellipsoid.
Definition at line 1207 of file Geodesic.java.
|
staticprivate |
Definition at line 235 of file Geodesic.java.