digiKam
geodetictools.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2008-05-05
7  * Description : Geodetic tools
8  *
9  * Copyright (C) 2008-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10  * Copyright (C) 2015-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_GEODETIC_TOOLS_H
26 #define DIGIKAM_GEODETIC_TOOLS_H
27 
28 // C++ includes
29 
30 #include <cmath>
31 
32 // Qt includes
33 
34 #include <QString>
35 #include <QPointF>
36 
37 // Local includes
38 
39 #include "digikam_export.h"
40 
41 namespace Digikam
42 {
43 
44 namespace Coordinates
45 {
46 
48 
49 inline double toRadians(double deg)
50 {
51  return (deg * M_PI / 180.0);
52 }
53 
54 inline double toRadiansFactor()
55 {
56  return (M_PI / 180.0);
57 }
58 
59 inline double toDegrees(double rad)
60 {
61  return (rad * 180.0 / M_PI);
62 }
63 
64 inline double toDegreesFactor()
65 {
66  return (180.0 / M_PI);
67 }
68 
69 } // namespace Coordinates
70 
71 // ------------------------------------------------------------------------------------------------
72 
80 class DIGIKAM_EXPORT Ellipsoid
81 {
82 
83 public:
84 
89  static Ellipsoid WGS84();
90 
94  static Ellipsoid GRS80();
95 
99  static Ellipsoid INTERNATIONAL_1924();
100 
104  static Ellipsoid CLARKE_1866();
105 
111  static Ellipsoid SPHERE();
112 
120  static Ellipsoid createEllipsoid(const QString& name,
121  double semiMajorAxis,
122  double semiMinorAxis);
123 
132  static Ellipsoid createFlattenedSphere(const QString& name,
133  double semiMajorAxis,
134  double inverseFlattening);
135 
142  double semiMajorAxis() const;
143 
150  double semiMinorAxis() const;
151 
157  double eccentricity() const;
158 
171  double inverseFlattening() const;
172 
183  bool isIvfDefinitive() const;
184 
192  bool isSphere() const;
193 
207  double orthodromicDistance(double x1, double y1, double x2, double y2);
208 
215  double radiusOfCurvature(double latitude);
216 
217 protected:
218 
232  Ellipsoid(const QString& name,
233  double semiMajorAxis,
234  double semiMinorAxis,
235  double inverseFlattening,
236  bool ivfDefinitive);
237  Ellipsoid(const QString& name,
238  double radius,
239  bool ivfDefinitive);
240 
241 protected:
242 
243  QString name;
244 
250 
256 
264 
271 
273 };
274 
275 // ------------------------------------------------------------------------------------------------
276 
277 class DIGIKAM_EXPORT GeodeticCalculator
278 {
303 public:
304 
305  explicit GeodeticCalculator(const Ellipsoid& e = Ellipsoid::WGS84());
306 
310  Ellipsoid ellipsoid() const;
311 
321  void setStartingGeographicPoint(double longitude, double latitude);
322 
333  void setDestinationGeographicPoint(double longitude, double latitude);
334 
346  bool destinationGeographicPoint(double* longitude, double* latitude);
347  QPointF destinationGeographicPoint();
348 
358  void setDirection(double azimuth, double distance);
359 
370  double azimuth();
371 
383  double orthodromicDistance();
384 
390  bool checkOrthodromicDistance();
391 
396  bool computeDestinationPoint();
397 
406  double meridianArcLength(double latitude1, double latitude2);
407 
416  double meridianArcLengthRadians(double P1, double P2);
417 
423  bool computeDirection();
424 
425 protected:
426 
427  double castToAngleRange(const double alpha);
428 
436  bool checkLatitude(double* latitude);
437 
445  bool checkLongitude(double* longitude);
446 
454  bool checkAzimuth(double* azimuth);
455 
462  bool checkOrthodromicDistance(const double distance);
463 
468  double TOLERANCE_0, TOLERANCE_1, TOLERANCE_2, TOLERANCE_3;
469 
474 
479 
484 
489 
494 
499 
503  double A, B, C, D, E, F;
504 
512  double fo, f, f2, f3, f4;
513 
517  double T1, T2, T4, T6;
518 
522  double a01, a02, a03, a21, a22, a23, a42, a43, a63;
523 
528  double m_lat1, m_long1;
529 
534  double m_lat2, m_long2;
535 
541  double m_distance, m_azimuth;
542 
548 
554 };
555 
556 } // namespace Digikam
557 
558 #endif // DIGIKAM_GEODETIC_TOOLS_H
Definition: geodetictools.h:81
bool m_ivfDefinitive
Definition: geodetictools.h:270
static Ellipsoid WGS84()
Definition: geodetictools.cpp:667
bool m_isSphere
Definition: geodetictools.h:272
double m_inverseFlattening
Definition: geodetictools.h:263
QString name
Definition: geodetictools.h:243
double m_semiMajorAxis
Definition: geodetictools.h:249
double m_semiMinorAxis
Definition: geodetictools.h:255
Definition: geodetictools.h:278
double TOLERANCE_0
Definition: geodetictools.h:468
double TOLERANCE_CHECK
Definition: geodetictools.h:473
double f
Definition: geodetictools.h:512
double m_maxOrthodromicDistance
Definition: geodetictools.h:498
double m_semiMinorAxis
Definition: geodetictools.h:488
bool m_directionValid
Definition: geodetictools.h:553
bool m_destinationValid
Definition: geodetictools.h:547
double A
Definition: geodetictools.h:503
double m_lat2
Definition: geodetictools.h:534
double m_lat1
Definition: geodetictools.h:528
double m_azimuth
Definition: geodetictools.h:541
Ellipsoid m_ellipsoid
Definition: geodetictools.h:478
double m_eccentricitySquared
Definition: geodetictools.h:493
double a01
Definition: geodetictools.h:522
double T1
Definition: geodetictools.h:517
double m_semiMajorAxis
Definition: geodetictools.h:483
#define F
double toDegrees(double rad)
Definition: geodetictools.h:59
double toRadians(double deg)
Converting between radians and degrees.
Definition: geodetictools.h:49
double toDegreesFactor()
Definition: geodetictools.h:64
double toRadiansFactor()
Definition: geodetictools.h:54
Definition: datefolderview.cpp:43