digiKam
Loading...
Searching...
No Matches
Digikam::GeodeticCalculator Class Reference

#include <geodetictools.h>

Public Member Functions

double azimuth ()
 
bool checkOrthodromicDistance ()
 
bool computeDestinationPoint ()
 
bool computeDirection ()
 
QPointF destinationGeographicPoint ()
 
bool destinationGeographicPoint (double *longitude, double *latitude)
 
Ellipsoid ellipsoid () const
 
 GeodeticCalculator (const Ellipsoid &e=Ellipsoid::WGS84())
 
double meridianArcLength (double latitude1, double latitude2)
 
double meridianArcLengthRadians (double P1, double P2)
 
double orthodromicDistance ()
 
void setDestinationGeographicPoint (double longitude, double latitude)
 
void setDirection (double azimuth, double distance)
 
void setStartingGeographicPoint (double longitude, double latitude)
 

Protected Member Functions

double castToAngleRange (const double alpha)
 
bool checkAzimuth (double *azimuth)
 
bool checkLatitude (double *latitude)
 
bool checkLongitude (double *longitude)
 
bool checkOrthodromicDistance (const double distance)
 

Protected Attributes

double a01 = 0.0
 
double a02 = 0.0
 
double a03 = 0.0
 
double a21 = 0.0
 
double a22 = 0.0
 
double a23 = 0.0
 
double a42 = 0.0
 
double a43 = 0.0
 
double a63 = 0.0
 
double f = 0.0
 
double f2 = 0.0
 
double f3 = 0.0
 
double f4 = 0.0
 
double fo = 0.0
 
double m_A = 0.0
 
double m_azimuth = 0.0
 
double m_B = 0.0
 
double m_C = 0.0
 
double m_D = 0.0
 
bool m_destinationValid = false
 
bool m_directionValid = false
 
double m_distance = 0.0
 
double m_E = 0.0
 
double m_eccentricitySquared = 0.0
 
Ellipsoid m_ellipsoid
 
double m_F = 0.0
 
double m_lat1 = 0.0
 
double m_lat2 = 0.0
 
double m_long1 = 0.0
 
double m_long2 = 0.0
 
double m_maxOrthodromicDistance = 0.0
 
double m_semiMajorAxis = 0.0
 
double m_semiMinorAxis = 0.0
 
double m_TOLERANCE_0 = 5.0e-15
 
double m_TOLERANCE_1 = 5.0e-14
 
double m_TOLERANCE_2 = 5.0e-13
 
double m_TOLERANCE_3 = 7.0e-3
 
double m_TOLERANCE_CHECK = 1E-8
 
double T1 = 1.0
 
double T2 = 0.0
 
double T4 = 0.0
 
double T6 = 0.0
 

Constructor & Destructor Documentation

◆ GeodeticCalculator()

Digikam::GeodeticCalculator::GeodeticCalculator ( const Ellipsoid e = Ellipsoid::WGS84())
explicit

Performs geodetic calculations on an ellipsoid. This class encapsulates a generic ellipsoid and calculates the following properties:

Distance and azimuth between two points. Point located at a given distance and azimuth from an other point.

The calculation use the following information:

The starting position (setStartingPosition), which is always considered valid. It is initially set at (0,0) and can only be changed to another legitimate value. Only one of the following:

  The destination position (setDestinationPosition), or
  An azimuth and distance (setDirection).

The latest one set overrides the other and determines what will be calculated.

References a01, a02, a03, a21, a22, a23, a42, a43, a63, f, f2, f3, f4, fo, m_A, m_B, m_C, m_D, m_E, m_eccentricitySquared, m_ellipsoid, m_F, m_maxOrthodromicDistance, m_semiMajorAxis, m_semiMinorAxis, Digikam::Ellipsoid::semiMajorAxis(), Digikam::Ellipsoid::semiMinorAxis(), T2, T4, and T6.

Member Function Documentation

◆ azimuth()

double Digikam::GeodeticCalculator::azimuth ( )

