1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-02-21 10:10:49 +01:00
GPXSee/src/map/projection.h

64 lines
1.4 KiB
C
Raw Normal View History

2017-11-26 18:54:03 +01:00
#ifndef PROJECTION_H
#define PROJECTION_H
#include <QtGlobal>
2017-11-26 18:54:03 +01:00
#include "common/coordinates.h"
#include "pointd.h"
#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"
#include "ct.h"
#include "proj/latlon.h"
2017-11-26 18:54:03 +01:00
class PCS;
2017-11-26 18:54:03 +01:00
class Projection {
public:
Projection() : _ct(0) {}
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));
~Projection();
2017-11-26 18:54:03 +01:00
Projection &operator=(const Projection &p);
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
{
/* 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());
}
bool isGeographic() const
{
return (dynamic_cast<const LatLon*>(_ct) != 0);
}
2018-02-20 23:37:19 +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-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
private:
2021-06-17 21:58:25 +02:00
GCS _gcs;
2018-03-09 18:57:23 +01:00
const CT *_ct;
LinearUnits _units;
2018-04-07 18:42:25 +02:00
CoordinateSystem _cs;
2017-11-26 18:54:03 +01:00
};
#endif // PROJECTION_H