public class GeodesicLine extends Object
GeodesicLine facilitates the determination of a series of points on a single
geodesic. The starting point (lat1, lon1) and the azimuth
azi1 are specified in the constructor. Position
returns the location of point 2 a distance s12 along the geodesic.
Alternatively ArcPosition gives the position of point 2
an arc length a12 along the geodesic.
The calculations are accurate to better than 15 nm (15 nanometers). 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.
The algorithms are described in
Here's an example of using this class
import net.sf.geographiclib.*;
public class GeodesicLineTest {
public static void main(String[] args) {
// Print waypoints between JFK and SIN
Geodesic geod = Geodesic.WGS84;
double
lat1 = 40.640, lon1 = -73.779, // JFK
lat2 = 1.359, lon2 = 103.989; // SIN
GeodesicData g = geod.Inverse(lat1, lon1, lat2, lon2,
GeodesicMask.DISTANCE | GeodesicMask.AZIMUTH);
GeodesicLine line = new GeodesicLine(geod, lat1, lon1, g.azi1,
GeodesicMask.DISTANCE_IN | GeodesicMask.LONGITUDE);
double
s12 = g.s12,
a12 = g.a12,
ds0 = 500e3; // Nominal distance between points = 500 km
int num = (int)(Math.ceil(s12 / ds0)); // The number of intervals
{
// Use intervals of equal length
double ds = s12 / num;
for (int i = 0; i <= num; ++i) {
g = line.Position(i * ds,
GeodesicMask.LATITUDE | GeodesicMask.LONGITUDE);
System.out.println(i + " " + g.lat2 + " " + g.lon2);
}
}
{
// Slightly faster, use intervals of equal arc length
double da = a12 / num;
for (int i = 0; i <= num; ++i) {
g = line.ArcPosition(i * da,
GeodesicMask.LATITUDE | GeodesicMask.LONGITUDE);
System.out.println(i + " " + g.lat2 + " " + g.lon2);
}
}
}
}| Constructor and Description |
|---|
GeodesicLine(Geodesic g,
double lat1,
double lon1,
double azi1)
Constructor for a geodesic line staring at latitude lat1, longitude
lon1, and azimuth azi1 (all in degrees).
|
GeodesicLine(Geodesic g,
double lat1,
double lon1,
double azi1,
int caps)
Constructor for a geodesic line staring at latitude lat1, longitude
lon1, and azimuth azi1 (all in degrees) with a subset of the
capabilities included.
|
| Modifier and Type | Method and Description |
|---|---|
GeodesicData |
ArcPosition(double a12)
Compute the position of point 2 which is an arc length a12
(degrees) from point 1.
|
GeodesicData |
ArcPosition(double a12,
int outmask)
Compute the position of point 2 which is an arc length a12
(degrees) from point 1 and with a subset of the geodesic results returned.
|
double |
Azimuth() |
int |
Capabilities() |
boolean |
Capabilities(int testcaps) |
double |
EquatorialArc() |
double |
EquatorialAzimuth() |
double |
Flattening() |
double |
Latitude() |
double |
Longitude() |
double |
MajorRadius() |
GeodesicData |
Position(boolean arcmode,
double s12_a12,
int outmask)
The general position function.
|
GeodesicData |
Position(double s12)
Compute the position of point 2 which is a distance s12 (meters)
from point 1.
|
GeodesicData |
Position(double s12,
int outmask)
Compute the position of point 2 which is a distance s12 (meters)
from point 1 and with a subset of the geodesic results returned.
|
public GeodesicLine(Geodesic g, double lat1, double lon1, double azi1)
g - A Geodesic object used to compute the necessary
information about the GeodesicLine.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°].
If the point is at a pole, the azimuth is defined by keeping lon1 fixed, writing lat1 = ±(90° − ε), and taking the limit ε → 0+.
public GeodesicLine(Geodesic g, double lat1, double lon1, double azi1, int caps)
g - A Geodesic object used to compute the necessary
information about the GeodesicLine.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 Position.
The GeodesicMask values are
public GeodesicData Position(double s12)
s12 - distance between point 1 and point 2 (meters); it can be
negative.GeodesicData object with the following fields:
lat1, lon1, azi1, lat2, lon2,
azi2, s12, a12. Some of these results may be
missing if the GeodesicLine did not include the relevant capability.
The values of lon2 and azi2 returned are in the range [−180°, 180°).
The GeodesicLine object must have been constructed with caps
|= GeodesicMask.DISTANCE_IN; otherwise no parameters are set.
public GeodesicData Position(double s12, int outmask)
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.GeodesicData object including the requested results.
The GeodesicLine object must have been constructed with caps
|= GeodesicMask.DISTANCE_IN; otherwise no parameters are set.
Requesting a value which the GeodesicLine object is not capable of
computing is not an error (no parameters will be set). The value of
lon2 returned is normally in the range [−180°, 180°);
however if the outmask includes the
GeodesicMask.LONG_UNROLL flag, the longitude is "unrolled" so that
the quantity lon2 − lon1 indicates how many times and
in what sense the geodesic encircles the ellipsoid.
public GeodesicData ArcPosition(double a12)
a12 - arc length between point 1 and point 2 (degrees); it can
be negative.GeodesicData object with the following fields:
lat1, lon1, azi1, lat2, lon2,
azi2, s12, a12. Some of these results may be
missing if the GeodesicLine did not include the relevant capability.
The values of lon2 and azi2 returned are in the range [−180°, 180°).
The GeodesicLine object must have been constructed with caps
|= GeodesicMask.DISTANCE_IN; otherwise no parameters are set.
public GeodesicData ArcPosition(double a12, int outmask)
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.GeodesicData object giving lat1, lon2,
azi2, and a12.
The GeodesicLine object must have been constructed with caps
|= GeodesicMask.DISTANCE_IN; otherwise no parameters are set.
Requesting a value which the GeodesicLine object is not capable of
computing is not an error (no parameters will be set). The value of
lon2 returned is in the range [−180°, 180°), unless
the outmask includes the GeodesicMask.LONG_UNROLL flag.
public GeodesicData Position(boolean arcmode, double s12_a12, int outmask)
Position
and ArcPosition are defined in terms of
this function.
arcmode - boolean flag determining the meaning of the second
parameter; if arcmode is false, then the GeodesicLine object must have
been constructed with caps |= GeodesicMask.DISTANCE_IN.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.GeodesicData object with the requested results.
The GeodesicMask values possible for outmask are
Requesting a value which the GeodesicLine object is not capable of computing is not an error; Double.NaN is returned instead.
public double Latitude()
public double Longitude()
public double Azimuth()
public double EquatorialAzimuth()
public double EquatorialArc()
public double MajorRadius()
public double Flattening()
public int Capabilities()
public boolean Capabilities(int testcaps)
testcaps - a set of bitor'ed GeodesicMask values.Copyright © 2015. All Rights Reserved.