1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-30 22:51:16 +01:00
GPXSee/src/map/datum.h

65 lines
1.8 KiB
C
Raw Normal View History

#ifndef DATUM_H
#define DATUM_H
2018-01-08 23:47:45 +01:00
#include <cmath>
#include <QDebug>
2017-11-26 18:54:03 +01:00
#include "common/coordinates.h"
#include "ellipsoid.h"
#include "geocentric.h"
class Datum
{
public:
2021-06-17 21:58:25 +02:00
Datum() : _transformation(None), _dx(NAN), _dy(NAN),
2018-05-19 20:55:43 +02:00
_dz(NAN), _rx(NAN), _ry(NAN), _rz(NAN), _scale(NAN) {}
2021-06-17 21:58:25 +02:00
Datum(const Ellipsoid &ellipsoid, double dx, double dy, double dz,
double rx, double ry, double rz, double ds);
2021-06-17 21:58:25 +02:00
Datum(const Ellipsoid &ellipsoid, double dx, double dy, double dz);
2021-06-17 21:58:25 +02:00
const Ellipsoid &ellipsoid() const {return _ellipsoid;}
double dx() const {return _dx;}
double dy() const {return _dy;}
double dz() const {return _dz;}
double rx() const {return _rx;}
double ry() const {return _ry;}
double rz() const {return _rz;}
2018-05-19 20:55:43 +02:00
double scale() const {return _scale;}
2017-07-12 21:23:56 +02:00
bool isNull() const
2021-06-17 21:58:25 +02:00
{return _ellipsoid.isNull();}
bool isValid() const
2021-06-17 21:58:25 +02:00
{return (_ellipsoid.isValid() && !std::isnan(_dx) && !std::isnan(_dy)
2018-05-19 20:55:43 +02:00
&& !std::isnan(_dz) && !std::isnan(_scale) && !std::isnan(_rx)
&& !std::isnan(_ry) && !std::isnan(_rz));}
2017-06-29 19:53:42 +02:00
Coordinates toWGS84(const Coordinates &c) const;
2018-01-08 23:47:45 +01:00
Coordinates fromWGS84(const Coordinates &c) const;
2018-07-26 23:51:11 +02:00
static const Datum &WGS84();
private:
2018-05-12 13:13:35 +02:00
enum TransformationType {
None,
Molodensky,
Helmert
};
Point3D helmert(const Point3D &p) const;
Point3D helmertr(const Point3D &p) const;
2021-06-17 21:58:25 +02:00
Ellipsoid _ellipsoid;
2018-05-12 13:13:35 +02:00
TransformationType _transformation;
2018-05-19 20:55:43 +02:00
double _dx, _dy, _dz, _rx, _ry, _rz, _scale;
};
inline bool operator==(const Datum &d1, const Datum &d2)
2021-06-17 21:58:25 +02:00
{return (d1.ellipsoid() == d2.ellipsoid() && d1.dx() == d2.dx()
&& d1.dy() == d2.dy() && d1.dz() == d2.dz() && d1.rx() == d2.rx()
2018-05-19 20:55:43 +02:00
&& d1.ry() == d2.ry() && d1.rz() == d2.rz() && d1.scale() == d2.scale());}
#ifndef QT_NO_DEBUG
2018-01-08 23:47:45 +01:00
QDebug operator<<(QDebug dbg, const Datum &datum);
#endif // QT_NO_DEBUG
2018-01-08 23:47:45 +01:00
#endif // DATUM_H