Skip to content

Commit 4dd76da

Browse files
committed
geometry sip sync and some cosmetics
1 parent 7af5851 commit 4dd76da

17 files changed

+346
-88
lines changed

python/core/geometry/qgsabstractgeometryv2.sip

+161-10
Original file line numberDiff line numberDiff line change
@@ -70,46 +70,167 @@ class QgsAbstractGeometryV2
7070
QgsAbstractGeometryV2( const QgsAbstractGeometryV2& geom );
7171
//virtual QgsAbstractGeometryV2& operator=( const QgsAbstractGeometryV2& geom );
7272

73+
/** Clones the geometry by performing a deep copy
74+
*/
7375
virtual QgsAbstractGeometryV2* clone() const = 0;
76+
77+
/** Clears the geometry, ie reset it to a null geometry
78+
*/
7479
virtual void clear() = 0;
7580

81+
/** Returns the minimal bounding box for the geometry
82+
*/
7683
QgsRectangle boundingBox() const;
7784

85+
/** Calculates the minimal bounding box for the geometry. Derived classes should override this method
86+
* to return the correct bounding box.
87+
*/
88+
virtual QgsRectangle calculateBoundingBox() const;
89+
7890
//mm-sql interface
91+
/** Returns the inherent dimension of the geometry. For example, this is 0 for a point geometry,
92+
* 1 for a linestring and 2 for a polygon.
93+
*/
7994
virtual int dimension() const = 0;
8095
//virtual int coordDim() const { return mCoordDimension; }
96+
97+
/** Returns a unique string representing the geometry type.
98+
* @see wkbType
99+
* @see wktTypeStr
100+
*/
81101
virtual QString geometryType() const = 0;
102+
103+
/** Returns the WKB type of the geometry.
104+
* @see geometryType
105+
* @see wktTypeStr
106+
*/
82107
QgsWKBTypes::Type wkbType() const;
108+
109+
/** Returns the WKT type string of the geometry.
110+
* @see geometryType
111+
* @see wkbType
112+
*/
83113
QString wktTypeStr() const;
114+
115+
/** Returns true if the geometry is 3D and contains a z-value.
116+
* @see isMeasure
117+
*/
84118
bool is3D() const;
119+
120+
/** Returns true if the geometry contains m values.
121+
* @see is3D
122+
*/
85123
bool isMeasure() const;
86124

87125
//import
126+
127+
/** Sets the geometry from a WKB string.
128+
* @see fromWkt
129+
*/
88130
virtual bool fromWkb( const unsigned char * wkb ) = 0;
131+
132+
/** Sets the geometry from a WKT string.
133+
* @see fromWkb
134+
*/
89135
virtual bool fromWkt( const QString& wkt ) = 0;
90136

91137
//export
138+
139+
/** Returns the size of the WKB representation of the geometry.
140+
* @see asWkb
141+
*/
92142
virtual int wkbSize() const = 0;
143+
144+
/** Returns a WKB representation of the geometry.
145+
* @param binarySize will be set to the size of the returned WKB string
146+
* @see wkbSize
147+
* @see asWkt
148+
* @see asGML2
149+
* @see asGML3
150+
* @see asJSON
151+
*/
93152
virtual unsigned char* asWkb( int& binarySize ) const = 0;
153+
154+
/** Returns a WKT representation of the geometry.
155+
* @param precision number of decimal places for coordinates
156+
* @see asWkb
157+
* @see asGML2
158+
* @see asGML3
159+
* @see asJSON
160+
*/
94161
virtual QString asWkt( int precision = 17 ) const = 0;
162+
163+
/** Returns a GML2 representation of the geometry.
164+
* @param doc DOM document
165+
* @param precision number of decimal places for coordinates
166+
* @param ns XML namespace
167+
* @see asWkb
168+
* @see asWkt
169+
* @see asGML3
170+
* @see asJSON
171+
*/
95172
virtual QDomElement asGML2( QDomDocument& doc, int precision = 17, const QString& ns = "gml" ) const = 0;
173+
174+
/** Returns a GML3 representation of the geometry.
175+
* @param doc DOM document
176+
* @param precision number of decimal places for coordinates
177+
* @param ns XML namespace
178+
* @see asWkb
179+
* @see asWkt
180+
* @see asGML2
181+
* @see asJSON
182+
*/
96183
virtual QDomElement asGML3( QDomDocument& doc, int precision = 17, const QString& ns = "gml" ) const = 0;
97-
virtual QString asJSON( int precision = 17 ) const = 0;
98184

