GeographicLib  1.37
Public Types | Friends | List of all members
GeographicLib::GeodesicLineExact Class Reference

An exact geodesic line. More...

#include <GeographicLib/GeodesicLineExact.hpp>

Public Types

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

Public Member Functions

Constructors
 GeodesicLineExact (const GeodesicExact &g, real lat1, real lon1, real azi1, unsigned caps=ALL)
 
 GeodesicLineExact ()
 
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
 
Math::real Position (real s12, real &lat2, real &lon2) const
 
Math::real Position (real s12, real &lat2, real &lon2, real &azi2) const
 
Math::real Position (real s12, real &lat2, real &lon2, real &azi2, real &m12) const
 
Math::real Position (real s12, real &lat2, real &lon2, real &azi2, real &M12, real &M21) const
 
Math::real Position (real s12, real &lat2, real &lon2, real &azi2, real &m12, real &M12, real &M21) const
 
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
 
void ArcPosition (real a12, real &lat2, real &lon2) const
 
void ArcPosition (real a12, real &lat2, real &lon2, real &azi2) const
 
void ArcPosition (real a12, real &lat2, real &lon2, real &azi2, real &s12) const
 
void ArcPosition (real a12, real &lat2, real &lon2, real &azi2, real &s12, real &m12) const
 
void ArcPosition (real a12, real &lat2, real &lon2, real &azi2, real &s12, real &M12, real &M21) const
 
void ArcPosition (real a12, real &lat2, real &lon2, real &azi2, real &s12, real &m12, real &M12, real &M21) const
 
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
 
Inspector functions
bool Init () const
 
Math::real Latitude () const
 
Math::real Longitude () const
 
Math::real Azimuth () const
 
Math::real EquatorialAzimuth () const
 
Math::real EquatorialArc () const
 
Math::real MajorRadius () const
 
Math::real Flattening () const
 
unsigned Capabilities () const
 
bool Capabilities (unsigned testcaps) const
 

Friends

class GeodesicExact
 

Detailed Description

An exact geodesic line.

GeodesicLineExact facilitates the determination of a series of points on a single geodesic. This is a companion to the GeodesicExact class. For additional information on this class see the documentation on the GeodesicLine class.

Example of use:

// Example of using the GeographicLib::GeodesicLineExact class
#include <iostream>
#include <exception>
#include <cmath>
#include <iomanip>
using namespace std;
using namespace GeographicLib;
int main() {
try {
// Print waypoints between JFK and SIN
// Alternatively: const GeodesicExact& geod = GeodesicExact::WGS84();
double
lat1 = 40.640, lon1 = -73.779, // JFK
lat2 = 1.359, lon2 = 103.989; // SIN
double s12, azi1, azi2,
a12 = geod.Inverse(lat1, lon1, lat2, lon2, s12, azi1, azi2);
const GeographicLib::GeodesicLineExact line(geod, lat1, lon1, azi1);
// Alternatively
// const GeographicLib::GeodesicLineExact line = geod.Line(lat1,lon1,azi1);
double ds = 500e3; // Nominal distance between points = 500 km
int num = int(ceil(s12 / ds)); // The number of intervals
cout << fixed << setprecision(3);
{
// Use intervals of equal length
double ds = s12 / num;
for (int i = 0; i <= num; ++i) {
double lat, lon;
line.Position(i * ds, lat, lon);
cout << i << " " << lat << " " << lon << "\n";
}
}
{
// Slightly faster, use intervals of equal arc length
double da = a12 / num;
for (int i = 0; i <= num; ++i) {
double lat, lon;
line.ArcPosition(i * da, lat, lon);
cout << i << " " << lat << " " << lon << "\n";
}
}
}
catch (const exception& e) {
cerr << "Caught exception: " << e.what() << "\n";
return 1;
}
return 0;
}

GeodSolve is a command-line utility providing access to the functionality of GeodesicExact and GeodesicLineExact (via the -E option).

Definition at line 35 of file GeodesicLineExact.hpp.

Member Enumeration Documentation

Bit masks for what calculations to do. They signify to the GeodesicLineExact::GeodesicLineExact constructor and to GeodesicExact::Line what capabilities should be included in the GeodesicLineExact object. This is merely a duplication of GeodesicExact::mask.

