@@ -83,7 +83,16 @@ class CORE_EXPORT QgsDistanceArea
83
83
void setSourceAuthId ( const QString& authid );
84
84
85
85
// ! returns source spatial reference system
86
- long sourceCrs () const { return mCoordTransform ->sourceCrs ().srsid (); }
86
+ // ! @deprecated use sourceCrsId() instead
87
+ // TODO QGIS 3.0 - make sourceCrs() return QgsCoordinateReferenceSystem
88
+ Q_DECL_DEPRECATED long sourceCrs () const { return mCoordTransform ->sourceCrs ().srsid (); }
89
+
90
+ /* * Returns the QgsCoordinateReferenceSystem::srsid() for the CRS used during calculations.
91
+ * @see setSourceCrs()
92
+ * @note added in QGIS 2.14
93
+ */
94
+ long sourceCrsId () const { return mCoordTransform ->sourceCrs ().srsid (); }
95
+
87
96
// ! What sort of coordinate system is being used?
88
97
bool geographic () const { return mCoordTransform ->sourceCrs ().geographicFlag (); }
89
98
@@ -138,23 +147,38 @@ class CORE_EXPORT QgsDistanceArea
138
147
139
148
/* * Measures the length of a geometry.
140
149
* @param geometry geometry to measure
141
- * @returns length of geometry. For geometry collections, non curve geometries will be ignored
150
+ * @returns length of geometry. For geometry collections, non curve geometries will be ignored. The units for the
151
+ * returned distance can be retrieved by calling lengthUnits().
142
152
* @note added in QGIS 2.12
153
+ * @see lengthUnits()
143
154
* @see measureArea()
144
155
* @see measurePerimeter()
145
156
*/
146
157
double measureLength ( const QgsGeometry* geometry ) const ;
147
158
148
- // ! measures perimeter of polygon
159
+ /* * Measures the perimeter of a polygon geometry.
160
+ * @param geometry geometry to measure
161
+ * @returns perimeter of geometry. For geometry collections, any non-polygon geometries will be ignored. The units for the
162
+ * returned perimeter can be retrieved by calling lengthUnits().
163
+ * @note added in QGIS 2.12
164
+ * @see lengthUnits()
165
+ * @see measureArea()
166
+ * @see measurePerimeter()
167
+ */
149
168
double measurePerimeter ( const QgsGeometry *geometry ) const ;
150
169
151
- // ! measures line
170
+ /* * Measures the length of a line with multiple segments.
171
+ * @param points list of points in line
172
+ * @returns length of line. The units for the returned length can be retrieved by calling lengthUnits().
173
+ * @see lengthUnits()
174
+ */
152
175
double measureLine ( const QList<QgsPoint>& points ) const ;
153
176
154
- /* * Measures length of line with one segment
177
+ /* * Measures length of a line with one segment.
155
178
* @param p1 start of line
156
179
* @param p2 end of line
157
- * @returns distance in meters, or map units if cartesian calculation was performed
180
+ * @returns distance between points. The units for the returned distance can be retrieved by calling lengthUnits().
181
+ * @see lengthUnits()
158
182
*/
159
183
double measureLine ( const QgsPoint& p1, const QgsPoint& p2 ) const ;
160
184
@@ -167,6 +191,11 @@ class CORE_EXPORT QgsDistanceArea
167
191
*/
168
192
double measureLine ( const QgsPoint& p1, const QgsPoint& p2, QGis::UnitType& units ) const ;
169
193
194
+ /* * Returns the units of distance for length calculations made by this object.
195
+ * @note added in QGIS 2.14
196
+ */
197
+ QGis::UnitType lengthUnits () const ;
198
+
170
199
// ! measures polygon area
171
200
double measurePolygon ( const QList<QgsPoint>& points ) const ;
172
201
@@ -176,11 +205,21 @@ class CORE_EXPORT QgsDistanceArea
176
205
static QString textUnit ( double value, int decimals, QGis::UnitType u, bool isArea, bool keepBaseUnit = false );
177
206
178
207
// ! Helper for conversion between physical units
208
+ // TODO QGIS 3.0 - remove this method, as its behaviour is non-intuitive.
179
209
void convertMeasurement ( double &measure, QGis::UnitType &measureUnits, QGis::UnitType displayUnits, bool isArea ) const ;
180
210
211
+ /* * Takes a length measurement calculated by this QgsDistanceArea object and converts it to a
212
+ * different distance unit.
213
+ * @param length length value calculated by this class to convert. It is assumed that the length
214
+ * was calculated by this class, ie that its unit of length is equal lengthUnits().
215
+ * @param toUnits distance unit to convert measurement to
216
+ * @returns converted distance
217
+ */
218
+ double convertLengthMeasurement ( double length, QGis::UnitType toUnits ) const ;
219
+
181
220
protected:
182
221
// ! measures polygon area and perimeter, vertices are extracted from WKB
183
- // @note available in python bindings
222
+ // @note not available in python bindings
184
223
const unsigned char * measurePolygon ( const unsigned char * feature, double * area, double * perimeter, bool hasZptr = false ) const ;
185
224
186
225
/* *
0 commit comments