GeographicLib 2.1.2
GeographicLib::RhumbLine Class Reference

Find a sequence of points on a single rhumb line. More...

#include <GeographicLib/Rhumb.hpp>

Public Types

enum  mask {
  NONE , LATITUDE , LONGITUDE , AZIMUTH ,
  DISTANCE , AREA , LONG_UNROLL , ALL
}
 

Public Member Functions

 RhumbLine (const RhumbLine &)=default
 
void Position (real s12, real &lat2, real &lon2, real &S12) const
 
void Position (real s12, real &lat2, real &lon2) const
 
void GenPosition (real s12, unsigned outmask, real &lat2, real &lon2, real &S12) const
 
Inspector functions
Math::real Latitude () const
 
Math::real Longitude () const
 
Math::real Azimuth () const
 
Math::real EquatorialRadius () const
 
Math::real Flattening () const
 

Friends

class Rhumb
 

Detailed Description

Find a sequence of points on a single rhumb line.

RhumbLine facilitates the determination of a series of points on a single rhumb line. The starting point (lat1, lon1) and the azimuth azi12 are specified in the call to Rhumb::Line which returns a RhumbLine object. RhumbLine.Position returns the location of point 2 (and, optionally, the corresponding area, S12) a distance s12 along the rhumb line.

There is no public constructor for this class. (Use Rhumb::Line to create an instance.) The Rhumb object used to create a RhumbLine must stay in scope as long as the RhumbLine.

Example of use:

// Example of using the GeographicLib::RhumbLine class
#include <iostream>
#include <iomanip>
#include <exception>
#include <cmath>
using namespace std;
using namespace GeographicLib;
int main() {
try {
// Print waypoints between JFK and SIN
// Alternatively: const Rhumb& rhumb = Rhumb::WGS84();
double
lat1 = 40.640, lon1 = -73.779, // JFK
lat2 = 1.359, lon2 = 103.989; // SIN
double s12, azi12;
rhumb.Inverse(lat1, lon1, lat2, lon2, s12, azi12);
RhumbLine line = rhumb.Line(lat1, lon1, azi12);
double ds0 = 500e3; // Nominal distance between points = 500 km
int num = int(ceil(s12 / ds0)); // 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";
}
}
}
catch (const exception& e) {
cerr << "Caught exception: " << e.what() << "\n";
return 1;
}
}
int main(int argc, const char *const argv[])
Definition: CartConvert.cpp:29
Header for GeographicLib::Constants class.
Header for GeographicLib::Rhumb and GeographicLib::RhumbLine classes.
Find a sequence of points on a single rhumb line.
Definition: Rhumb.hpp:458
void Position(real s12, real &lat2, real &lon2, real &S12) const
Definition: Rhumb.hpp:535
Solve of the direct and inverse rhumb problems.
Definition: Rhumb.hpp:66
Namespace for GeographicLib.
Definition: Accumulator.cpp:12

Definition at line 458 of file Rhumb.hpp.

Member Enumeration Documentation

◆ mask

This is a duplication of Rhumb::mask.

Enumerator
NONE 

No output.

LATITUDE 

Calculate latitude lat2.

LONGITUDE 

Calculate longitude lon2.

AZIMUTH 

Calculate azimuth azi12.

DISTANCE 

Calculate distance s12.

AREA 

Calculate area S12.

LONG_UNROLL 

Unroll lon2 in the direct calculation.

ALL 

Calculate everything. (LONG_UNROLL is not included in this mask.)

Definition at line 475 of file Rhumb.hpp.

Constructor & Destructor Documentation

◆ RhumbLine()

GeographicLib::RhumbLine::RhumbLine ( const RhumbLine )
default

Construction is via default copy constructor.

Member Function Documentation

◆ Position() [1/2]

void GeographicLib::RhumbLine::Position ( real  s12,
real &  lat2,
real &  lon2,
real &  S12 
) const
inline

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

Parameters
[in]s12distance between point 1 and point 2 (meters); it can be negative.
[out]lat2latitude of point 2 (degrees).
[out]lon2longitude of point 2 (degrees).
[out]S12area under the rhumb line (meters2).

The value of lon2 returned is in the range [−180°, 180°].

If s12 is large enough that the rhumb line crosses a pole, the longitude of point 2 is indeterminate (a NaN is returned for lon2 and S12).

Definition at line 535 of file Rhumb.hpp.

Referenced by main().

◆ Position() [2/2]

void GeographicLib::RhumbLine::Position ( real  s12,
real &  lat2,
real &  lon2 
) const
inline

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

Definition at line 543 of file Rhumb.hpp.

◆ GenPosition()

void GeographicLib::RhumbLine::GenPosition ( real  s12,
unsigned  outmask,
real &  lat2,
real &  lon2,
real &  S12 
) const

The general position routine. RhumbLine::Position is defined in term so this function.

Parameters
[in]s12distance between point 1 and point 2 (meters); it can be negative.
[in]outmaska bitor'ed combination of RhumbLine::mask values specifying which of the following parameters should be set.
[out]lat2latitude of point 2 (degrees).
[out]lon2longitude of point 2 (degrees).
[out]S12area under the rhumb line (meters2).

The RhumbLine::mask values possible for outmask are

With the RhumbLine::LONG_UNROLL bit set, the quantity lon2lon1 indicates how many times and in what sense the rhumb line encircles the ellipsoid.

If s12 is large enough that the rhumb line crosses a pole, the longitude of point 2 is indeterminate (a NaN is returned for lon2 and S12).

Definition at line 350 of file Rhumb.cpp.

References GeographicLib::Math::AngNormalize(), AREA, GeographicLib::Math::degree(), GeographicLib::Math::hd, GeographicLib::Ellipsoid::InverseRectifyingLatitude(), LATITUDE, LONG_UNROLL, LONGITUDE, GeographicLib::Math::NaN(), GeographicLib::Math::qd, and GeographicLib::Ellipsoid::QuarterMeridian().

Referenced by GeographicLib::Rhumb::GenDirect().

◆ Latitude()

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

Definition at line 586 of file Rhumb.hpp.

◆ Longitude()

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

Definition at line 591 of file Rhumb.hpp.

◆ Azimuth()

Math::real GeographicLib::RhumbLine::Azimuth ( ) const
inline
Returns
azi12 the azimuth of the rhumb line (degrees).

Definition at line 596 of file Rhumb.hpp.

◆ EquatorialRadius()

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

Definition at line 602 of file Rhumb.hpp.

References GeographicLib::Rhumb::EquatorialRadius().

◆ Flattening()

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

Definition at line 608 of file Rhumb.hpp.

References GeographicLib::Rhumb::Flattening().

Friends And Related Function Documentation

◆ Rhumb

friend class Rhumb
friend

Definition at line 461 of file Rhumb.hpp.


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