21
21
#include " qgspoint.h"
22
22
23
23
#include " qgis_quick.h"
24
- #include " qgsquickmapsettings.h"
24
+ #include " qgscoordinatetransformcontext.h"
25
+ #include " qgscoordinatereferencesystem.h"
26
+ #include " qgspoint.h"
25
27
26
28
/* *
27
29
* \ingroup quick
28
30
* Helper class for transform of coordinates (QgsPoint) to a different coordinate reference system.
29
31
*
32
+ * It requires connection of transformation context from mapSettings, source position and source CRS to
33
+ * calculate projected position in desired destination CRS
34
+ *
30
35
* \note QML Type: CoordinateTransformer
31
36
*
32
37
* \since QGIS 3.2
@@ -47,8 +52,8 @@ class QUICK_EXPORT QgsQuickCoordinateTransformer : public QObject
47
52
// ! Source CRS, default 4326
48
53
Q_PROPERTY ( QgsCoordinateReferenceSystem sourceCrs READ sourceCrs WRITE setSourceCrs NOTIFY sourceCrsChanged )
49
54
50
- // ! Map settings, for getting transformation context
51
- Q_PROPERTY ( QgsQuickMapSettings *mapSettings MEMBER mMapSettings NOTIFY mapSettingsChanged )
55
+ // ! Transformation context, can be set from QgsQuickMapSettings::transformContext()
56
+ Q_PROPERTY ( QgsCoordinateTransformContext transformContext WRITE setTransformContext )
52
57
53
58
public:
54
59
// ! Creates new coordinate transformer
@@ -61,7 +66,7 @@ class QUICK_EXPORT QgsQuickCoordinateTransformer : public QObject
61
66
QgsPoint sourcePosition () const ;
62
67
63
68
// !\copydoc QgsQuickCoordinateTransformer::sourcePosition
64
- void setSourcePosition ( QgsPoint sourcePosition );
69
+ void setSourcePosition ( const QgsPoint & sourcePosition );
65
70
66
71
// !\copydoc QgsQuickCoordinateTransformer::destinationCrs
67
72
QgsCoordinateReferenceSystem destinationCrs () const ;
@@ -75,29 +80,31 @@ class QUICK_EXPORT QgsQuickCoordinateTransformer : public QObject
75
80
// !\copydoc QgsQuickCoordinateTransformer::sourceCrs
76
81
void setSourceCrs ( const QgsCoordinateReferenceSystem &sourceCrs );
77
82
83
+ // !\copydoc QgsQuickCoordinateTransformer::transformContext
84
+ void setTransformContext ( const QgsCoordinateTransformContext &context );
85
+
78
86
signals:
79
- // ! Projected position changed
87
+ // !\copydoc QgsQuickCoordinateTransformer::projectedPosition
80
88
void projectedPositionChanged ();
81
89
82
- // ! Source position changed
90
+ // !\copydoc QgsQuickCoordinateTransformer::sourcePosition
83
91
void sourcePositionChanged ();
84
92
85
- // ! Destination CRS changed
93
+ // !\copydoc QgsQuickCoordinateTransformer::destinationCrs
86
94
void destinationCrsChanged ();
87
95
88
- // ! Source CRS changed
96
+ // !\copydoc QgsQuickCoordinateTransformer::sourceCrs
89
97
void sourceCrsChanged ();
90
98
91
- // ! Map settings changed
92
- void mapSettingsChanged ();
99
+ // !\copydoc QgsQuickCoordinateTransformer::transformContext
100
+ void transformContextChanged ();
93
101
94
102
private:
95
103
void updatePosition ();
96
104
97
105
QgsPoint mProjectedPosition ;
98
106
QgsPoint mSourcePosition ;
99
107
QgsCoordinateTransform mCoordinateTransform ;
100
- QgsQuickMapSettings *mMapSettings = nullptr ;
101
108
};
102
109
103
110
#endif // QGSQUICKCOORDINATETRANSFORMER_H
0 commit comments