99-
virtual QgsRectangle calculateBoundingBox() const;
185+
/** Returns a GeoJSON representation of the geometry.
186+
* @param precision number of decimal places for coordinates
187+
* @see asWkb
188+
* @see asWkt
189+
* @see asGML2
190+
* @see asGML3
191+
*/
192+
virtual QString asJSON( int precision = 17 ) const = 0;
100193

101194
//render pipeline
195+
196+
/** Transforms the geometry using a coordinate transform
197+
* @param ct coordinate transform
198+
@param d transformation direction
199+
*/
102200
virtual void transform( const QgsCoordinateTransform& ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform ) = 0;
201+
202+
/** Transforms the geometry using a QTransform object
203+
* @param t QTransform transformation
204+
*/
103205
virtual void transform( const QTransform& t ) = 0;
206+
207+
104208
//virtual void clip( const QgsRectangle& rect );
209+
210+
/** Draws the geometry using the specified QPainter.
211+
* @param p destination QPainter
212+
*/
105213
virtual void draw( QPainter& p ) const = 0;
106214

107215
/** Returns next vertex id and coordinates
108-
@return false if at end*/
216+
* @param id initial value should be the starting vertex id. The next vertex id will be stored
217+
* in this variable if found.
218+
* @param vertex container for found node
219+
* @return false if at end
220+
*/
109221
virtual bool nextVertex( QgsVertexId& id, QgsPointV2& vertex ) const = 0;
110222

223+
/** Retrieves the sequence of geometries, rings and nodes.
224+
* @param coord destination for coordinate sequence.
225+
*/
111226
virtual void coordinateSequence( QList< QList< QList< QgsPointV2 > > >& coord /Out/ ) const = 0;
227+
228+
/** Returns the number of nodes contained in the geometry
229+
*/
112230
int nCoordinates() const;
231+
232+
/** Returns the point corresponding to a specified vertex id
233+
*/
113234
virtual QgsPointV2 vertexAt( const QgsVertexId& id ) const = 0;
114235

115236
/** Searches for the closest segment of the geometry to a given point.
@@ -121,11 +242,34 @@ class QgsAbstractGeometryV2
121242
* @param epsilon epsilon for segment snapping
122243
* @returns squared distance to closest segment
123244
*/
124-
virtual double closestSegment( const QgsPointV2& pt, QgsPointV2& segmentPt, QgsVertexId& vertexAfter, bool* leftOf, double epsilon ) const = 0;
245+
virtual double closestSegment( const QgsPointV2& pt, QgsPointV2& segmentPt, QgsVertexId& vertexAfter, bool* leftOf, double epsilon ) const = 0;
125246

126247
//low-level editing
248+
249+
/** Inserts a vertex into the geometry
250+
* @param position vertex id for position of inserted vertex
251+
* @param vertex vertex to insert
252+
* @returns true if insert was successful
253+
* @see moveVertex
254+
* @see deleteVertex
255+
*/
127256
virtual bool insertVertex( const QgsVertexId& position, const QgsPointV2& vertex ) = 0;
257+
258+
/** Moves a vertex within the geometry
259+
* @param position vertex id for vertex to move
260+
* @param newPos new position of vertex
261+
* @returns true if move was successful
262+
* @see insertVertex
263+
* @see deleteVertex
264+
*/
128265
virtual bool moveVertex( const QgsVertexId& position, const QgsPointV2& newPos ) = 0;
266+
267+
/** Deletes a vertex within the geometry
268+
* @param position vertex id for vertex to delete
269+
* @returns true if delete was successful
270+
* @see insertVertex
271+
* @see moveVertex
272+
*/
129273
virtual bool deleteVertex( const QgsVertexId& position ) = 0;
130274

