Skip to content

Commit 53e1df4

Browse files
committedApr 17, 2017
sipify QgsDistanceArea
1 parent 4fc49c9 commit 53e1df4

File tree

4 files changed

+329
-257
lines changed

4 files changed

+329
-257
lines changed
 

‎python/auto_sip.blacklist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ core/qgsdatasourceuri.sip
1919
core/qgsdatetimestatisticalsummary.sip
2020
core/qgsdatumtransformstore.sip
2121
core/qgsdbfilterproxymodel.sip
22-
core/qgsdistancearea.sip
2322
core/qgseditformconfig.sip
2423
core/qgseditorwidgetsetup.sip
2524
core/qgserror.sip

‎python/core/qgsdistancearea.sip

Lines changed: 290 additions & 235 deletions
Original file line numberDiff line numberDiff line change
@@ -1,286 +1,341 @@
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/core/qgsdistancearea.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
111

212
class QgsDistanceArea
313
{
4-
%TypeHeaderCode
5-
#include <qgsdistancearea.h>
14+
%Docstring
15+
General purpose distance and area calculator.
16+
- calculations are done on ellipsoid
17+
- it's possible to pass points/features in any CRS, coordinates are transformed
18+
- two options how to use it
19+
+ use measure() takes QgsGeometry as a parameter and calculates distance or area
20+
+ use directly measureLine(), measurePolygon() which take list of QgsPoints
21+
(both cases transform the coordinates from source CRS to the ellipse coords)
22+
- returned values are in meters resp. square meters
623
%End
724

25+
%TypeHeaderCode
26+
#include "qgsdistancearea.h"
27+
%End
828
public:
929

10-
//! Constructor
1130
QgsDistanceArea();
31+
%Docstring
32+
Constructor
33+
%End
1234

13-
//! Destructor
14-
~QgsDistanceArea();
15-
16-
//! Copy constructor
1735
QgsDistanceArea( const QgsDistanceArea &origDA );
36+
%Docstring
37+
Copy constructor
38+
%End
39+
40+
// QgsDistanceArea &operator=( const QgsDistanceArea &origDA );
1841

19-
/** Sets whether coordinates must be projected to ellipsoid before measuring
20-
* @note for calculations to use the ellipsoid, both the ellipsoid mode must be true
21-
* and an ellipse must be set
22-
* @see setEllipsoid()
23-
* @see willUseEllipsoid()
24-
*/
2542
void setEllipsoidalMode( bool flag );
43+
%Docstring
44+
Sets whether coordinates must be projected to ellipsoid before measuring
45+
.. note::
46+
47+
for calculations to use the ellipsoid, both the ellipsoid mode must be true
48+
and an ellipse must be set
49+
\see setEllipsoid()
50+
\see willUseEllipsoid()
51+
%End
2652

27-
/** Returns whether ellipsoidal calculations are enabled
28-
* @see willUseEllipsoid()
29-
* @see setEllipsoidalMode()
30-
*/
3153
bool ellipsoidalEnabled() const;
54+
%Docstring
55+
Returns whether ellipsoidal calculations are enabled
56+
\see willUseEllipsoid()
57+
\see setEllipsoidalMode()
58+
:rtype: bool
59+
%End
3260

33-
/** Returns whether calculations will use the ellipsoid. Calculations will only use the
34-
* ellipsoid if ellipsoidalEnabled() is true and an ellipsoid has been set.
35-
* @note added in QGIS 2.14
36-
* @see ellipsoidalEnabled()
37-
* @see ellipsoid()
38-
*/
3961
bool willUseEllipsoid() const;
62+
%Docstring
63+
Returns whether calculations will use the ellipsoid. Calculations will only use the
64+
ellipsoid if ellipsoidalEnabled() is true and an ellipsoid has been set.
65+
.. versionadded:: 2.14
66+
\see ellipsoidalEnabled()
67+
\see ellipsoid()
68+
:rtype: bool
69+
%End
4070

41-
//! sets source spatial reference system (by QGIS CRS)
4271
void setSourceCrs( long srsid );
72+
%Docstring
73+
Sets source spatial reference system (by QGIS CRS).
74+
%End
4375

44-
/**
45-
* Sets source spatial reference system (by QGIS CRS)
46-
* @note: missing in Python bindings in QGIS < 2.2
47-
*/
48-
void setSourceCrs( const QgsCoordinateReferenceSystem& srcCRS );
76+
void setSourceCrs( const QgsCoordinateReferenceSystem &srcCRS );
77+
%Docstring
78+
Sets source spatial reference system (by QGIS CRS).
79+
.. versionadded:: 2.2
80+
\see sourceCrs()
81+
%End
4982

50-
//! sets source spatial reference system by authid
51-
void setSourceAuthId( const QString& authid );
83+
void setSourceAuthId( const QString &authid );
84+
%Docstring
85+
Sets source spatial reference system by authid.
86+
%End
5287

53-
/** Returns the source spatial reference system.
54-
* @see setSourceCrs()
55-
*/
5688
QgsCoordinateReferenceSystem sourceCrs() const;
89+
%Docstring
90+
Returns the source spatial reference system.
91+
\see setSourceCrs()
92+
:rtype: QgsCoordinateReferenceSystem
93+
%End
5794

58-
/** Returns the QgsCoordinateReferenceSystem::srsid() for the CRS used during calculations.
59-
* @see setSourceCrs()
60-
* @note added in QGIS 2.14
61-
*/
6295
long sourceCrsId() const;
96+
%Docstring
97+
Returns the QgsCoordinateReferenceSystem.srsid() for the CRS used during calculations.
98+
\see setSourceCrs()
99+
.. versionadded:: 2.14
100+
:rtype: long
101+
%End
63102

64-
//! What sort of coordinate system is being used?
65103
bool geographic() const;
104+
%Docstring
105+
Returns true if a geographic (latitude/longitude based) source CRS is used.
106+
:rtype: bool
107+
%End
108+
109+
bool setEllipsoid( const QString &ellipsoid );
110+
%Docstring
111+
Sets ellipsoid by its acronym. Calculations will only use the ellipsoid if
112+
both the ellipsoid has been set and ellipsoidalEnabled() is true.
113+
:return: true if ellipsoid was successfully set
114+
\see ellipsoid()
115+
\see setEllipsoidalMode()
116+
\see willUseEllipsoid()
117+
:rtype: bool
118+
%End
66119

67-
/** Sets ellipsoid by its acronym. Calculations will only use the ellipsoid if
68-
* both the ellipsoid has been set and ellipsoidalEnabled() is true.
69-
* @returns true if ellipsoid was successfully set
70-
* @see ellipsoid()
71-
* @see setEllipsoidalMode()
72-
* @see willUseEllipsoid()
73-
*/
74-
bool setEllipsoid( const QString& ellipsoid );
75-
76-
/** Sets ellipsoid by supplied radii. Calculations will only use the ellipsoid if
77-
* both the ellipsoid has been set and ellipsoidalEnabled() is true.
78-
* @returns true if ellipsoid was successfully set
79-
* @see ellipsoid()
80-
* @see setEllipsoidalMode()
81-
* @see willUseEllipsoid()
82-
*/
83-
// Inverse flattening is calculated with invf = a/(a-b)
84120
bool setEllipsoid( double semiMajor, double semiMinor );
121+
%Docstring
122+
Inverse flattening is calculated with invf = a/(a-b)
123+
:rtype: bool
124+
%End
85125

86-
/** Returns ellipsoid's acronym. Calculations will only use the
87-
* ellipsoid if ellipsoidalEnabled() is true and an ellipsoid has been set.
88-
* @see setEllipsoid()
89-
* @see ellipsoidalEnabled()
90-
* @see willUseEllipsoid()
91-
*/
92126
QString ellipsoid() const;
127+
%Docstring
128+
Returns ellipsoid's acronym. Calculations will only use the
129+
ellipsoid if ellipsoidalEnabled() is true and an ellipsoid has been set.
130+
\see setEllipsoid()
131+
\see ellipsoidalEnabled()
132+
\see willUseEllipsoid()
133+
:rtype: str
134+
%End
93135

94-
//! returns ellipsoid's semi major axis
95136
double ellipsoidSemiMajor() const;
96-
//! returns ellipsoid's semi minor axis
137+
%Docstring
138+
Returns the ellipsoid's semi major axis.
139+
:rtype: float
140+
%End
141+
97142
double ellipsoidSemiMinor() const;
98-
//! returns ellipsoid's inverse flattening
143+
%Docstring
144+
Returns ellipsoid's semi minor axis.
145+
:rtype: float
146+
%End
147+
99148
double ellipsoidInverseFlattening() const;
149+
%Docstring
150+
Returns ellipsoid's inverse flattening.
151+
:rtype: float
152+
%End
153+
154+
double measureArea( const QgsGeometry &geometry ) const;
155+
%Docstring
156+
Measures the area of a geometry.
157+
\param geometry geometry to measure
158+
:return: area of geometry. For geometry collections, non surface geometries will be ignored. The units for the
159+
returned area can be retrieved by calling areaUnits().
160+
.. versionadded:: 2.12
161+
\see measureLength()
162+
\see measurePerimeter()
163+
\see areaUnits()
164+
:rtype: float
165+
%End
166+
167+
double measureLength( const QgsGeometry &geometry ) const;
168+
%Docstring
169+
Measures the length of a geometry.
170+
\param geometry geometry to measure
171+
:return: length of geometry. For geometry collections, non curve geometries will be ignored. The units for the
172+
returned distance can be retrieved by calling lengthUnits().
173+
.. versionadded:: 2.12
174+
\see lengthUnits()
175+
\see measureArea()
176+
\see measurePerimeter()
177+
:rtype: float
178+
%End
179+
180+
double measurePerimeter( const QgsGeometry &geometry ) const;
181+
%Docstring
182+
Measures the perimeter of a polygon geometry.
183+
\param geometry geometry to measure
184+
:return: perimeter of geometry. For geometry collections, any non-polygon geometries will be ignored. The units for the
185+
returned perimeter can be retrieved by calling lengthUnits().
186+
.. versionadded:: 2.12
187+
\see lengthUnits()
188+
\see measureArea()
189+
\see measurePerimeter()
190+
:rtype: float
191+
%End
192+
193+
double measureLine( const QList<QgsPoint> &points ) const;
194+
%Docstring
195+
Measures the length of a line with multiple segments.
196+
\param points list of points in line
197+
:return: length of line. The units for the returned length can be retrieved by calling lengthUnits().
198+
\see lengthUnits()
199+
:rtype: float
200+
%End
201+
202+
double measureLine( const QgsPoint &p1, const QgsPoint &p2 ) const;
203+
%Docstring
204+
Measures length of a line with one segment.
205+
\param p1 start of line
206+
\param p2 end of line
207+
:return: distance between points. The units for the returned distance can be retrieved by calling lengthUnits().
208+
\see lengthUnits()
209+
:rtype: float
210+
%End
211+
212+
213+
double measureLineProjected( const QgsPoint &p1, double distance = 1, double azimuth = M_PI / 2, QgsPoint *projectedPoint /Out/ = 0 ) const;
214+
%Docstring
215+
Calculates distance from one point with distance in meters and azimuth (direction)
216+
When the sourceCrs() is geographic, computeSpheroidProject() will be called
217+
otherwise QgsPoint.project() will be called after QgsUnitTypes.fromUnitToUnitFactor() has been applied to the distance
218+
\note:
219+
The input Point must be in the coordinate reference system being used
220+
.. versionadded:: 3.0
221+
\param p1 start point [can be Cartesian or Geographic]
222+
\param distance must be in meters
223+
\param azimuth - azimuth in radians, clockwise from North
224+
\param projectedPoint calculated projected point
225+
:return: distance in mapUnits
226+
\see sourceCrs()
227+
\see computeSpheroidProject()
228+
:rtype: float
229+
%End
100230

101-
/** Measures the area of a geometry.
102-
* @param geometry geometry to measure
103-
* @returns area of geometry. For geometry collections, non surface geometries will be ignored. The units for the
104-
* returned area can be retrieved by calling areaUnits().
105-
* @note added in QGIS 2.12
106-
* @see measureLength()
107-
* @see measurePerimeter()
108-
* @see areaUnits()
109-
*/
110-
double measureArea( const QgsGeometry* geometry ) const;
111-
112-
/** Measures the length of a geometry.
113-
* @param geometry geometry to measure
114-
* @returns length of geometry. For geometry collections, non curve geometries will be ignored. The units for the
115-
* returned distance can be retrieved by calling lengthUnits().
116-
* @note added in QGIS 2.12
117-
* @see lengthUnits()
118-
* @see measureArea()
119-
* @see measurePerimeter()
120-
*/
121-
double measureLength( const QgsGeometry* geometry ) const;
122-
123-
/** Measures the perimeter of a polygon geometry.
124-
* @param geometry geometry to measure
125-
* @returns perimeter of geometry. For geometry collections, any non-polygon geometries will be ignored. The units for the
126-
* returned perimeter can be retrieved by calling lengthUnits().
127-
* @note added in QGIS 2.12
128-
* @see lengthUnits()
129-
* @see measureArea()
130-
* @see measurePerimeter()
131-
*/
132-
double measurePerimeter( const QgsGeometry *geometry ) const;
133-
134-
/** Measures the length of a line with multiple segments.
135-
* @param points list of points in line
136-
* @returns length of line. The units for the returned length can be retrieved by calling lengthUnits().
137-
* @see lengthUnits()
138-
*/
139-
double measureLine( const QList<QgsPoint>& points ) const;
140-
141-
/** Measures length of a line with one segment.
142-
* @param p1 start of line
143-
* @param p2 end of line
144-
* @returns distance between points. The units for the returned distance can be retrieved by calling lengthUnits().
145-
* @see lengthUnits()
146-
*/
147-
double measureLine( const QgsPoint& p1, const QgsPoint& p2 ) const;
148-
149-
/**
150-
* calculates distance from one point with distance in meters and azimuth (direction)
151-
* based on inverse Vincenty's formula when Geographic
152-
* otherwise QgsPoint.project() will be called after QgsUnitTypes::fromUnitToUnitFactor() has been applied to the distance
153-
* note: usage:
154-
* QgsDistanceArea myDa;
155-
* myDa.setSourceCrs( layer->crs() );
156-
* \since QGIS 3.0
157-
* @param p1 start point [can be Cartesian or Geographic]
158-
* @param distance expected to be in meters
159-
* @param azimuth - azimuth in radians. [default M_PI/2 - East of p1]
160-
* @param projectedPoint calculated projected point
161-
* @return distance in mapUnits
162-
*/
163-
double measureLineProjected( const QgsPoint &p1, double distance = 1, double azimuth = M_PI / 2, QgsPoint *projectedPoint /Out/ = nullptr ) const;
164-
165-
/** Returns the units of distance for length calculations made by this object.
166-
* @note added in QGIS 2.14
167-
* @see areaUnits()
168-
*/
169231
QgsUnitTypes::DistanceUnit lengthUnits() const;
232+
%Docstring
233+
Returns the units of distance for length calculations made by this object.
234+
.. versionadded:: 2.14
235+
\see areaUnits()
236+
:rtype: QgsUnitTypes.DistanceUnit
237+
%End
170238

171-
/** Returns the units of area for areal calculations made by this object.
172-
* @note added in QGIS 2.14
173-
* @see lengthUnits()
174-
*/
175239
QgsUnitTypes::AreaUnit areaUnits() const;
240+
%Docstring
241+
Returns the units of area for areal calculations made by this object.
242+
.. versionadded:: 2.14
243+
\see lengthUnits()
244+
:rtype: QgsUnitTypes.AreaUnit
245+
%End
246+
247+
double measurePolygon( const QList<QgsPoint> &points ) const;
248+
%Docstring
249+
Measures the area of the polygon described by a set of points.
250+
:rtype: float
251+
%End
252+
253+
double bearing( const QgsPoint &p1, const QgsPoint &p2 ) const;
254+
%Docstring
255+
Compute the bearing (in radians) between two points.
256+
:rtype: float
257+
%End
176258

177-
//! measures polygon area
178-
double measurePolygon( const QList<QgsPoint>& points ) const;
179-
180-
//! compute bearing - in radians
181-
double bearing( const QgsPoint& p1, const QgsPoint& p2 ) const;
182-
183-
/** Returns an distance formatted as a friendly string.
184-
* @param distance distance to format
185-
* @param decimals number of decimal places to show
186-
* @param unit unit of distance
187-
* @param keepBaseUnit set to false to allow conversion of large distances to more suitable units, e.g., meters to
188-
* kilometers
189-
* @returns formatted distance string
190-
* @note added in QGIS 2.16
191-
* @see formatArea()
192-
*/
193259
static QString formatDistance( double distance, int decimals, QgsUnitTypes::DistanceUnit unit, bool keepBaseUnit = false );
260+
%Docstring
261+
Returns an distance formatted as a friendly string.
262+
\param distance distance to format
263+
\param decimals number of decimal places to show
264+
\param unit unit of distance
265+
\param keepBaseUnit set to false to allow conversion of large distances to more suitable units, e.g., meters to
266+
kilometers
267+
:return: formatted distance string
268+
.. versionadded:: 2.16
269+
\see formatArea()
270+
:rtype: str
271+
%End
194272

195-
/** Returns an area formatted as a friendly string.
196-
* @param area area to format
197-
* @param decimals number of decimal places to show
198-
* @param unit unit of area
199-
* @param keepBaseUnit set to false to allow conversion of large areas to more suitable units, e.g., square meters to
200-
* square kilometers
201-
* @returns formatted area string
202-
* @note added in QGIS 2.14
203-
* @see formatDistance()
204-
*/
205273
static QString formatArea( double area, int decimals, QgsUnitTypes::AreaUnit unit, bool keepBaseUnit = false );
274+
%Docstring
275+
Returns an area formatted as a friendly string.
276+
\param area area to format
277+
\param decimals number of decimal places to show
278+
\param unit unit of area
279+
\param keepBaseUnit set to false to allow conversion of large areas to more suitable units, e.g., square meters to
280+
square kilometers
281+
:return: formatted area string
282+
.. versionadded:: 2.14
283+
\see formatDistance()
284+
:rtype: str
285+
%End
206286

207-
/** Takes a length measurement calculated by this QgsDistanceArea object and converts it to a
208-
* different distance unit.
209-
* @param length length value calculated by this class to convert. It is assumed that the length
210-
* was calculated by this class, ie that its unit of length is equal to lengthUnits().
211-
* @param toUnits distance unit to convert measurement to
212-
* @returns converted distance
213-
* @see convertAreaMeasurement()
214-
* @note added in QGIS 2.14
215-
*/
216287
double convertLengthMeasurement( double length, QgsUnitTypes::DistanceUnit toUnits ) const;
288+
%Docstring
289+
Takes a length measurement calculated by this QgsDistanceArea object and converts it to a
290+
different distance unit.
291+
\param length length value calculated by this class to convert. It is assumed that the length
292+
was calculated by this class, ie that its unit of length is equal to lengthUnits().
293+
\param toUnits distance unit to convert measurement to
294+
:return: converted distance
295+
\see convertAreaMeasurement()
296+
.. versionadded:: 2.14
297+
:rtype: float
298+
%End
217299

218-
/** Takes an area measurement calculated by this QgsDistanceArea object and converts it to a
219-
* different areal unit.
220-
* @param area area value calculated by this class to convert. It is assumed that the area
221-
* was calculated by this class, ie that its unit of area is equal to areaUnits().
222-
* @param toUnits area unit to convert measurement to
223-
* @returns converted area
224-
* @see convertLengthMeasurement()
225-
* @note added in QGIS 2.14
226-
*/
227300
double convertAreaMeasurement( double area, QgsUnitTypes::AreaUnit toUnits ) const;
301+
%Docstring
302+
Takes an area measurement calculated by this QgsDistanceArea object and converts it to a
303+
different areal unit.
304+
\param area area value calculated by this class to convert. It is assumed that the area
305+
was calculated by this class, ie that its unit of area is equal to areaUnits().
306+
\param toUnits area unit to convert measurement to
307+
:return: converted area
308+
\see convertLengthMeasurement()
309+
.. versionadded:: 2.14
310+
:rtype: float
311+
%End
228312

229-
protected:
230-
//! measures polygon area and perimeter, vertices are extracted from WKB
231-
// @note not available in python bindings
232-
// QgsConstWkbPtr measurePolygon( QgsConstWkbPtr feature, double* area, double* perimeter, bool hasZptr = false ) const;
233-
234-
/**
235-
* calculates distance from two points on ellipsoid
236-
* based on inverse Vincenty's formulae
237-
*
238-
* Points p1 and p2 are expected to be in degrees and in currently used ellipsoid
239-
*
240-
* @note if course1 is not NULL, bearing (in radians) from first point is calculated
241-
* (the same for course2)
242-
* @return distance in meters
243-
*/
244-
double computeDistanceBearing( const QgsPoint& p1, const QgsPoint& p2,
245-
double* course1 = 0, double* course2 = 0 ) const;
246-
247-
/**
248-
* Given a location, an azimuth and a distance, computes the
249-
* location of the projected point. Based on Vincenty's formula
250-
* for the geodetic direct problem as described in "Geocentric
251-
* Datum of Australia Technical Manual", Chapter 4. Tested against:
252-
* http://mascot.gdbc.gov.bc.ca/mascot/util1b.html
253-
* and
254-
* http://www.ga.gov.au/nmd/geodesy/datums/vincenty_direct.jsp
255-
* @note code (and documentation) taken from rttopo project
256-
* https://git.osgeo.org/gogs/rttopo/librttopo
257-
* - spheroid_project.spheroid_project(...)
258-
* \since QGIS 3.0
259-
* @param p1 - location of first Geographic (lat,long) point.
260-
* @param distance - distance in meters. [default 1 meter]
261-
* @param azimuth - azimuth in radians. [default M_PI/2 - East of p1]
262-
* @return p2 - location of projected point.
263-
*/
264313
QgsPoint computeSpheroidProject( const QgsPoint &p1, double distance = 1, double azimuth = M_PI / 2 ) const;
314+
%Docstring
315+
Given a location, an azimuth and a distance, computes the
316+
location of the projected point. Based on Vincenty's formula
317+
for the geodetic direct problem as described in "Geocentric
318+
Datum of Australia Technical Manual", Chapter 4.
319+
.. note::
320+
321+
code (and documentation) taken from rttopo project
322+
https://git.osgeo.org/gogs/rttopo/librttopo
323+
- spheroid_project.spheroid_project(...)
324+
.. versionadded:: 3.0
325+
\param p1 - location of first geographic (latitude/longitude) point as degrees.
326+
\param distance - distance in meters.
327+
\param azimuth - azimuth in radians, clockwise from North
328+
:return: p2 - location of projected point as longitude/latitude.
329+
:rtype: QgsPoint
330+
%End
265331

266-
//! uses flat / planimetric / Euclidean distance
267-
double computeDistanceFlat( const QgsPoint& p1, const QgsPoint& p2 ) const;
268-
269-
//! calculate distance with given coordinates (does not do a transform anymore)
270-
double computeDistance( const QList<QgsPoint>& points ) const;
271-
272-
/**
273-
* calculates area of polygon on ellipsoid
274-
* algorithm has been taken from GRASS: gis/area_poly1.c
275-
*/
276-
double computePolygonArea( const QList<QgsPoint>& points ) const;
277-
278-
double computePolygonFlatArea( const QList<QgsPoint>& points ) const;
332+
};
279333

