2017-11-26 18:54:03 +01:00
|
|
|
#ifndef PROJECTION_H
|
|
|
|
#define PROJECTION_H
|
|
|
|
|
2024-03-19 22:39:42 +01:00
|
|
|
#include <QtGlobal>
|
2017-11-26 18:54:03 +01:00
|
|
|
#include "common/coordinates.h"
|
2018-04-16 20:26:10 +02:00
|
|
|
#include "pointd.h"
|
2018-01-25 00:19:11 +01:00
|
|
|
#include "linearunits.h"
|
2018-04-05 21:13:48 +02:00
|
|
|
#include "coordinatesystem.h"
|
2021-06-17 21:58:25 +02:00
|
|
|
#include "gcs.h"
|
2024-03-19 22:39:42 +01:00
|
|
|
#include "ct.h"
|
2024-03-11 23:12:51 +01:00
|
|
|
#include "proj/latlon.h"
|
2017-11-26 18:54:03 +01:00
|
|
|
|
2018-04-05 20:38:23 +02:00
|
|
|
class PCS;
|
2017-11-26 18:54:03 +01:00
|
|
|
|
|
|
|
class Projection {
|
|
|
|
public:
|
2024-03-11 23:12:51 +01:00
|
|
|
Projection() : _ct(0) {}
|
2018-01-25 00:19:11 +01:00
|
|
|
Projection(const Projection &p);
|
2021-06-17 21:58:25 +02:00
|
|
|
Projection(const PCS &pcs);
|
|
|
|
Projection(const GCS &gcs, const CoordinateSystem &cs
|
2018-04-07 18:42:25 +02:00
|
|
|
= CoordinateSystem(CoordinateSystem::YX));
|
2018-01-25 00:19:11 +01:00
|
|
|
~Projection();
|
2017-11-26 18:54:03 +01:00
|
|
|
|
2018-01-25 00:19:11 +01:00
|
|
|
Projection &operator=(const Projection &p);
|
2020-04-21 23:26:35 +02:00
|
|
|
bool operator==(const Projection &p) const;
|
2017-11-26 18:54:03 +01:00
|
|
|
|
2021-06-27 16:00:27 +02:00
|
|
|
bool isNull() const
|
|
|
|
{
|
|
|
|
return (_gcs.isNull() && _ct == 0 && _units.isNull() && _cs.isNull());
|
|
|
|
}
|
|
|
|
bool isValid() const
|
|
|
|
{
|
2024-03-19 22:39:42 +01:00
|
|
|
/* We do not check the CoordinateSystem here as it is not always defined
|
|
|
|
and except of WMTS/WMS it is not needed. */
|
2021-06-27 16:00:27 +02:00
|
|
|
return (_gcs.isValid() && _ct != 0 && _units.isValid());
|
|
|
|
}
|
2024-03-11 23:12:51 +01:00
|
|
|
bool isGeographic() const
|
|
|
|
{
|
|
|
|
return (dynamic_cast<const LatLon*>(_ct) != 0);
|
|
|
|
}
|
2018-02-20 23:37:19 +01:00
|
|
|
|
2024-03-19 22:39:42 +01:00
|
|
|
PointD ll2xy(const Coordinates &c) const
|
|
|
|
{
|
|
|
|
Q_ASSERT(isValid());
|
|
|
|
return _units.fromMeters(_ct->ll2xy(_gcs.fromWGS84(c)));
|
|
|
|
}
|
|
|
|
Coordinates xy2ll(const PointD &p) const
|
|
|
|
{
|
|
|
|
Q_ASSERT(isValid());
|
|
|
|
return _gcs.toWGS84(_ct->xy2ll(_units.toMeters(p)));
|
|
|
|
}
|
2018-01-25 00:19:11 +01:00
|
|
|
|
2018-02-20 23:37:19 +01:00
|
|
|
const LinearUnits &units() const {return _units;}
|
2018-04-07 18:42:25 +02:00
|
|
|
const CoordinateSystem &coordinateSystem() const {return _cs;}
|
2018-02-20 23:37:19 +01:00
|
|
|
|
2018-01-25 00:19:11 +01:00
|
|
|
private:
|
2021-06-17 21:58:25 +02:00
|
|
|
GCS _gcs;
|
2018-03-09 18:57:23 +01:00
|
|
|
const CT *_ct;
|
2018-01-25 00:19:11 +01:00
|
|
|
LinearUnits _units;
|
2018-04-07 18:42:25 +02:00
|
|
|
CoordinateSystem _cs;
|
2017-11-26 18:54:03 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PROJECTION_H
|