131275
/** Returns the length of the geometry.
@@ -146,15 +290,20 @@ class QgsAbstractGeometryV2
146290
*/
147291
virtual double area() const;
148292

149-
/** Returns the centroid of the geometry*/
293+
/** Returns the centroid of the geometry */
150294
virtual QgsPointV2 centroid() const;
151295

152296
/** Returns true if the geometry is empty
153297
*/
154298
bool isEmpty() const;
155299

300+
/** Returns true if the geometry contains curved segments
301+
*/
156302
virtual bool hasCurvedSegments() const;
157-
/** Returns a geometry without curves. Caller takes ownership*/
303+
304+
/** Returns a version of the geometry without curves. Caller takes ownership of
305+
* the returned geometry.
306+
*/
158307
virtual QgsAbstractGeometryV2* segmentize() const /Factory/;
159308

160309
/** Returns approximate angle at a vertex. This is usually the average angle between adjacent
@@ -165,8 +314,8 @@ class QgsAbstractGeometryV2
165314
*/
166315
virtual double vertexAngle( const QgsVertexId& vertex ) const = 0;
167316

168-
virtual int vertexCount(int part = 0, int ring = 0) const = 0;
169-
virtual int ringCount(int part = 0) const = 0;
317+
virtual int vertexCount( int part = 0, int ring = 0 ) const = 0;
318+
virtual int ringCount( int part = 0 ) const = 0;
170319

171320
/** Returns count of parts contained in the geometry.
172321
* @see vertexCount
@@ -178,15 +327,17 @@ class QgsAbstractGeometryV2
178327
* @param zValue initial z-value for all nodes
179328
* @returns true on success
180329
* @note added in QGIS 2.12
181-
* @see addMValue
330+
* @see dropZValue()
331+
* @see addMValue()
182332
*/
183333
virtual bool addZValue( double zValue = 0 ) = 0;
184334

185335
/** Adds a measure to the geometry, initialized to a preset value.
186336
* @param mValue initial m-value for all nodes
187337
* @returns true on success
188338
* @note added in QGIS 2.12
189-
* @see addZValue
339+
* @see dropMValue()
340+
* @see addZValue()
190341
*/
191342
virtual bool addMValue( double mValue = 0 ) = 0;
192343

python/core/geometry/qgscircularstringv2.sip

+41-3
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,71 @@ class QgsCircularStringV2: public QgsCurveV2
2929
QString asJSON( int precision = 17 ) const;
3030

3131
int numPoints() const;
32+
33+
/** Returns the point at index i within the circular string.
34+
*/
3235
QgsPointV2 pointN( int i ) const;
36+
37+
/**
38+
* @copydoc QgsCurveV2::points()
39+
*/
3340
void points( QList<QgsPointV2>& pts ) const;
34-
void setPoints( const QList<QgsPointV2>& points );
3541

42+
/** Sets the circular string's points
43+
*/
44+
void setPoints( const QList<QgsPointV2>& points );
3645

37-
//curve interface
46+
/**
47+
* @copydoc QgsAbstractGeometryV2::length()
48+
*/
3849
virtual double length() const;
50+
51+
/**
52+
* @copydoc QgsCurveV2::startPoint()
53+
*/
3954
virtual QgsPointV2 startPoint() const;
55+
/**
56+
* @copydoc QgsCurveV2::endPoint()
57+
*/
4058
virtual QgsPointV2 endPoint() const;
59+
/**
60+
* @copydoc QgsCurveV2::curveToLine()
61+
*/
4162
virtual QgsLineStringV2* curveToLine() const;
4263