280-
/**
281-
* precalculates some values
282-
* (must be called always when changing ellipsoid)
283-
*/
284-
void computeAreaInit();
285334

286-
};
335+
/************************************************************************
336+
* This file has been generated automatically from *
337+
* *
338+
* src/core/qgsdistancearea.h *
339+
* *
340+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
341+
************************************************************************/

‎src/core/qgsdistancearea.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,13 @@ double QgsDistanceArea::measureLineProjected( const QgsPoint &p1, double distanc
545545
return result;
546546
}
547547

548+
/*
549+
* From original rttopo documentation:
550+
* Tested against:
551+
* http://mascot.gdbc.gov.bc.ca/mascot/util1b.html
552+
* and
553+
* http://www.ga.gov.au/nmd/geodesy/datums/vincenty_direct.jsp
554+
*/
548555
QgsPoint QgsDistanceArea::computeSpheroidProject(
549556
const QgsPoint &p1, double distance, double azimuth ) const
550557
{

‎src/core/qgsdistancearea.h

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,21 @@ class CORE_EXPORT QgsDistanceArea
7070
*/
7171
bool willUseEllipsoid() const;
7272

73-
//! sets source spatial reference system (by QGIS CRS)
73+
/**
74+
* Sets source spatial reference system (by QGIS CRS).
75+
*/
7476
void setSourceCrs( long srsid );
7577

7678
/**
77-
* Sets source spatial reference system (by QGIS CRS)
78-
* \note: missing in Python bindings in QGIS < 2.2
79+
* Sets source spatial reference system (by QGIS CRS).
80+
* \since QGIS 2.2
7981
* \see sourceCrs()
8082
*/
8183
void setSourceCrs( const QgsCoordinateReferenceSystem &srcCRS );
8284

83-
//! sets source spatial reference system by authid
85+
/**
86+
* Sets source spatial reference system by authid.
87+
*/
8488
void setSourceAuthId( const QString &authid );
8589

8690
/** Returns the source spatial reference system.
@@ -94,7 +98,9 @@ class CORE_EXPORT QgsDistanceArea
9498
*/
9599
long sourceCrsId() const { return mCoordTransform.sourceCrs().srsid(); }
96100

97-
//! What sort of coordinate system is being used?
101+
/**
102+
* Returns true if a geographic (latitude/longitude based) source CRS is used.
103+
*/
98104
bool geographic() const { return mCoordTransform.sourceCrs().isGeographic(); }
99105

100106
/** Sets ellipsoid by its acronym. Calculations will only use the ellipsoid if
@@ -124,11 +130,19 @@ class CORE_EXPORT QgsDistanceArea
124130
*/
125131
QString ellipsoid() const { return mEllipsoid; }
126132

127-
//! returns ellipsoid's semi major axis
133+
/**
134+
* Returns the ellipsoid's semi major axis.
135+
*/
128136
double ellipsoidSemiMajor() const { return mSemiMajor; }
129-
//! returns ellipsoid's semi minor axis
137+
138+
/**
139+
* Returns ellipsoid's semi minor axis.
140+
*/
130141
double ellipsoidSemiMinor() const { return mSemiMinor; }
131-
//! returns ellipsoid's inverse flattening
142+
143+
/**
144+
* Returns ellipsoid's inverse flattening.
145+
*/
132146
double ellipsoidInverseFlattening() const { return mInvFlattening; }
133147

134148
/** Measures the area of a geometry.
@@ -184,9 +198,10 @@ class CORE_EXPORT QgsDistanceArea
184198
* \param p2 end of line
185199
* \param units will be set to units of measure
186200
* \returns calculated distance between points. Distance units are stored in units parameter.
201+
* \note Not available in Python bindings.
187202
* \since QGIS 2.12
188203
*/
189-
double measureLine( const QgsPoint &p1, const QgsPoint &p2, QgsUnitTypes::DistanceUnit &units ) const;
204+
SIP_SKIP double measureLine( const QgsPoint &p1, const QgsPoint &p2, QgsUnitTypes::DistanceUnit &units ) const;
190205

191206
/**
192207
* Calculates distance from one point with distance in meters and azimuth (direction)
@@ -203,7 +218,7 @@ class CORE_EXPORT QgsDistanceArea
203218
* \see sourceCrs()
204219
* \see computeSpheroidProject()
205220
*/
206-
double measureLineProjected( const QgsPoint &p1, double distance = 1, double azimuth = M_PI / 2, QgsPoint *projectedPoint = nullptr ) const;
221+
double measureLineProjected( const QgsPoint &p1, double distance = 1, double azimuth = M_PI / 2, QgsPoint *projectedPoint SIP_OUT = nullptr ) const;
207222

208223
/** Returns the units of distance for length calculations made by this object.
209224
* \since QGIS 2.14
@@ -217,10 +232,14 @@ class CORE_EXPORT QgsDistanceArea
217232
*/
218233
QgsUnitTypes::AreaUnit areaUnits() const;
219234

220-
//! measures polygon area
235+
/**
236+
* Measures the area of the polygon described by a set of points.
237+
*/
221238
double measurePolygon( const QList<QgsPoint> &points ) const;
222239

223-
//! compute bearing - in radians
240+
/**
241+
* Compute the bearing (in radians) between two points.
242+
*/
224243
double bearing( const QgsPoint &p1, const QgsPoint &p2 ) const;
225244

226245
/** Returns an distance formatted as a friendly string.
@@ -281,15 +300,7 @@ class CORE_EXPORT QgsDistanceArea
281300
* \param p1 - location of first geographic (latitude/longitude) point as degrees.
282301
* \param distance - distance in meters.
283302
* \param azimuth - azimuth in radians, clockwise from North
284-
* \return p2 - location of projected point as degrees.
285-
*/
286-
287-
/*
288-
* From original rttopo documentation:
289-
* Tested against:
290-
* http://mascot.gdbc.gov.bc.ca/mascot/util1b.html
291-
* and
292-
* http://www.ga.gov.au/nmd/geodesy/datums/vincenty_direct.jsp
303+
* \return p2 - location of projected point as longitude/latitude.
293304
*/
294305
QgsPoint computeSpheroidProject( const QgsPoint &p1, double distance = 1, double azimuth = M_PI / 2 ) const;
295306

0 commit comments

Comments
 (0)
Please sign in to comment.