Map API refactoring
[GPXSee.git] / src / map / projection.h
blobd7e00089dc9f787a2fcfd5fbfd9a318a85cdec69
1 #ifndef PROJECTION_H
2 #define PROJECTION_H
4 #include <QDebug>
5 #include "common/coordinates.h"
6 #include "pointd.h"
7 #include "linearunits.h"
8 #include "coordinatesystem.h"
9 #include "gcs.h"
11 class PCS;
12 class CT;
13 class AngularUnits;
15 class Projection {
16 public:
17 class Setup {
18 public:
19 Setup() : _latitudeOrigin(NAN), _longitudeOrigin(NAN), _scale(NAN),
20 _falseEasting(NAN), _falseNorthing(NAN), _standardParallel1(NAN),
21 _standardParallel2(NAN) {}
22 Setup(double latitudeOrigin, double longitudeOrigin, double scale,
23 double falseEasting, double falseNorthing, double standardParallel1,
24 double standardParallel2) : _latitudeOrigin(latitudeOrigin),
25 _longitudeOrigin(longitudeOrigin), _scale(scale),
26 _falseEasting(falseEasting), _falseNorthing(falseNorthing),
27 _standardParallel1(standardParallel1),
28 _standardParallel2(standardParallel2) {}
30 double latitudeOrigin() const {return _latitudeOrigin;}
31 double longitudeOrigin() const {return _longitudeOrigin;}
32 double scale() const {return _scale;}
33 double falseEasting() const {return _falseEasting;}
34 double falseNorthing() const {return _falseNorthing;}
35 double standardParallel1() const {return _standardParallel1;}
36 double standardParallel2() const {return _standardParallel2;}
38 void setLatitudeOrigin(double val) {_latitudeOrigin = val;}
39 void setLongitudeOrigin(double val) {_longitudeOrigin = val;}
40 void setScale(double val) {_scale = val;}
41 void setFalseEasting(double val) {_falseEasting = val;}
42 void setFalseNorthing(double val) {_falseNorthing = val;}
43 void setStandardParallel1(double val) {_standardParallel1 = val;}
44 void setStandardParallel2(double val) {_standardParallel2 = val;}
46 bool isNull() const {return std::isnan(_latitudeOrigin)
47 && std::isnan(_longitudeOrigin) && std::isnan(_scale)
48 && std::isnan(_falseEasting) && std::isnan(_falseNorthing)
49 && std::isnan(_standardParallel1) && std::isnan(_standardParallel2);}
51 private:
52 double _latitudeOrigin;
53 double _longitudeOrigin;
54 double _scale;
55 double _falseEasting;
56 double _falseNorthing;
57 double _standardParallel1;
58 double _standardParallel2;
61 class Method {
62 public:
63 Method() : _id(0) {}
64 Method(int id);
66 int id() const {return _id;}
67 bool isNull() const {return (_id == 0);}
68 bool isValid() const {return !isNull();}
69 private:
70 int _id;
73 Projection() : _ct(0), _geographic(false) {}
74 Projection(const Projection &p);
75 Projection(const PCS &pcs);
76 Projection(const GCS &gcs, const CoordinateSystem &cs
77 = CoordinateSystem(CoordinateSystem::YX));
78 ~Projection();
80 Projection &operator=(const Projection &p);
81 bool operator==(const Projection &p) const;
83 bool isNull() const
85 return (_gcs.isNull() && _ct == 0 && _units.isNull() && _cs.isNull());
87 bool isValid() const
89 // We do not check the CoordinateSystem here as it is not always defined
90 // and except of WMTS/WMS it is not needed.
91 return (_gcs.isValid() && _ct != 0 && _units.isValid());
93 bool isGeographic() const {return _geographic;}
95 PointD ll2xy(const Coordinates &c) const;
96 Coordinates xy2ll(const PointD &p) const;
98 const LinearUnits &units() const {return _units;}
99 const CoordinateSystem &coordinateSystem() const {return _cs;}
101 private:
102 GCS _gcs;
103 const CT *_ct;
104 LinearUnits _units;
105 CoordinateSystem _cs;
106 bool _geographic;
109 #ifndef QT_NO_DEBUG
110 QDebug operator<<(QDebug dbg, const Projection::Setup &setup);
111 QDebug operator<<(QDebug dbg, const Projection::Method &method);
112 #endif // QT_NO_DEBUG
114 #endif // PROJECTION_H