4364
void draw( QPainter& p ) const;
65+
66+
/** Transforms the geometry using a coordinate transform
67+
* @param ct coordinate transform
68+
* @param d transformation direction
69+
*/
4470
void transform( const QgsCoordinateTransform& ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform );
4571
void transform( const QTransform& t );
46-
//void clip( const QgsRectangle& rect );
4772
void addToPainterPath( QPainterPath& path ) const;
73+
74+
/**
75+
* @copydoc QgsCurveV2::drawAsPolygon()
76+
*/
4877
void drawAsPolygon( QPainter& p ) const;
4978

5079
virtual bool insertVertex( const QgsVertexId& position, const QgsPointV2& vertex );
5180
virtual bool moveVertex( const QgsVertexId& position, const QgsPointV2& newPos );
5281
virtual bool deleteVertex( const QgsVertexId& position );
5382

5483
double closestSegment( const QgsPointV2& pt, QgsPointV2& segmentPt, QgsVertexId& vertexAfter, bool* leftOf, double epsilon ) const;
84+
/**
85+
* @copydoc QgsCurveV2::pointAt()
86+
*/
5587
bool pointAt( int i, QgsPointV2& vertex, QgsVertexId::VertexType& type ) const;
5688

89+
/**
90+
* @copydoc QgsCurveV2::sumUpArea()
91+
*/
5792
void sumUpArea( double& sum ) const;
5893

94+
/**
95+
* @copydoc QgsAbstractGeometryV2::hasCurvedSegments()
96+
*/
5997
bool hasCurvedSegments() const;
6098

6199
/** Returns approximate rotation angle for a vertex. Usually average angle between adjacent segments.

python/core/geometry/qgscompoundcurvev2.sip

+23-4
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,33 @@ class QgsCompoundCurveV2: public QgsCurveV2
3737
virtual void points( QList<QgsPointV2>& pts ) const;
3838
virtual int numPoints() const;
3939
virtual QgsLineStringV2* curveToLine() const;
40+
41+
/** Returns the number of curves in the geometry.
42+
*/
4043
int nCurves() const;
44+
45+
/** Returns the curve at the specified index.
46+
*/
4147
const QgsCurveV2* curveAt( int i ) const;
4248

43-
/** Adds curve (takes ownership)*/
49+
/** Adds a curve to the geometr (takes ownership)
50+
*/
4451
void addCurve( QgsCurveV2* c /Transfer/ );
52+
53+
/** Removes a curve from the geometry.
54+
* @param i index of curve to remove
55+
*/
4556
void removeCurve( int i );
57+
58+
/** Adds a vertex to the end of the geometry.
59+
*/
4660
void addVertex( const QgsPointV2& pt );
47-
/** Returns closed ring based on curve (connects to start point if not already done)*/
48-
void close();
4961

5062
void draw( QPainter& p ) const;
63+
/** Transforms the geometry using a coordinate transform
64+
* @param ct coordinate transform
65+
@param d transformation direction
66+
*/
5167
void transform( const QgsCoordinateTransform& ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform );
5268
void transform( const QTransform& t );
5369
void addToPainterPath( QPainterPath& path ) const;
@@ -58,10 +74,13 @@ class QgsCompoundCurveV2: public QgsCurveV2
5874
virtual bool deleteVertex( const QgsVertexId& position );
5975

6076
virtual double closestSegment( const QgsPointV2& pt, QgsPointV2& segmentPt, QgsVertexId& vertexAfter, bool* leftOf, double epsilon ) const;
61-
bool pointAt( int i, QgsPointV2& vertex, QgsVertexId::VertexType& type ) const;
77+
bool pointAt( int node, QgsPointV2& point, QgsVertexId::VertexType& type ) const;
6278

6379
void sumUpArea( double& sum ) const;
6480

81+
/** Appends first point if not already closed.*/
82+
void close();
83+
6584
bool hasCurvedSegments() const;
6685

6786
/** Returns approximate rotation angle for a vertex. Usually average angle between adjacent segments.

0 commit comments

Comments
 (0)