GeographicLib::Gnomonic Class Reference

Gnomonic projection More...

`#include <GeographicLib/Gnomonic.hpp>`

## Public Member Functions

| Gnomonic (const Geodesic &earth=Geodesic::WGS84())
void | Forward (real lat0, real lon0, real lat, real lon, real &x, real &y, real &azi, real &rk) const
void | Reverse (real lat0, real lon0, real x, real y, real &lat, real &lon, real &azi, real &rk) const
void | Forward (real lat0, real lon0, real lat, real lon, real &x, real &y) const
void | Reverse (real lat0, real lon0, real x, real y, real &lat, real &lon) const
Inspector functions
Math::real | EquatorialRadius () const
Math::real | Flattening () const

## Detailed Description

Gnomonic projection

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 projection of P is defined as follows: compute the geodesic line from C to P; compute the reduced length m12, geodesic scale M12, and ρ = m12/M12; finally x = ρ sin azi1; y = ρ cos azi1, where azi1 is the azimuth of the geodesic at C. The Gnomonic::Forward and Gnomonic::Reverse 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 if 1/rk2.

For a sphere, ρ is 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.

The conversions all take place using a Geodesic object (by default Geodesic::WGS84()). For more information on geodesics see Geodesics on an ellipsoid of revolution.

Warning
  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 GeographicLib::Gnomonic class
#include <iostream>
#include <exception>
#include <GeographicLib/Geodesic.hpp>
#include <GeographicLib/Gnomonic.hpp>
using namespace std;
using namespace GeographicLib;
int main() {
try {
Geodesic geod(Constants::WGS84_a(), Constants::WGS84_f());
// Alternatively: const Geodesic& geod = Geodesic::WGS84();
const double lat0 = 48 + 50/60.0, lon0 = 2 + 20/60.0; // Paris
Gnomonic proj(geod);
{
// Sample forward calculation
double lat = 50.9, lon = 1.8; // Calais
double x, y;
proj.Forward(lat0, lon0, lat, lon, x, y);
cout << x << " " << y << "\n";
}
{
// Sample reverse calculation
double x = -38e3, y = 230e3;
double lat, lon;
proj.Reverse(lat0, lon0, x, y, lat, lon);
cout << lat << " " << lon << "\n";
}
}
catch (const exception& e) {
cerr << "Caught exception: " << e.what() << "\n";
return 1;
}
}
main
int main(int argc, const char *const argv[])
Definition: CartConvert.cpp:29
Geodesic.hpp
Header for GeographicLib::Geodesic class.
Gnomonic.hpp
Header for GeographicLib::Gnomonic class.
GeographicLib::Constants::WGS84_f
static T WGS84_f()
Definition: Constants.hpp:141
GeographicLib::Constants::WGS84_a
static T WGS84_a()
Definition: Constants.hpp:135
GeographicLib::Gnomonic::Gnomonic
Gnomonic(const Geodesic &earth=Geodesic::WGS84())
Definition: Gnomonic.cpp:22
GeographicLib
Namespace for GeographicLib.
Definition: Accumulator.cpp:12
std
Definition: NearestNeighbor.hpp:812

GeodesicProj is a command-line utility providing access to the functionality of AzimuthalEquidistant, Gnomonic, and CassiniSoldner.

Definition at line 102 of file Gnomonic.hpp.

## Constructor & Destructor Documentation

## Gnomonic()

GeographicLib::Gnomonic::Gnomonic | ( | const Geodesic & | earth = `Geodesic::WGS84()` | ) |

explicit

Constructor for Gnomonic.

Parameters

  [in] | earth | the Geodesic object to use for geodesic calculations. By default this uses the WGS84 ellipsoid.

Definition at line 22 of file Gnomonic.cpp.

## Member Function Documentation

## Forward() [1/2]

void GeographicLib::Gnomonic::Forward | ( | real | lat0,
|  | real | lon0,
|  | real | lat,
|  | real | lon,
|  | real & | x,
|  | real & | y,
|  | real & | azi,
|  | real & | rk
| ) |  | const