Enumerator
NONE 

No capabilities, no output.

LATITUDE 

Calculate latitude lat2. (It's not necessary to include this as a capability to GeodesicLineExact 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 GeodesicLineExact 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 69 of file GeodesicLineExact.hpp.

Constructor & Destructor Documentation

GeographicLib::GeodesicLineExact::GeodesicLineExact ( const GeodesicExact g,
real  lat1,
real  lon1,
real  azi1,
unsigned  caps = ALL 
)

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

Parameters
[in]gA GeodesicExact object used to compute the necessary information about the GeodesicLineExact.
[in]lat1latitude of point 1 (degrees).
[in]lon1longitude of point 1 (degrees).
[in]azi1azimuth at point 1 (degrees).
[in]capsbitor'ed combination of GeodesicLineExact::mask values specifying the capabilities the GeodesicLineExact object should possess, i.e., which quantities can be returned in calls to GeodesicLine::Position.

lat1 should be in the range [−90°, 90°]; lon1 and azi1 should be in the range [−540°, 540°).

The GeodesicLineExact::mask values are

The default value of caps is GeodesicLineExact::ALL.

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 35 of file GeodesicLineExact.cpp.

References GeographicLib::Math::AngNormalize(), GeographicLib::EllipticFunction::D(), GeographicLib::Math::degree(), GeographicLib::EllipticFunction::deltaD(), GeographicLib::EllipticFunction::deltaE(), GeographicLib::EllipticFunction::deltaH(), GeographicLib::EllipticFunction::E(), GeographicLib::EllipticFunction::H(), GeographicLib::Math::hypot(), GeographicLib::Math::pi(), GeographicLib::EllipticFunction::Reset(), and GeographicLib::Math::sq().

GeographicLib::GeodesicLineExact::GeodesicLineExact ( )
inline

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

Definition at line 180 of file GeodesicLineExact.hpp.

Member Function Documentation

Math::real GeographicLib::GeodesicLineExact::Position ( real  s12,
real &  lat2,
real &  lon2,
real &  azi2,
real &  m12,
real &  M12,
real &  M21,
real &  S12 
) const
inline

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

Parameters
[in]s12distance between point 1 and point 2 (meters); it can be signed.
[out]lat2latitude of point 2 (degrees).
[out]lon2longitude of point 2 (degrees); requires that the GeodesicLineExact object was constructed with caps |= GeodesicLineExact::LONGITUDE.
[out]azi2(forward) azimuth at point 2 (degrees).
[out]m12reduced length of geodesic (meters); requires that the GeodesicLineExact object was constructed with caps |= GeodesicLineExact::REDUCEDLENGTH.
[out]M12geodesic scale of point 2 relative to point 1 (dimensionless); requires that the GeodesicLineExact object was constructed with caps |= GeodesicLineExact::GEODESICSCALE.
[out]M21geodesic scale of point 1 relative to point 2 (dimensionless); requires that the GeodesicLineExact object was constructed with caps |= GeodesicLineExact::GEODESICSCALE.
[out]S12area under the geodesic (meters2); requires that the GeodesicLineExact object was constructed with caps |= GeodesicLineExact::AREA.
Returns
a12 arc length of between point 1 and point 2 (degrees).

The values of lon2 and azi2 returned are in the range [−180°, 180°).

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

The following functions are overloaded versions of GeodesicLineExact::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 226 of file GeodesicLineExact.hpp.

Referenced by main().

Math::real GeographicLib::GeodesicLineExact::Position ( real  s12,
real &  lat2,
real &  lon2 
) const
inline

See the documentation for GeodesicLineExact::Position.

Definition at line 240 of file GeodesicLineExact.hpp.

Math::real GeographicLib::GeodesicLineExact::Position ( real  s12,
real &  lat2,
real &  lon2,
real &  azi2 
) const
inline

See the documentation for GeodesicLineExact::Position.

Definition at line 250 of file GeodesicLineExact.hpp.

Math::real GeographicLib::GeodesicLineExact::Position ( real  s12,
real &  lat2,
real &  lon2,
real &  azi2,
real &  m12 
) const
inline

See the documentation for GeodesicLineExact::Position.

Definition at line 261 of file GeodesicLineExact.hpp.

Math::real GeographicLib::GeodesicLineExact::Position ( real  s12,
real &  lat2,
real &  lon2,
real &  azi2,
real &  M12,
real &  M21 
) const
inline

See the documentation for GeodesicLineExact::Position.

Definition at line 273 of file GeodesicLineExact.hpp.

Math::real GeographicLib::GeodesicLineExact::Position ( real  s12,
real &  lat2,
real &  lon2,
real &  azi2,
real &  m12,
real &  M12,
real &  M21 
) const
inline

See the documentation for GeodesicLineExact::Position.

Definition at line 286 of file GeodesicLineExact.hpp.

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

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

Parameters
[in]a12arc length between point 1 and point 2 (degrees); it can be signed.
[out]lat2latitude of point 2 (degrees).
[out]lon2longitude of point 2 (degrees); requires that the GeodesicLineExact object was constructed with caps |= GeodesicLineExact::LONGITUDE.
[out]azi2(forward) azimuth at point 2 (degrees).
[out]s12distance between point 1 and point 2 (meters); requires that the GeodesicLineExact object was constructed with caps |= GeodesicLineExact::DISTANCE.
[out]m12reduced length of geodesic (meters); requires that the GeodesicLineExact object was constructed with caps |= GeodesicLineExact::REDUCEDLENGTH.
[out]M12geodesic scale of point 2 relative to point 1 (dimensionless); requires that the GeodesicLineExact object was constructed with caps |= GeodesicLineExact::GEODESICSCALE.
[out]M21geodesic scale of point 1 relative to point 2 (dimensionless); requires that the GeodesicLineExact object was constructed with caps |= GeodesicLineExact::GEODESICSCALE.
[out]S12area under the geodesic (meters2); requires that the GeodesicLineExact object was constructed with caps |= GeodesicLineExact::AREA.

The values of lon2 and azi2 returned are in the range [−180°, 180°).

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

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

Definition at line 340 of file GeodesicLineExact.hpp.

Referenced by main().

void GeographicLib::GeodesicLineExact::ArcPosition ( real  a12,
real &  lat2,
real &  lon2 
) const
inline

See the documentation for GeodesicLineExact::ArcPosition.

Definition at line 352 of file GeodesicLineExact.hpp.

void GeographicLib::GeodesicLineExact::ArcPosition ( real  a12,
real &  lat2,
real &  lon2,
real &  azi2 
) const
inline

See the documentation for GeodesicLineExact::ArcPosition.

Definition at line 363 of file GeodesicLineExact.hpp.

void GeographicLib::GeodesicLineExact::ArcPosition ( real  a12,
real &  lat2,
real &  lon2,
real &  azi2,
real &  s12 
) const
inline

See the documentation for GeodesicLineExact::ArcPosition.

Definition at line 375 of file GeodesicLineExact.hpp.

void GeographicLib::GeodesicLineExact::ArcPosition ( real  a12,
real &  lat2,
real &  lon2,
real &  azi2,
real &  s12,
real &  m12 
) const
inline

See the documentation for GeodesicLineExact::ArcPosition.

Definition at line 386 of file GeodesicLineExact.hpp.

void GeographicLib::GeodesicLineExact::ArcPosition ( real  a12,
real &  lat2,
real &  lon2,
real &  azi2,
real &  s12,
real &  M12,
real &  M21 
) const
inline

See the documentation for GeodesicLineExact::ArcPosition.

Definition at line 398 of file GeodesicLineExact.hpp.

void GeographicLib::GeodesicLineExact::ArcPosition ( real  a12,
real &  lat2,
real &  lon2,
real &  azi2,
real &  s12,
real &  m12,
real &  M12,
real &  M21 
) const
inline

See the documentation for GeodesicLineExact::ArcPosition.

Definition at line 411 of file GeodesicLineExact.hpp.

Math::real GeographicLib::GeodesicLineExact::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

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

Parameters
[in]arcmodeboolean flag determining the meaning of the second parameter; if arcmode is false, then the GeodesicLineExact object must have been constructed with caps |= GeodesicLineExact::DISTANCE_IN.
[in]s12_a12if 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]outmaska bitor'ed combination of GeodesicLineExact::mask values specifying which of the following parameters should be set.
[out]lat2latitude of point 2 (degrees).
[out]lon2longitude of point 2 (degrees); requires that the GeodesicLineExact object was constructed with caps |= GeodesicLineExact::LONGITUDE.
[out]azi2(forward) azimuth at point 2 (degrees).
[out]s12distance between point 1 and point 2 (meters); requires that the GeodesicLineExact object was constructed with caps |= GeodesicLineExact::DISTANCE.
[out]m12reduced length of geodesic (meters); requires that the GeodesicLineExact object was constructed with caps |= GeodesicLineExact::REDUCEDLENGTH.
[out]M12geodesic scale of point 2 relative to point 1 (dimensionless); requires that the GeodesicLineExact object was constructed with caps |= GeodesicLineExact::GEODESICSCALE.
[out]M21geodesic scale of point 1 relative to point 2 (dimensionless); requires that the GeodesicLineExact object was constructed with caps |= GeodesicLineExact::GEODESICSCALE.
[out]S12area under the geodesic (meters2); requires that the GeodesicLineExact object was constructed with caps |= GeodesicLineExact::AREA.
Returns
a12 arc length of between point 1 and point 2 (degrees).