Returns the azimuth. This method returns the value set by the last call to setDirection(double,double) setDirection(azimuth,distance), except if setDestinationGeographicPoint(double,double) setDestinationGeographicPoint(...) has been invoked after. In this later case, the azimuth will be computed from the startingGeographicPoint starting point to the destination point.

Returns
The azimuth, in decimal degrees from -180° to +180°.

References computeDirection(), m_azimuth, m_directionValid, and Digikam::Coordinates::toDegrees().

Referenced by checkAzimuth(), computeDestinationPoint(), and setDirection().

◆ castToAngleRange()

double Digikam::GeodeticCalculator::castToAngleRange ( const double  alpha)
protected

◆ checkAzimuth()

bool Digikam::GeodeticCalculator::checkAzimuth ( double *  azimuth)
protected

Checks the azimuth validity. The argument azimuth should be greater or equal than -180 degrees and lower or equals than +180 degrees. As a convenience, this method converts the azimuth to radians.

Parameters
azimuthThe azimuth value in decimal degrees.

References azimuth(), and Digikam::Coordinates::toRadians().

Referenced by setDirection().

◆ checkLatitude()

bool Digikam::GeodeticCalculator::checkLatitude ( double *  latitude)
protected

Checks the latitude validity. The argument latitude should be greater or equal than -90 degrees and lower or equals than +90 degrees. As a convenience, this method converts the latitude to radians.

Parameters
latitudeThe latitude value in decimal degrees.

References Digikam::Coordinates::toRadians().

Referenced by meridianArcLength(), setDestinationGeographicPoint(), and setStartingGeographicPoint().

◆ checkLongitude()

bool Digikam::GeodeticCalculator::checkLongitude ( double *  longitude)
protected

Checks the longitude validity. The argument longitude should be greater or equal than -180 degrees and lower or equals than +180 degrees. As a convenience, this method converts the longitude to radians.

Parameters
longitudeThe longitude value in decimal degrees.

References Digikam::Coordinates::toRadians().

Referenced by setDestinationGeographicPoint(), and setStartingGeographicPoint().

◆ checkOrthodromicDistance() [1/2]

bool Digikam::GeodeticCalculator::checkOrthodromicDistance ( )

Computes the orthodromic distance using the algorithm implemented in the Geotools's ellipsoid class (if available), and check if the error is smaller than some tolerance error.

References m_distance, m_ellipsoid, m_lat1, m_lat2, m_long1, m_long2, m_TOLERANCE_CHECK, Digikam::Ellipsoid::orthodromicDistance(), and Digikam::Coordinates::toDegrees().

Referenced by orthodromicDistance(), and setDirection().

◆ checkOrthodromicDistance() [2/2]

bool Digikam::GeodeticCalculator::checkOrthodromicDistance ( const double  distance)
protected

Checks the orthodromic distance validity. Arguments orthodromicDistance should be greater or equal than 0 and lower or equals than the maximum orthodromic distance.

Parameters
distanceThe orthodromic distance value.

References m_maxOrthodromicDistance.

◆ computeDestinationPoint()

bool Digikam::GeodeticCalculator::computeDestinationPoint ( )

Computes the destination point from the starting point, the azimuth and the orthodromic distance.

References azimuth(), castToAngleRange(), f, fo, m_azimuth, m_destinationValid, m_directionValid, m_distance, m_lat1, m_lat2, m_long1, m_long2, m_semiMajorAxis, m_TOLERANCE_1, and X.

Referenced by destinationGeographicPoint().

◆ computeDirection()

bool Digikam::GeodeticCalculator::computeDirection ( )

Computes the azimuth and orthodromic distance from the startingGeographicPoint starting point and the destinationGeographicPoint destination point.

Computes the azimuth and orthodromic distance from the startingGeographicPoint() and the destinationGeographicPoint().

References a01, a02, a03, a21, a22, a23, a42, a43, a63, castToAngleRange(), f, fo, m_azimuth, m_destinationValid, m_directionValid, m_distance, m_eccentricitySquared, m_lat1, m_lat2, m_long1, m_long2, m_semiMajorAxis, m_semiMinorAxis, m_TOLERANCE_0, m_TOLERANCE_1, m_TOLERANCE_2, m_TOLERANCE_3, meridianArcLengthRadians(), T1, T2, T4, and T6.

