Public Types | Friends

GeographicLib::GeodesicLine Class Reference

A geodesic line. More...

#include <GeographicLib/GeodesicLine.hpp>

List of all members.

Public Types

enum  mask {
  NONE, LATITUDE, LONGITUDE, AZIMUTH,
  DISTANCE, DISTANCE_IN, REDUCEDLENGTH, GEODESICSCALE,
  AREA, ALL
}

Public Member Functions

Constructors

 GeodesicLine (const Geodesic &g, real lat1, real lon1, real azi1, unsigned caps=ALL) throw ()
 GeodesicLine () throw ()
Position in terms of distance

Math::real Position (real s12, real &lat2, real &lon2, real &azi2, real &m12, real &M12, real &M21, real &S12) const throw ()
Math::real Position (real s12, real &lat2, real &lon2) const throw ()
Math::real Position (real s12, real &lat2, real &lon2, real &azi2) const throw ()
Math::real Position (real s12, real &lat2, real &lon2, real &azi2, real &m12) const throw ()
Math::real Position (real s12, real &lat2, real &lon2, real &azi2, real &M12, real &M21) const throw ()
Math::real Position (real s12, real &lat2, real &lon2, real &azi2, real &m12, real &M12, real &M21) const throw ()
Position in terms of arc length

void ArcPosition (real a12, real &lat2, real &lon2, real &azi2, real &s12, real &m12, real &M12, real &M21, real &S12) const throw ()
void ArcPosition (real a12, real &lat2, real &lon2) const throw ()
void ArcPosition (real a12, real &lat2, real &lon2, real &azi2) const throw ()
void ArcPosition (real a12, real &lat2, real &lon2, real &azi2, real &s12) const throw ()
void ArcPosition (real a12, real &lat2, real &lon2, real &azi2, real &s12, real &m12) const throw ()
void ArcPosition (real a12, real &lat2, real &lon2, real &azi2, real &s12, real &M12, real &M21) const throw ()
void ArcPosition (real a12, real &lat2, real &lon2, real &azi2, real &s12, real &m12, real &M12, real &M21) const throw ()
The general position function.

Math::real GenPosition (bool arcmode, real s12_a12, unsigned outmask, real &lat2, real &lon2, real &azi2, real &s12, real &m12, real &M12, real &M21, real &S12) const throw ()
Inspector functions

bool Init () const throw ()
Math::real Latitude () const throw ()
Math::real Longitude () const throw ()
Math::real Azimuth () const throw ()
Math::real EquatorialAzimuth () const throw ()
Math::real EquatorialArc () const throw ()
Math::real MajorRadius () const throw ()
Math::real InverseFlattening () const throw ()
unsigned Capabilities () const throw ()
bool Capabilities (unsigned testcaps) const throw ()
Deprecated Functions

Math::real Position (real s12, real &lat2, real &lon2, real &azi2, real &m12, bool arcmode) const throw ()
void Scale (real a12, real &M12, real &M21) const throw ()

Friends

class Geodesic

Detailed Description

A geodesic line.

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. GeodesicLine.Position returns the location of point 2 a distance s12 along the geodesic. Alternatively GeodesicLine.ArcPosition gives the position of point 2 an arc length a12 along the geodesic. An example of use of this class is:

   #include <iostream>
   #include <iomanip>
   #include <cmath>
   #include "GeographicLib/Geodesic.hpp"
   #include "GeographicLib/GeodesicLine.hpp"

   int main() {
     // Print waypoints between JFK and SIN at
     // approximately 100km intervals.
     double
       lat1 = 40.640, lon1 = -73.779, // JFK
       lat2 = 1.359, lon2 = 177.486;  // SIN
     const GeographicLib::Geodesic&
       g = GeographicLib::Geodesic::WGS84;
     double azi1, azi2,
       a12 = g.Inverse(lat1, lon1, lat2, lon2, azi1, azi2);
     double ds = 100e3;  // Nominal distance between points = 100 km
     int num = std::ceil(a12/ (90 * ds / 10e6)); // 90 deg = 10e6 m
     double da = a12/num;              // Arc length between points
     const GeographicLib::GeodesicLine l(g, lat1, lon1, azi1);
     std::cout << std::fixed << std::setprecision(3);
     for (int i = 0; i <= num; ++i) {
       double lat, lon;
       l.ArcPosition(i * da, lat, lon);
       std::cout << lat << " " << lon << "\n";
     }
   }

