GeographicLib: GeographicLib::RhumbLine Class Reference

GeographicLib 2.5.2

Loading...
Searching...
No Matches
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 }
typedef Rhumb | BaseClass

## 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>
#include <GeographicLib/Rhumb.hpp>
#include <GeographicLib/Constants.hpp>
using namespace std;
using namespace GeographicLib;
int main() {
try {
// Print waypoints between JFK and SIN
Rhumb rhumb(Constants::WGS84_a(), Constants::WGS84_f());
// 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;
}
}
main
int main(int argc, const char *const argv[])
Definition CartConvert.cpp:28
Constants.hpp
Header for GeographicLib::Constants class.
Rhumb.hpp
Header for GeographicLib::Rhumb and GeographicLib::RhumbLine classes.
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::RhumbLine::Position
void Position(real s12, real &lat2, real &lon2, real &S12) const
Definition Rhumb.hpp:467
GeographicLib::RhumbLine::Rhumb
friend class Rhumb
Definition Rhumb.hpp:385
GeographicLib
Namespace for GeographicLib.
Definition Accumulator.cpp:12
std
Definition NearestNeighbor.hpp:806

Definition at line 382 of file Rhumb.hpp.

## Member Typedef Documentation

## ◆ BaseClass

typedef Rhumb GeographicLib::RhumbLine::BaseClass

Typedef for the base class implementing rhumb lines.

Definition at line 448 of file Rhumb.hpp.

## Member Enumeration Documentation

## ◆ mask

enum GeographicLib::RhumbLine::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 402 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] | s12 | distance between point 1 and point 2 (meters); it can be negative.
  [out] | lat2 | latitude of point 2 (degrees).
  [out] | lon2 | longitude of point 2 (degrees).
  [out] | S12 | area 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 467 of file Rhumb.hpp.

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

## ◆ 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 475 of file Rhumb.hpp.

References GenPosition(), LATITUDE, and LONGITUDE.

## ◆ 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] | s12 | distance between point 1 and point 2 (meters); it can be negative.
  [in] | outmask | a bitor'ed combination of RhumbLine::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).
  [out] | S12 | area under the rhumb line (meters2).

The RhumbLine::mask values possible for outmask are

- outmask |= RhumbLine::LATITUDE for the latitude lat2;
- outmask |= RhumbLine::LONGITUDE for the latitude lon2;
- outmask |= RhumbLine::AREA for the area S12;
- outmask |= RhumbLine::ALL for all of the above;
- outmask |= RhumbLine::LONG_UNROLL to unroll lon2 instead of wrapping it into the range [−180°, 180°].

With the RhumbLine::LONG_UNROLL bit set, the quantity lon2 − lon1 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 283 of file Rhumb.cpp.

References GeographicLib::Math::AngNormalize(), AREA, GeographicLib::AuxLatitude::CHI, GeographicLib::Math::degree(), GeographicLib::AuxAngle::degrees(), GeographicLib::DAuxLatitude::Dlam(), GeographicLib::Math::hd, LATITUDE, LONG_UNROLL, LONGITUDE, GeographicLib::AuxLatitude::MU, GeographicLib::Math::NaN(), GeographicLib::AuxLatitude::PHI, GeographicLib::Math::qd, and GeographicLib::AuxAngle::tan().

Referenced by GeographicLib::Rhumb::GenDirect(), main(), Position(), and Position().

## ◆ Latitude()

Math::real GeographicLib::RhumbLine::Latitude | ( |  | ) | const
| inline

Returns
  lat1 the latitude of point 1 (degrees).

Definition at line 518 of file Rhumb.hpp.

## ◆ Longitude()

Math::real GeographicLib::RhumbLine::Longitude | ( |  | ) | const
| inline

Returns
  lon1 the longitude of point 1 (degrees).

Definition at line 523 of file Rhumb.hpp.

## ◆ Azimuth()

Math::real GeographicLib::RhumbLine::Azimuth | ( |  | ) | const
| inline

Returns
  azi12 the azimuth of the rhumb line (degrees).

Definition at line 528 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 534 of file Rhumb.hpp.

## ◆ 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 540 of file Rhumb.hpp.

## Friends And Related Symbol Documentation

## ◆ Rhumb

friend class Rhumb
| friend

Definition at line 385 of file Rhumb.hpp.

References Rhumb.

Referenced by Rhumb.

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

- Rhumb.hpp
- Rhumb.cpp