GeographicLib  1.42
Public Types | Public Member Functions | Friends | List of all members
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_NOWRAP, ALL
}
 

Public Member Functions

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 MajorRadius () 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 <exception>
#include <cmath>
#include <iomanip>
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);
const GeographicLib::RhumbLine line = rhumb.Line(lat1, lon1, azi12);
// Alternatively
// const GeographicLib::RhumbLine line = rhumb.Line(lat1, lon1, azi1);
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;
}
return 0;
}

Definition at line 442 of file Rhumb.hpp.

Member Enumeration Documentation

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_NOWRAP 

Do wrap the lon2 in the direct calculation.

ALL 

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

Definition at line 454 of file Rhumb.hpp.

Member Function Documentation

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 514 of file Rhumb.hpp.

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 522 of file Rhumb.hpp.

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 Rhumb::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 Rhumb::mask values possible for outmask are

With the LONG_NOWRAP bit set, the quantity lon2lon1 indicates how many times the rhumb line wrapped around the ellipsoid. Because lon2 might be outside the normal allowed range for longitudes, [−540°, 540°), be sure to normalize it with Math::AngNormalize2 before using it in other GeographicLib calls.

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 313 of file Rhumb.cpp.

References GeographicLib::Math::AngNormalize(), GeographicLib::Math::AngNormalize2(), AREA, GeographicLib::Math::degree(), GeographicLib::Ellipsoid::InverseRectifyingLatitude(), LATITUDE, LONG_NOWRAP, LONGITUDE, GeographicLib::Math::NaN(), and GeographicLib::Ellipsoid::QuarterMeridian().

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

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

Definition at line 567 of file Rhumb.hpp.

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

Definition at line 572 of file Rhumb.hpp.

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

Definition at line 577 of file Rhumb.hpp.

Math::real GeographicLib::RhumbLine::MajorRadius ( ) 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 583 of file Rhumb.hpp.

References GeographicLib::Rhumb::MajorRadius().

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 589 of file Rhumb.hpp.

References GeographicLib::Rhumb::Flattening().

Friends And Related Function Documentation

friend class Rhumb
friend

Definition at line 445 of file Rhumb.hpp.


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