Referenced by azimuth(), and orthodromicDistance().

◆ destinationGeographicPoint() [1/2]

QPointF Digikam::GeodeticCalculator::destinationGeographicPoint ( )

◆ destinationGeographicPoint() [2/2]

bool Digikam::GeodeticCalculator::destinationGeographicPoint ( double *  longitude,
double *  latitude 
)

Returns the destination point. This method returns the point set by the last call to a setDestinationGeographicPoint(...) method, except if setDirection(...) has been invoked after. In this later case, the destination point will be computed from the starting point to the azimuth and distance specified. Coordinates positive North and East.

Returns
The destination point. The x and y coordinates are the longitude and latitude in decimal degrees, respectively.

References computeDestinationPoint(), m_destinationValid, m_lat2, m_long2, and Digikam::Coordinates::toDegrees().

Referenced by Digikam::FieldQueryBuilder::addPosition().

◆ ellipsoid()

Ellipsoid Digikam::GeodeticCalculator::ellipsoid ( ) const

Returns the referenced ellipsoid.

References m_ellipsoid.

Referenced by Digikam::FieldQueryBuilder::addPosition().

◆ meridianArcLength()

double Digikam::GeodeticCalculator::meridianArcLength ( double  latitude1,
double  latitude2 
)

Calculates the meridian arc length between two points in the same meridian in the referenced ellipsoid.

Parameters
latitude1The latitude of the first point (in decimal degrees).
latitude2The latitude of the second point (in decimal degrees).
Returns
Returned the meridian arc length between latitude1 and latitude2

References checkLatitude(), and meridianArcLengthRadians().

◆ meridianArcLengthRadians()

double Digikam::GeodeticCalculator::meridianArcLengthRadians ( double  P1,
double  P2 
)

Calculates the meridian arc length between two points in the same meridian in the referenced ellipsoid.

Parameters
P1The latitude of the first point (in radians).
P2The latitude of the second point (in radians).
Returns
Returned the meridian arc length between P1 and P2

References m_A, m_B, m_C, m_D, m_E, m_eccentricitySquared, m_F, m_semiMajorAxis, and m_TOLERANCE_0.

Referenced by computeDirection(), and meridianArcLength().

◆ orthodromicDistance()

double Digikam::GeodeticCalculator::orthodromicDistance ( )

Returns the orthodromic distance. This method returns the value set by the last call to setDirection(double,double) setDirection(azimuth,distance), except if setDestinationGeographicPoint(double,double) setDestinationGeographicPoint(...) has been invoked after. In this later case, the distance will be computed from the startingGeographicPoint starting point to the destination point.

Returns
The orthodromic distance, in the same units as the getEllipsoid ellipsoid axis.

References checkOrthodromicDistance(), computeDirection(), m_directionValid, and m_distance.

Referenced by Digikam::MetaEngine::setGPSInfo().

◆ setDestinationGeographicPoint()

void Digikam::GeodeticCalculator::setDestinationGeographicPoint ( double  longitude,
double  latitude 
)

Set the destination point in geographic coordinates. The azimuth and distance values will be updated as a side effect of this call. They will be recomputed the next time getAzimuth() or getOrthodromicDistance() are invoked. Coordinates positive North and East.

Parameters
longitudeThe longitude in decimal degrees between -180 and +180°
latitudeThe latitude in decimal degrees between -90 and +90°

References checkLatitude(), checkLongitude(), m_destinationValid, m_directionValid, m_lat2, and m_long2.

Referenced by Digikam::MetaEngine::setGPSInfo().

◆ setDirection()

void Digikam::GeodeticCalculator::setDirection ( double  azimuth,
double  distance 
)

Set the azimuth and the distance from the startingGeographicPoint starting point. The destination point will be updated as a side effect of this call. It will be recomputed the next time destinationGeographicPoint() is invoked. Azimuth 0° North.