The GeodesicLineExact::mask values possible for outmask are

Requesting a value which the GeodesicLineExact 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 124 of file GeodesicLineExact.cpp.

References GeographicLib::Math::AngNormalize(), GeographicLib::Math::AngNormalize2(), AREA, AZIMUTH, GeographicLib::Math::degree(), GeographicLib::EllipticFunction::Delta(), GeographicLib::EllipticFunction::deltaD(), GeographicLib::EllipticFunction::deltaE(), GeographicLib::EllipticFunction::deltaEinv(), GeographicLib::EllipticFunction::deltaH(), DISTANCE, DISTANCE_IN, GEODESICSCALE, GeographicLib::Math::hypot(), Init(), LATITUDE, LONGITUDE, GeographicLib::Math::NaN(), REDUCEDLENGTH, and GeographicLib::Math::sq().

bool GeographicLib::GeodesicLineExact::Init ( ) const
inline
Returns
true if the object has been initialized.

Definition at line 491 of file GeodesicLineExact.hpp.

Referenced by GenPosition().

Math::real GeographicLib::GeodesicLineExact::Latitude ( ) const
inline
Returns
lat1 the latitude of point 1 (degrees).

Definition at line 496 of file GeodesicLineExact.hpp.

References GeographicLib::Math::NaN().