The default copy constructor and assignment operators work with this class, so that, for example, the previous example could start

       GeographicLib::GeodesicLine l;
       l = g.Line(lat1, lon1, azi1);

Similarly, a vector can be used to hold GeodesicLine objects.

The calculations are accurate to better than 15 nm. See Sec. 9 of arXiv:1102.1215 for details.

The algorithms are described in

For more information on geodesics see Geodesics on the Ellipsoid.

Definition at line 78 of file GeodesicLine.hpp.


Member Enumeration Documentation

Bit masks for what calculations to do. These masks do double duty. They signify to the GeodesicLine::GeodesicLine constructor and to Geodesic::Line what capabilities should be included in the GeodesicLine object. They also specify which results to return in the general routines Geodesic::GenDirect and Geodesic::GenInverse routines. This is merely a duplication of Geodesic::mask.

Enumerator:
NONE 

No capabilities, no output.

LATITUDE 

Calculate latitude lat2. (It's not necessary to include this as a capability to GeodesicLine because this is included by default.)

LONGITUDE 

Calculate longitude lon2.

AZIMUTH 

Calculate azimuths azi1 and azi2. (It's not necessary to include this as a capability to GeodesicLine because this is included by default.)

DISTANCE 

Calculate distance s12.

DISTANCE_IN 

Allow distance s12 to be used as input in the direct geodesic problem.

REDUCEDLENGTH 

Calculate reduced length m12.

GEODESICSCALE 

Calculate geodesic scales M12 and M21.

AREA 

Calculate area S12.

ALL 

All capabilities. Calculate everything.

Definition at line 116 of file GeodesicLine.hpp.


Constructor & Destructor Documentation

GeographicLib::GeodesicLine::GeodesicLine ( const Geodesic g,
real  lat1,
real  lon1,
real  azi1,
unsigned  caps = ALL 
) throw ()

Constructor for a geodesic line staring at latitude lat1, longitude lon1, and aziumuth azi1 (all in degrees).

Parameters:
[in] g A Geodesic object used to compute the necessary information about the GeodesicLine.
[in] lat1 latitude of point 1 (degrees).
[in] lon1 longitude of point 1 (degrees).
[in] azi1 azimuth at point 1 (degrees).
[in] caps bitor'ed combination of GeodesicLine::mask values specifying the capabilities the GeodesicLine object should possess, i.e., which quantities can be returned in calls to GeodesicLib::Position.

The GeodesicLine::mask values are

The default value of caps is GeodesicLine::ALL which turns on all the capabilities.

If the point is at a pole, the azimuth is defined by keeping the lon1 fixed and writing lat1 = 90 - eps or -90 + eps and taking the limit eps -> 0 from above.

Definition at line 40 of file GeodesicLine.cpp.

GeographicLib::GeodesicLine::GeodesicLine (  )  throw () [inline]

A default constructor. If GeodesicLine::Position is called on the resulting object, it returns immediately (without doing any calculations). The object can be set with a call to Geodesic::Line. Use Init() to test whether object is still in this uninitialized state.

Definition at line 224 of file GeodesicLine.hpp.


Member Function Documentation

Math::real GeographicLib::GeodesicLine::Position ( real  s12,
real &  lat2,
real &  lon2,
real &  azi2,
real &  m12,
real &  M12,
real &  M21,
real &  S12 
) const throw () [inline]

Compute the position of point 2 which is a distance s12 (meters) from point 1.

Parameters:
[in] s12 distance between point 1 and point 2 (meters); it can be signed.
[out] lat2 latitude of point 2 (degrees).
[out] lon2 longitude of point 2 (degrees); requires that the GeodesicLine object was constructed with caps |= GeodesicLine::LONGITUDE.
[out] azi2 (forward) azimuth at point 2 (degrees).
[out] m12 reduced length of geodesic (meters); requires that the GeodesicLine object was constructed with caps |= GeodesicLine::REDUCEDLENGTH.
[out] M12 geodesic scale of point 2 relative to point 1 (dimensionless); requires that the GeodesicLine object was constructed with caps |= GeodesicLine::GEODESICSCALE.
[out] M21 geodesic scale of point 1 relative to point 2 (dimensionless); requires that the GeodesicLine object was constructed with caps |= GeodesicLine::GEODESICSCALE.
[out] S12 area under the geodesic (meters2); requires that the GeodesicLine object was constructed with caps |= GeodesicLine::AREA.
Returns:
a12 arc length of between point 1 and point 2 (degrees).

The GeodesicLine object must have been constructed with caps |= GeodesicLine::DISTANCE_IN; otherwise Math::NaN() is returned and no parameters are set. Requesting a value which the GeodesicLine object is not capable of computing is not an error; the corresponding argument will not be altered.

The following functions are overloaded versions of GeodesicLine::Position which omit some of the output parameters. Note, however, that the arc length is always computed and returned as the function value.

Definition at line 267 of file GeodesicLine.hpp.

References AREA, AZIMUTH, GenPosition(), GEODESICSCALE, LATITUDE, LONGITUDE, and REDUCEDLENGTH.

Referenced by Position().

Math::real GeographicLib::GeodesicLine::Position ( real  s12,
real &  lat2,
real &  lon2 
) const throw () [inline]

See the documentation for GeodesicLine::Position.

Definition at line 281 of file GeodesicLine.hpp.

References GenPosition(), LATITUDE, and LONGITUDE.

Math::real GeographicLib::GeodesicLine::Position ( real  s12,
real &  lat2,
real &  lon2,
real &  azi2 
) const throw () [inline]

See the documentation for GeodesicLine::Position.

Definition at line 291 of file GeodesicLine.hpp.

References AZIMUTH, GenPosition(), LATITUDE, and LONGITUDE.

Math::real GeographicLib::GeodesicLine::Position ( real  s12,
real &  lat2,
real &  lon2,
real &  azi2,
real &  m12 
) const throw () [inline]

See the documentation for GeodesicLine::Position.

Definition at line 302 of file GeodesicLine.hpp.

References AZIMUTH, GenPosition(), LATITUDE, LONGITUDE, and REDUCEDLENGTH.

Math::real GeographicLib::GeodesicLine::Position ( real  s12,
real &  lat2,
real &  lon2,
real &  azi2,
real &  M12,
real &  M21 
) const throw () [inline]

See the documentation for GeodesicLine::Position.

Definition at line 314 of file GeodesicLine.hpp.

References AZIMUTH, GenPosition(), GEODESICSCALE, LATITUDE, and LONGITUDE.

Math::real GeographicLib::GeodesicLine::Position ( real  s12,
real &  lat2,
real &  lon2,
real &  azi2,
real &  m12,
real &  M12,
real &  M21 
) const throw () [inline]

See the documentation for GeodesicLine::Position.

Definition at line 327 of file GeodesicLine.hpp.

References AZIMUTH, GenPosition(), GEODESICSCALE, LATITUDE, LONGITUDE, and REDUCEDLENGTH.

void GeographicLib::GeodesicLine::ArcPosition ( real  a12,
real &  lat2,
real &  lon2,
real &  azi2,
real &  s12,
real &  m12,
real &  M12,
real &  M21,
real &  S12 
) const throw () [inline]

Compute the position of point 2 which is an arc length a12 (degrees) from point 1.

Parameters:
[in] a12 arc length between point 1 and point 2 (degrees); it can be signed.
[out] lat2 latitude of point 2 (degrees).
[out] lon2 longitude of point 2 (degrees); requires that the GeodesicLine object was constructed with caps |= GeodesicLine::LONGITUDE.
[out] azi2 (forward) azimuth at point 2 (degrees).
[out] s12 distance between point 1 and point 2 (meters); requires that the GeodesicLine object was constructed with caps |= GeodesicLine::DISTANCE.
[out] m12 reduced length of geodesic (meters); requires that the GeodesicLine object was constructed with caps |= GeodesicLine::REDUCEDLENGTH.
[out] M12 geodesic scale of point 2 relative to point 1 (dimensionless); requires that the GeodesicLine object was constructed with caps |= GeodesicLine::GEODESICSCALE.
[out] M21 geodesic scale of point 1 relative to point 2 (dimensionless); requires that the GeodesicLine object was constructed with caps |= GeodesicLine::GEODESICSCALE.
[out] S12 area under the geodesic (meters2); requires that the GeodesicLine object was constructed with caps |= GeodesicLine::AREA.

Requesting a value which the GeodesicLine object is not capable of computing is not an error; the corresponding argument will not be altered.

The following functions are overloaded versions of GeodesicLine::ArcPosition which omit some of the output parameters.

Definition at line 378 of file GeodesicLine.hpp.

References AREA, AZIMUTH, DISTANCE, GenPosition(), GEODESICSCALE, LATITUDE, LONGITUDE, and REDUCEDLENGTH.

Referenced by Position(), and Scale().

void GeographicLib::GeodesicLine::ArcPosition ( real  a12,
real &  lat2,
real &  lon2 
) const throw () [inline]

See the documentation for GeodesicLine::ArcPosition.

Definition at line 390 of file GeodesicLine.hpp.

References GenPosition(), LATITUDE, and LONGITUDE.

void GeographicLib::GeodesicLine::ArcPosition ( real  a12,
real &  lat2,
real &  lon2,
real &  azi2 
) const throw () [inline]

See the documentation for GeodesicLine::ArcPosition.

Definition at line 401 of file GeodesicLine.hpp.

References AZIMUTH, GenPosition(), LATITUDE, and LONGITUDE.

void GeographicLib::GeodesicLine::ArcPosition ( real  a12,
real &  lat2,
real &  lon2,
real &  azi2,
real &  s12 
) const throw () [inline]

See the documentation for GeodesicLine::ArcPosition.

Definition at line 413 of file GeodesicLine.hpp.

References AZIMUTH, DISTANCE, GenPosition(), LATITUDE, and LONGITUDE.

void GeographicLib::GeodesicLine::ArcPosition ( real  a12,
real &  lat2,
real &  lon2,
real &  azi2,
real &  s12,
real &  m12 
) const throw () [inline]

See the documentation for GeodesicLine::ArcPosition.

Definition at line 424 of file GeodesicLine.hpp.

References AZIMUTH, DISTANCE, GenPosition(), LATITUDE, LONGITUDE, and REDUCEDLENGTH.

void GeographicLib::GeodesicLine::ArcPosition ( real  a12,
real &  lat2,
real &  lon2,
real &  azi2,
real &  s12,
real &  M12,
real &  M21 
) const throw () [inline]

See the documentation for GeodesicLine::ArcPosition.

Definition at line 436 of file GeodesicLine.hpp.

References AZIMUTH, DISTANCE, GenPosition(), GEODESICSCALE, LATITUDE, and LONGITUDE.

void GeographicLib::GeodesicLine::ArcPosition ( real  a12,
real &  lat2,
real &  lon2,
real &  azi2,
real &  s12,
real &  m12,
real &  M12,
real &  M21 
) const throw () [inline]

See the documentation for GeodesicLine::ArcPosition.

Definition at line 449 of file GeodesicLine.hpp.

References AZIMUTH, DISTANCE, GenPosition(), GEODESICSCALE, LATITUDE, LONGITUDE, and REDUCEDLENGTH.

Math::real GeographicLib::GeodesicLine::GenPosition ( bool  arcmode,
real  s12_a12,
unsigned  outmask,
real &  lat2,
real &  lon2,
real &  azi2,
real &  s12,
real &  m12,
real &  M12,
real &  M21,
real &  S12 
) const throw ()

The general position function. GeodesicLine::Position and GeodesicLine::ArcPosition are defined in terms of this function.

Parameters:
[in] arcmode boolean flag determining the meaning of the second parameter; if arcmode is false, then the GeodesicLine object must have been constructed with caps |= GeodesicLine::DISTANCE_IN.
[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 signed.
[in] outmask a bitor'ed combination of GeodesicLine::mask values specifying which of the following parameters should be set.
[out] lat2 latitude of point 2 (degrees).
[out] lon2 longitude of point 2 (degrees); requires that the GeodesicLine object was constructed with caps |= GeodesicLine::LONGITUDE.
[out] azi2 (forward) azimuth at point 2 (degrees).
[out] s12 distance between point 1 and point 2 (meters); requires that the GeodesicLine object was constructed with caps |= GeodesicLine::DISTANCE.
[out] m12 reduced length of geodesic (meters); requires that the GeodesicLine object was constructed with caps |= GeodesicLine::REDUCEDLENGTH.
[out] M12 geodesic scale of point 2 relative to point 1 (dimensionless); requires that the GeodesicLine object was constructed with caps |= GeodesicLine::GEODESICSCALE.
[out] M21 geodesic scale of point 1 relative to point 2 (dimensionless); requires that the GeodesicLine object was constructed with caps |= GeodesicLine::GEODESICSCALE.
[out] S12 area under the geodesic (meters2); requires that the GeodesicLine object was constructed with caps |= GeodesicLine::AREA.
Returns:
a12 arc length of between point 1 and point 2 (degrees).

The GeodesicLine::mask values possible for outmask are

Requesting a value which the GeodesicLine object is not capable of computing is not an error; the corresponding argument will not be altered. Note, however, that the arc length is always computed and returned as the function value.

Definition at line 128 of file GeodesicLine.cpp.

Referenced by ArcPosition(), and Position().

bool GeographicLib::GeodesicLine::Init (  )  const throw () [inline]
Returns:
true if the object has been initialized.

Definition at line 528 of file GeodesicLine.hpp.

Referenced by Azimuth(), EquatorialArc(), EquatorialAzimuth(), GeographicLib::CassiniSoldner::Init(), InverseFlattening(), Latitude(), Longitude(), and MajorRadius().

Math::real GeographicLib::GeodesicLine::Latitude (  )  const throw () [inline]
Returns:
lat1 the latitude of point 1 (degrees).

Definition at line 533 of file GeodesicLine.hpp.

References Init().

Referenced by GeographicLib::CassiniSoldner::LatitudeOrigin().

Math::real GeographicLib::GeodesicLine::Longitude (  )  const throw () [inline]
Returns:
lon1 the longitude of point 1 (degrees).

Definition at line 538 of file GeodesicLine.hpp.

References Init().

Referenced by GeographicLib::CassiniSoldner::LongitudeOrigin().

Math::real GeographicLib::GeodesicLine::Azimuth (  )  const throw () [inline]
Returns:
azi1 the azimuth (degrees) of the geodesic line at point 1.

Definition at line 543 of file GeodesicLine.hpp.

References Init().

Math::real GeographicLib::GeodesicLine::EquatorialAzimuth (  )  const throw () [inline]
Returns:
azi0 the azimuth (degrees) of the geodesic line as it crosses the equator in a northward direction.

Definition at line 549 of file GeodesicLine.hpp.

References Init().

Math::real GeographicLib::GeodesicLine::EquatorialArc (  )  const throw () [inline]
Returns:
a1 the arc length (degrees) between the northward equatorial crossing and point 1.

Definition at line 557 of file GeodesicLine.hpp.

References Init().

Math::real GeographicLib::GeodesicLine::MajorRadius (  )  const throw () [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 565 of file GeodesicLine.hpp.

References Init().

Math::real GeographicLib::GeodesicLine::InverseFlattening (  )  const throw () [inline]
Returns:
r the inverse flattening of the ellipsoid. This is the value inherited from the Geodesic object used in the constructor. A value of 0 is returned for a sphere (infinite inverse flattening).

Definition at line 572 of file GeodesicLine.hpp.

References Init().

unsigned GeographicLib::GeodesicLine::Capabilities (  )  const throw () [inline]
Returns:
caps the computational capabilities that this object was constructed with. LATITUDE and AZIMUTH are always included.

Definition at line 578 of file GeodesicLine.hpp.

bool GeographicLib::GeodesicLine::Capabilities ( unsigned  testcaps  )  const throw () [inline]
Parameters:
[in] testcaps a set of bitor'ed GeodesicLine::mask values.
Returns:
true if the GeodesicLine object has all these capabilities.

Definition at line 584 of file GeodesicLine.hpp.

Math::real GeographicLib::GeodesicLine::Position ( real  s12,
real &  lat2,
real &  lon2,
real &  azi2,
real &  m12,
bool  arcmode 
) const throw () [inline]

DEPRECATED. Return the latitude, lat2, longitude, lon2, and forward azimuth, azi2 (degrees) of the point 2 which is a distance, s12 (in meters), from point 1. Also return the reduced length m12 (meters). s12 can be signed. If arcmode (default false) is set to true, s12 is interpreted as the arc length a12 (in degrees) on the auxiliary sphere. Returned value is the arc length a12 (degrees) if arcmode is false, otherwise it is the distance s12 (meters).

Definition at line 604 of file GeodesicLine.hpp.

References ArcPosition(), and Position().

void GeographicLib::GeodesicLine::Scale ( real  a12,
real &  M12,
real &  M21 
) const throw () [inline]

DEPRECATED. Return the scale of the geodesic line extending an arc length a12 (degrees) from point 1 to point 2. M12 (a number) measures the convergence of initially parallel geodesics. It is defined by the following construction: starting at point 1 proceed at azimuth azi1 + 90o a small distance dt; turn -90o and proceed a distance s12 (not the arc length a12); the distance to point 2 is given by M12 dt. M21 is defined analogously.

Definition at line 624 of file GeodesicLine.hpp.

References ArcPosition().


Friends And Related Function Documentation

friend class Geodesic [friend]

Definition at line 81 of file GeodesicLine.hpp.


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