mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 19:55:53 +01:00
Precompute some more constants
This commit is contained in:
parent
a66ca7b3a8
commit
59c95e53c4
@ -46,7 +46,6 @@ static Coordinates molodensky(const Coordinates &c, const Datum &from,
|
|||||||
|
|
||||||
Point3D Datum::helmert(const Point3D &p) const
|
Point3D Datum::helmert(const Point3D &p) const
|
||||||
{
|
{
|
||||||
double scale = 1 + _ds * 1e-6;
|
|
||||||
double R00 = 1;
|
double R00 = 1;
|
||||||
double R01 = _rz;
|
double R01 = _rz;
|
||||||
double R02 = -_ry;
|
double R02 = -_ry;
|
||||||
@ -57,14 +56,13 @@ Point3D Datum::helmert(const Point3D &p) const
|
|||||||
double R21 = -_rx;
|
double R21 = -_rx;
|
||||||
double R22 = 1;
|
double R22 = 1;
|
||||||
|
|
||||||
return Point3D(scale * (R00 * p.x() + R01 * p.y() + R02 * p.z()) + _dx,
|
return Point3D(_scale * (R00 * p.x() + R01 * p.y() + R02 * p.z()) + _dx,
|
||||||
scale * (R10 * p.x() + R11 * p.y() + R12 * p.z()) + _dy,
|
_scale * (R10 * p.x() + R11 * p.y() + R12 * p.z()) + _dy,
|
||||||
scale * (R20 * p.x() + R21 * p.y() + R22 * p.z()) + _dz);
|
_scale * (R20 * p.x() + R21 * p.y() + R22 * p.z()) + _dz);
|
||||||
}
|
}
|
||||||
|
|
||||||
Point3D Datum::helmertr(const Point3D &p) const
|
Point3D Datum::helmertr(const Point3D &p) const
|
||||||
{
|
{
|
||||||
double scale = 1 + _ds * 1e-6;
|
|
||||||
double R00 = 1;
|
double R00 = 1;
|
||||||
double R01 = _rz;
|
double R01 = _rz;
|
||||||
double R02 = -_ry;
|
double R02 = -_ry;
|
||||||
@ -75,9 +73,9 @@ Point3D Datum::helmertr(const Point3D &p) const
|
|||||||
double R21 = -_rx;
|
double R21 = -_rx;
|
||||||
double R22 = 1;
|
double R22 = 1;
|
||||||
|
|
||||||
double x = (p.x() - _dx) / scale;
|
double x = (p.x() - _dx) / _scale;
|
||||||
double y = (p.y() - _dy) / scale;
|
double y = (p.y() - _dy) / _scale;
|
||||||
double z = (p.z() - _dz) / scale;
|
double z = (p.z() - _dz) / _scale;
|
||||||
|
|
||||||
return Point3D(R00 * x + R10 * y + R20 * z, R01 * x + R11 * y + R21 * z,
|
return Point3D(R00 * x + R10 * y + R20 * z, R01 * x + R11 * y + R21 * z,
|
||||||
R02 * x + R12 * y + R22 * z);
|
R02 * x + R12 * y + R22 * z);
|
||||||
@ -86,11 +84,11 @@ Point3D Datum::helmertr(const Point3D &p) const
|
|||||||
Datum::Datum(const Ellipsoid *ellipsoid, double dx, double dy, double dz,
|
Datum::Datum(const Ellipsoid *ellipsoid, double dx, double dy, double dz,
|
||||||
double rx, double ry, double rz, double ds)
|
double rx, double ry, double rz, double ds)
|
||||||
: _ellipsoid(ellipsoid), _dx(dx), _dy(dy), _dz(dz), _rx(as2rad(rx)),
|
: _ellipsoid(ellipsoid), _dx(dx), _dy(dy), _dz(dz), _rx(as2rad(rx)),
|
||||||
_ry(as2rad(ry)), _rz(as2rad(rz)), _ds(ds)
|
_ry(as2rad(ry)), _rz(as2rad(rz)), _scale(1.0 + ds * 1e-6)
|
||||||
{
|
{
|
||||||
if (_ellipsoid->radius() == WGS84_RADIUS && _ellipsoid->flattening()
|
if (_ellipsoid->radius() == WGS84_RADIUS && _ellipsoid->flattening()
|
||||||
== WGS84_FLATTENING && _dx == 0.0 && _dy == 0.0 && _dz == 0.0
|
== WGS84_FLATTENING && _dx == 0.0 && _dy == 0.0 && _dz == 0.0
|
||||||
&& _rx == 0.0 && _ry == 0.0 && _rz == 0.0 && _ds == 0.0)
|
&& _rx == 0.0 && _ry == 0.0 && _rz == 0.0 && ds == 0.0)
|
||||||
_transformation = None;
|
_transformation = None;
|
||||||
else
|
else
|
||||||
_transformation = Helmert;
|
_transformation = Helmert;
|
||||||
@ -98,7 +96,7 @@ Datum::Datum(const Ellipsoid *ellipsoid, double dx, double dy, double dz,
|
|||||||
|
|
||||||
Datum::Datum(const Ellipsoid *ellipsoid, double dx, double dy, double dz)
|
Datum::Datum(const Ellipsoid *ellipsoid, double dx, double dy, double dz)
|
||||||
: _ellipsoid(ellipsoid), _dx(dx), _dy(dy), _dz(dz), _rx(0.0), _ry(0.0),
|
: _ellipsoid(ellipsoid), _dx(dx), _dy(dy), _dz(dz), _rx(0.0), _ry(0.0),
|
||||||
_rz(0.0), _ds(0.0)
|
_rz(0.0), _scale(1.0)
|
||||||
{
|
{
|
||||||
if (_ellipsoid->radius() == WGS84_RADIUS && _ellipsoid->flattening()
|
if (_ellipsoid->radius() == WGS84_RADIUS && _ellipsoid->flattening()
|
||||||
== WGS84_FLATTENING && _dx == 0.0 && _dy == 0.0 && _dz == 0.0)
|
== WGS84_FLATTENING && _dx == 0.0 && _dy == 0.0 && _dz == 0.0)
|
||||||
@ -139,7 +137,7 @@ QDebug operator<<(QDebug dbg, const Datum &datum)
|
|||||||
dbg.nospace() << "Datum(" << *datum.ellipsoid() << ", " << datum.dx()
|
dbg.nospace() << "Datum(" << *datum.ellipsoid() << ", " << datum.dx()
|
||||||
<< ", " << datum.dy() << ", " << datum.dz() << ", " << rad2as(datum.rx())
|
<< ", " << datum.dy() << ", " << datum.dz() << ", " << rad2as(datum.rx())
|
||||||
<< ", " << rad2as(datum.ry()) << ", " << rad2as(datum.rz()) << ", "
|
<< ", " << rad2as(datum.ry()) << ", " << rad2as(datum.rz()) << ", "
|
||||||
<< datum.ds() << ")";
|
<< (datum.scale() - 1.0) / 1e-6 << ")";
|
||||||
return dbg.space();
|
return dbg.space();
|
||||||
}
|
}
|
||||||
#endif // QT_NO_DEBUG
|
#endif // QT_NO_DEBUG
|
||||||
|
@ -11,7 +11,7 @@ class Datum
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Datum() : _ellipsoid(0), _transformation(None), _dx(NAN), _dy(NAN),
|
Datum() : _ellipsoid(0), _transformation(None), _dx(NAN), _dy(NAN),
|
||||||
_dz(NAN), _rx(NAN), _ry(NAN), _rz(NAN), _ds(NAN) {}
|
_dz(NAN), _rx(NAN), _ry(NAN), _rz(NAN), _scale(NAN) {}
|
||||||
Datum(const Ellipsoid *ellipsoid, double dx, double dy, double dz,
|
Datum(const Ellipsoid *ellipsoid, double dx, double dy, double dz,
|
||||||
double rx, double ry, double rz, double ds);
|
double rx, double ry, double rz, double ds);
|
||||||
Datum(const Ellipsoid *ellipsoid, double dx, double dy, double dz);
|
Datum(const Ellipsoid *ellipsoid, double dx, double dy, double dz);
|
||||||
@ -20,16 +20,16 @@ public:
|
|||||||
double dx() const {return _dx;}
|
double dx() const {return _dx;}
|
||||||
double dy() const {return _dy;}
|
double dy() const {return _dy;}
|
||||||
double dz() const {return _dz;}
|
double dz() const {return _dz;}
|
||||||
double ds() const {return _ds;}
|
|
||||||
double rx() const {return _rx;}
|
double rx() const {return _rx;}
|
||||||
double ry() const {return _ry;}
|
double ry() const {return _ry;}
|
||||||
double rz() const {return _rz;}
|
double rz() const {return _rz;}
|
||||||
|
double scale() const {return _scale;}
|
||||||
|
|
||||||
bool isNull() const
|
bool isNull() const
|
||||||
{return !_ellipsoid;}
|
{return !_ellipsoid;}
|
||||||
bool isValid() const
|
bool isValid() const
|
||||||
{return (_ellipsoid && !std::isnan(_dx) && !std::isnan(_dy)
|
{return (_ellipsoid && !std::isnan(_dx) && !std::isnan(_dy)
|
||||||
&& !std::isnan(_dz) && !std::isnan(_ds) && !std::isnan(_rx)
|
&& !std::isnan(_dz) && !std::isnan(_scale) && !std::isnan(_rx)
|
||||||
&& !std::isnan(_ry) && !std::isnan(_rz));}
|
&& !std::isnan(_ry) && !std::isnan(_rz));}
|
||||||
|
|
||||||
Coordinates toWGS84(const Coordinates &c) const;
|
Coordinates toWGS84(const Coordinates &c) const;
|
||||||
@ -47,13 +47,13 @@ private:
|
|||||||
|
|
||||||
const Ellipsoid *_ellipsoid;
|
const Ellipsoid *_ellipsoid;
|
||||||
TransformationType _transformation;
|
TransformationType _transformation;
|
||||||
double _dx, _dy, _dz, _rx, _ry, _rz, _ds;
|
double _dx, _dy, _dz, _rx, _ry, _rz, _scale;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool operator==(const Datum &d1, const Datum &d2)
|
inline bool operator==(const Datum &d1, const Datum &d2)
|
||||||
{return (*d1.ellipsoid() == *d2.ellipsoid() && d1.dx() == d2.dx()
|
{return (*d1.ellipsoid() == *d2.ellipsoid() && d1.dx() == d2.dx()
|
||||||
&& d1.dy() == d2.dy() && d1.dz() == d2.dz() && d1.rx() == d2.rx()
|
&& d1.dy() == d2.dy() && d1.dz() == d2.dz() && d1.rx() == d2.rx()
|
||||||
&& d1.ry() == d2.ry() && d1.rz() == d2.rz() && d1.ds() == d2.ds());}
|
&& d1.ry() == d2.ry() && d1.rz() == d2.rz() && d1.scale() == d2.scale());}
|
||||||
|
|
||||||
#ifndef QT_NO_DEBUG
|
#ifndef QT_NO_DEBUG
|
||||||
QDebug operator<<(QDebug dbg, const Datum &datum);
|
QDebug operator<<(QDebug dbg, const Datum &datum);
|
||||||
|
Loading…
Reference in New Issue
Block a user