Parameters
azimuthThe azimuth in decimal degrees from -180° to 180°.
distanceThe orthodromic distance in the same units as the ellipsoid axis.

References azimuth(), checkAzimuth(), checkOrthodromicDistance(), m_azimuth, m_destinationValid, m_directionValid, and m_distance.

Referenced by Digikam::FieldQueryBuilder::addPosition().

◆ setStartingGeographicPoint()

void Digikam::GeodeticCalculator::setStartingGeographicPoint ( double  longitude,
double  latitude 
)

Set the starting point in geographic coordinates. The azimuth, the orthodromic distance and the destination point are discarded. They will need to be specified again. Coordinates positive North and East.

Parameters
longitudeThe longitude in decimal degrees between -180 and +180°
latitudeThe latitude in decimal degrees between -90 and +90°

References checkLatitude(), checkLongitude(), m_destinationValid, m_directionValid, m_lat1, and m_long1.

Referenced by Digikam::FieldQueryBuilder::addPosition(), and Digikam::MetaEngine::setGPSInfo().

Member Data Documentation

◆ a01

double Digikam::GeodeticCalculator::a01 = 0.0
protected

Parameters computed from the ellipsoid.

Referenced by computeDirection(), and GeodeticCalculator().

◆ a02

double Digikam::GeodeticCalculator::a02 = 0.0
protected

◆ a03

double Digikam::GeodeticCalculator::a03 = 0.0
protected

◆ a21

double Digikam::GeodeticCalculator::a21 = 0.0
protected

◆ a22

double Digikam::GeodeticCalculator::a22 = 0.0
protected

◆ a23

double Digikam::GeodeticCalculator::a23 = 0.0
protected

◆ a42

double Digikam::GeodeticCalculator::a42 = 0.0
protected

◆ a43

double Digikam::GeodeticCalculator::a43 = 0.0
protected

◆ a63

double Digikam::GeodeticCalculator::a63 = 0.0
protected

◆ f

double Digikam::GeodeticCalculator::f = 0.0
protected

◆ f2

double Digikam::GeodeticCalculator::f2 = 0.0
protected

Referenced by GeodeticCalculator().

◆ f3

double Digikam::GeodeticCalculator::f3 = 0.0
protected

Referenced by GeodeticCalculator().

◆ f4

double Digikam::GeodeticCalculator::f4 = 0.0
protected

Referenced by GeodeticCalculator().

◆ fo

double Digikam::GeodeticCalculator::fo = 0.0
protected

GPNHRI parameters computed from the ellipsoid.

f if the flattening of the referenced ellipsoid. f2, f3 and f4 are f2, f3 and f4 respectively.

Referenced by computeDestinationPoint(), computeDirection(), and GeodeticCalculator().

◆ m_A

double Digikam::GeodeticCalculator::m_A = 0.0
protected

GPNARC parameters computed from the ellipsoid.

Referenced by GeodeticCalculator(), and meridianArcLengthRadians().

◆ m_azimuth

double Digikam::GeodeticCalculator::m_azimuth = 0.0
protected

◆ m_B

double Digikam::GeodeticCalculator::m_B = 0.0
protected

◆ m_C

double Digikam::GeodeticCalculator::m_C = 0.0
protected

◆ m_D

double Digikam::GeodeticCalculator::m_D = 0.0
protected

◆ m_destinationValid

bool Digikam::GeodeticCalculator::m_destinationValid = false
protected

Tell if the destination point is valid. false if long2 and lat2 need to be computed.

Referenced by computeDestinationPoint(), computeDirection(), destinationGeographicPoint(), setDestinationGeographicPoint(), setDirection(), and setStartingGeographicPoint().

◆ m_directionValid

bool Digikam::GeodeticCalculator::m_directionValid = false
protected

Tell if the azimuth and the distance are valids. false if distance and azimuth need to be computed.

Referenced by azimuth(), computeDestinationPoint(), computeDirection(), orthodromicDistance(), setDestinationGeographicPoint(), setDirection(), and setStartingGeographicPoint().

◆ m_distance

double Digikam::GeodeticCalculator::m_distance = 0.0
protected