Math::real GeographicLib::GeodesicLineExact::Longitude ( ) const
inline
Returns
lon1 the longitude of point 1 (degrees).

Definition at line 502 of file GeodesicLineExact.hpp.

References GeographicLib::Math::NaN().

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

Definition at line 508 of file GeodesicLineExact.hpp.

References GeographicLib::Math::NaN().

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

Definition at line 515 of file GeodesicLineExact.hpp.

References GeographicLib::Math::degree(), and GeographicLib::Math::NaN().

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

Definition at line 525 of file GeodesicLineExact.hpp.

References GeographicLib::Math::degree(), and GeographicLib::Math::NaN().

Math::real GeographicLib::GeodesicLineExact::MajorRadius ( ) const
inline
Returns
a the equatorial radius of the ellipsoid (meters). This is the value inherited from the GeodesicExact object used in the constructor.

Definition at line 536 of file GeodesicLineExact.hpp.

References GeographicLib::Math::NaN().

Math::real GeographicLib::GeodesicLineExact::Flattening ( ) const
inline
Returns
f the flattening of the ellipsoid. This is the value inherited from the GeodesicExact object used in the constructor.

Definition at line 543 of file GeodesicLineExact.hpp.

References GeographicLib::Math::NaN().

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

Definition at line 559 of file GeodesicLineExact.hpp.

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

Definition at line 565 of file GeodesicLineExact.hpp.

Friends And Related Function Documentation

friend class GeodesicExact
friend

Definition at line 38 of file GeodesicLineExact.hpp.


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