Class Gnomonic
- java.lang.Object
-
- net.sf.geographiclib.Gnomonic
-
public class Gnomonic extends Object
Gnomonic projection.Note: Gnomonic.java has been ported to Java from its C++ equivalent Gnomonic.cpp, authored by C. F. F. Karney and licensed under MIT/X11 license. The following documentation is mostly the same as for its C++ equivalent, but has been adopted to apply to this Java implementation.
Gnomonic projection centered at an arbitrary position C on the ellipsoid. This projection is derived in Section 8 of
- C. F. F. Karney, Algorithms for geodesics, J. Geodesy 87, 43–55 (2013); DOI: 10.1007/s00190-012-0578-z; addenda: geod-addenda.html.
The gnomonic projection of a point P on the ellipsoid is defined as follows: compute the geodesic line from C to P; compute the reduced length m12, geodesic scale M12, and ρ = m12/M12; finally, this gives the coordinates x and y of P in gnomonic projection with x = ρ sin azi1; y = ρ cos azi1, where azi1 is the azimuth of the geodesic at C. The method
Forward(double, double, double, double)
performs the forward projection andReverse(double, double, double, double)
is the inverse of the projection. The methods also return the azimuth azi of the geodesic at P and reciprocal scale rk in the azimuthal direction. The scale in the radial direction is 1/rk2.For a sphere, ρ reduces to a tan(s12/a), where s12 is the length of the geodesic from C to P, and the gnomonic projection has the property that all geodesics appear as straight lines. For an ellipsoid, this property holds only for geodesics interesting the centers. However geodesic segments close to the center are approximately straight.
Consider a geodesic segment of length l. Let T be the point on the geodesic (extended if necessary) closest to C, the center of the projection, and t, be the distance CT. To lowest order, the maximum deviation (as a true distance) of the corresponding gnomonic line segment (i.e., with the same end points) from the geodesic is
(K(T) − K(C)) l2 t / 32.
where K is the Gaussian curvature.This result applies for any surface. For an ellipsoid of revolution, consider all geodesics whose end points are within a distance r of C. For a given r, the deviation is maximum when the latitude of C is 45°, when endpoints are a distance r away, and when their azimuths from the center are ± 45° or ± 135°. To lowest order in r and the flattening f, the deviation is f (r/2a)3 r.
CAUTION: The definition of this projection for a sphere is standard. However, there is no standard for how it should be extended to an ellipsoid. The choices are:
- Declare that the projection is undefined for an ellipsoid.
- Project to a tangent plane from the center of the ellipsoid. This causes great ellipses to appear as straight lines in the projection; i.e., it generalizes the spherical great circle to a great ellipse. This was proposed by independently by Bowring and Williams in 1997.
- Project to the conformal sphere with the constant of integration chosen so that the values of the latitude match for the center point and perform a central projection onto the plane tangent to the conformal sphere at the center point. This causes normal sections through the center point to appear as straight lines in the projection; i.e., it generalizes the spherical great circle to a normal section. This was proposed by I. G. Letoval'tsev, Generalization of the gnomonic projection for a spheroid and the principal geodetic problems involved in the alignment of surface routes, Geodesy and Aerophotography (5), 271–274 (1963).
- The projection given here. This causes geodesics close to the center point to appear as straight lines in the projection; i.e., it generalizes the spherical great circle to a geodesic.
Example of use:
// Example of using the Gnomonic.java class import net.sf.geographiclib.Geodesic; import net.sf.geographiclib.Gnomonic; import net.sf.geographiclib.GnomonicData; public class ExampleGnomonic { public static void main(String[] args) { Geodesic geod = Geodesic.WGS84; double lat0 = 48 + 50 / 60.0, lon0 = 2 + 20 / 60.0; // Paris Gnomonic gnom = new Gnomonic(geod); { // Sample forward calculation double lat = 50.9, lon = 1.8; // Calais GnomonicData proj = gnom.Forward(lat0, lon0, lat, lon); System.out.println(proj.x + " " + proj.y); } { // Sample reverse calculation double x = -38e3, y = 230e3; GnomonicData proj = gnom.Reverse(lat0, lon0, x, y); System.out.println(proj.lat + " " + proj.lon); } } }
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
EquatorialRadius()
double
Flattening()
GnomonicData
Forward(double lat0, double lon0, double lat, double lon)
Forward projection, from geographic to gnomonic.GnomonicData
Reverse(double lat0, double lon0, double x, double y)
Reverse projection, from gnomonic to geographic.
-
-
-
Method Detail
-
Forward
public GnomonicData Forward(double lat0, double lon0, double lat, double lon)
Forward projection, from geographic to gnomonic.- Parameters:
lat0
- latitude of center point of projection (degrees).lon0
- longitude of center point of projection (degrees).lat
- latitude of point (degrees).lon
- longitude of point (degrees).- Returns:
GnomonicData
object with the following fields: lat0, lon0, lat, lon, x, y, azi, rk.lat0 and lat should be in the range [−90°, 90°] and lon0 and lon should be in the range [−540°, 540°). The scale of the projection is 1/rk2 in the "radial" direction, azi clockwise from true north, and is 1/rk in the direction perpendicular to this. If the point lies "over the horizon", i.e., if rk ≤ 0, then NaNs are returned for x and y (the correct values are returned for azi and rk). A call to Forward followed by a call to Reverse will return the original (lat, lon) (to within roundoff) provided the point in not over the horizon.
-
Reverse
public GnomonicData Reverse(double lat0, double lon0, double x, double y)
Reverse projection, from gnomonic to geographic.- Parameters:
lat0
- latitude of center point of projection (degrees).lon0
- longitude of center point of projection (degrees).x
- easting of point (meters).y
- northing of point (meters).- Returns:
GnomonicData
object with the following fields: lat0, lon0, lat, lon, x, y, azi, rk.lat0 should be in the range [−90°, 90°] and lon0 should be in the range [−540°, 540°). lat will be in the range [−90°, 90°] and lon will be in the range [−180°, 180°]. The scale of the projection is 1/rk2 in the "radial" direction, azi clockwise from true north, and is 1/rk in the direction perpendicular to this. Even though all inputs should return a valid lat and lon, it's possible that the procedure fails to converge for very large x or y; in this case NaNs are returned for all the output arguments. A call to Reverse followed by a call to Forward will return the original (x, y) (to roundoff).
-
EquatorialRadius
public double EquatorialRadius()
- Returns:
- a the equatorial radius of the ellipsoid (meters). This is the value inherited from the Geodesic object used in the constructor.
-
Flattening
public double Flattening()
- Returns:
- f the flattening of the ellipsoid. This is the value inherited from the Geodesic object used in the constructor.
-
-