The distance and azimuth (in radians) from the starting point (long1, lat1) to the destination point (long2, lat2).

Referenced by checkOrthodromicDistance(), computeDestinationPoint(), computeDirection(), orthodromicDistance(), and setDirection().

◆ m_E

double Digikam::GeodeticCalculator::m_E = 0.0
protected

◆ m_eccentricitySquared

double Digikam::GeodeticCalculator::m_eccentricitySquared = 0.0
protected

The eccentricity squared of the referenced ellipsoid.

Referenced by computeDirection(), GeodeticCalculator(), and meridianArcLengthRadians().

◆ m_ellipsoid

Ellipsoid Digikam::GeodeticCalculator::m_ellipsoid
protected

The encapsulated ellipsoid.

Referenced by checkOrthodromicDistance(), ellipsoid(), and GeodeticCalculator().

◆ m_F

double Digikam::GeodeticCalculator::m_F = 0.0
protected

◆ m_lat1

double Digikam::GeodeticCalculator::m_lat1 = 0.0
protected

The (latitude, longitude) coordinate of the first point in radians. This point is set by setStartingGeographicPoint.

Referenced by checkOrthodromicDistance(), computeDestinationPoint(), computeDirection(), and setStartingGeographicPoint().

◆ m_lat2

double Digikam::GeodeticCalculator::m_lat2 = 0.0
protected

The (latitude, longitude) coordinate of the destination point in radians. This point is set by setDestinationGeographicPoint.

Referenced by checkOrthodromicDistance(), computeDestinationPoint(), computeDirection(), destinationGeographicPoint(), and setDestinationGeographicPoint().

◆ m_long1

double Digikam::GeodeticCalculator::m_long1 = 0.0
protected

◆ m_long2

double Digikam::GeodeticCalculator::m_long2 = 0.0
protected

◆ m_maxOrthodromicDistance

double Digikam::GeodeticCalculator::m_maxOrthodromicDistance = 0.0
protected

The maximum orthodromic distance that could be calculated onto the referenced ellipsoid.

Referenced by checkOrthodromicDistance(), and GeodeticCalculator().

◆ m_semiMajorAxis

double Digikam::GeodeticCalculator::m_semiMajorAxis = 0.0
protected

The semi major axis of the referenced ellipsoid.

Referenced by computeDestinationPoint(), computeDirection(), GeodeticCalculator(), and meridianArcLengthRadians().

◆ m_semiMinorAxis

double Digikam::GeodeticCalculator::m_semiMinorAxis = 0.0
protected

The semi minor axis of the referenced ellipsoid.

Referenced by computeDirection(), and GeodeticCalculator().

◆ m_TOLERANCE_0

double Digikam::GeodeticCalculator::m_TOLERANCE_0 = 5.0e-15
protected

Tolerance factors from the strictest (TOLERANCE_0) to the most relax one (TOLERANCE_3).

Referenced by computeDirection(), and meridianArcLengthRadians().

◆ m_TOLERANCE_1

double Digikam::GeodeticCalculator::m_TOLERANCE_1 = 5.0e-14
protected

◆ m_TOLERANCE_2

double Digikam::GeodeticCalculator::m_TOLERANCE_2 = 5.0e-13
protected

Referenced by computeDirection().

◆ m_TOLERANCE_3

double Digikam::GeodeticCalculator::m_TOLERANCE_3 = 7.0e-3
protected

Referenced by computeDirection().

◆ m_TOLERANCE_CHECK

double Digikam::GeodeticCalculator::m_TOLERANCE_CHECK = 1E-8
protected

Tolerance factor for assertions. It has no impact on computed values.

Referenced by checkOrthodromicDistance().

◆ T1

double Digikam::GeodeticCalculator::T1 = 1.0
protected

Parameters computed from the ellipsoid.

Referenced by computeDirection().

◆ T2

double Digikam::GeodeticCalculator::T2 = 0.0
protected

◆ T4

double Digikam::GeodeticCalculator::T4 = 0.0
protected

◆ T6

double Digikam::GeodeticCalculator::T6 = 0.0
protected

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