Forward projection, from geographic to gnomonic.

Parameters

  [in] | lat0 | latitude of center point of projection (degrees).
  [in] | lon0 | longitude of center point of projection (degrees).
  [in] | lat | latitude of point (degrees).
  [in] | lon | longitude of point (degrees).
  [out] | x | easting of point (meters).
  [out] | y | northing of point (meters).
  [out] | azi | azimuth of geodesic at point (degrees).
  [out] | rk | reciprocal of azimuthal scale at point.

lat0 and lat should be in the range [−90°, 90°]. 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.

Definition at line 30 of file Gnomonic.cpp.

References GeographicLib::Geodesic::AZIMUTH, GeographicLib::Geodesic::GEODESICSCALE, GeographicLib::Math::NaN(), GeographicLib::Geodesic::REDUCEDLENGTH, and GeographicLib::Math::sincosd().

Referenced by main().

## Reverse() [1/2]

void GeographicLib::Gnomonic::Reverse | ( | real | lat0,
|  | real | lon0,
|  | real | x,
|  | real | y,
|  | real & | lat,
|  | real & | lon,
|  | real & | azi,
|  | real & | rk
| ) |  | const

Reverse projection, from gnomonic to geographic.

Parameters

  [in] | lat0 | latitude of center point of projection (degrees).
  [in] | lon0 | longitude of center point of projection (degrees).
  [in] | x | easting of point (meters).
  [in] | y | northing of point (meters).
  [out] | lat | latitude of point (degrees).
  [out] | lon | longitude of point (degrees).
  [out] | azi | azimuth of geodesic at point (degrees).
  [out] | rk | reciprocal of azimuthal scale at point.

lat0 should be in the range [−90°, 90°]. 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).

Definition at line 47 of file Gnomonic.cpp.

References GeographicLib::Math::atan2d(), GeographicLib::Geodesic::AZIMUTH, GeographicLib::Geodesic::DISTANCE_IN, GeographicLib::Geodesic::GEODESICSCALE, GEOGRAPHICLIB_PANIC, GeographicLib::Geodesic::LATITUDE, GeographicLib::Geodesic::Line(), GeographicLib::Geodesic::LONGITUDE, GeographicLib::Math::NaN(), GeographicLib::GeodesicLine::Position(), and GeographicLib::Geodesic::REDUCEDLENGTH.

Referenced by main().

## Forward() [2/2]

void GeographicLib::Gnomonic::Forward | ( | real | lat0,
|  | real | lon0,
|  | real | lat,
|  | real | lon,
|  | real & | x,
|  | real & | y
| ) |  | const

inline

Gnomonic::Forward without returning the azimuth and scale.

Definition at line 180 of file Gnomonic.hpp.

## Reverse() [2/2]

void GeographicLib::Gnomonic::Reverse | ( | real | lat0,
|  | real | lon0,
|  | real | x,
|  | real | y,
|  | real & | lat,
|  | real & | lon
| ) |  | const

inline

Gnomonic::Reverse without returning the azimuth and scale.

Definition at line 189 of file Gnomonic.hpp.

## EquatorialRadius()

Math::real GeographicLib::Gnomonic::EquatorialRadius | ( |  | ) | const

inline

Returns
  a the equatorial radius of the ellipsoid (meters). This is the value inherited from the Geodesic object used in the constructor.

Definition at line 202 of file Gnomonic.hpp.

References GeographicLib::Geodesic::EquatorialRadius().

## Flattening()

Math::real GeographicLib::Gnomonic::Flattening | ( |  | ) | const

inline

Returns
  f the flattening of the ellipsoid. This is the value inherited from the Geodesic object used in the constructor.

Definition at line 208 of file Gnomonic.hpp.

References GeographicLib::Geodesic::Flattening().

The documentation for this class was generated from the following files:

- Gnomonic.hpp
- Gnomonic.cpp