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