Skip to content

Commit 4dd76da

Browse files
committedJan 28, 2016
geometry sip sync and some cosmetics
1 parent 7af5851 commit 4dd76da

17 files changed

+346
-88
lines changed
 

‎python/core/geometry/qgsabstractgeometryv2.sip

Lines changed: 161 additions & 10 deletions
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

Lines changed: 41 additions & 3 deletions
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

Lines changed: 23 additions & 4 deletions
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.

‎python/core/geometry/qgscurvepolygonv2.sip

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,18 @@ class QgsCurvePolygonV2: public QgsSurfaceV2
4747
*/
4848
virtual void setExteriorRing( QgsCurveV2* ring /Transfer/ );
4949

50-
/** Sets interior rings (takes ownership)*/
50+
/** Sets all interior rings (takes ownership)*/
5151
void setInteriorRings( const QList<QgsCurveV2*>& rings );
52+
/** Adds an interior ring to the geometry (takes ownership)*/
5253
virtual void addInteriorRing( QgsCurveV2* ring /Transfer/ );
5354
/** Removes ring. Exterior ring is 0, first interior ring 1, ...*/
5455
bool removeInteriorRing( int nr );
5556

5657
virtual void draw( QPainter& p ) const;
58+
/** Transforms the geometry using a coordinate transform
59+
* @param ct coordinate transform
60+
@param d transformation direction
61+
*/
5762
void transform( const QgsCoordinateTransform& ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform );
5863
void transform( const QTransform& t );
5964

@@ -73,9 +78,10 @@ class QgsCurvePolygonV2: public QgsSurfaceV2
7378
@return rotation in radians, clockwise from north*/
7479
double vertexAngle( const QgsVertexId& vertex ) const;
7580

76-
virtual int vertexCount(int part = 0, int ring = 0) const;
77-
virtual int ringCount(int part = 0) const;
81+
virtual int vertexCount( int /*part*/ = 0, int ring = 0) const;
82+
virtual int ringCount( int /*part*/ = 0 ) const;
7883
virtual int partCount() const;
84+
virtual QgsPointV2 vertexAt( const QgsVertexId& id ) const;
7985

8086
virtual bool addZValue( double zValue = 0 );
8187
virtual bool addMValue( double mValue = 0 );

‎python/core/geometry/qgsgeometry.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class QgsGeometry
8787
@note not available in python bindings
8888
*/
8989
// void fromGeos( GEOSGeometry* geos );
90+
9091
/**
9192
Set the geometry, feeding in the buffer containing OGC Well-Known Binary and the buffer's length.
9293
This class will take ownership of the buffer.

‎python/core/geometry/qgsgeometrycollectionv2.sip

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,26 @@ class QgsGeometryCollectionV2: public QgsAbstractGeometryV2
1212

1313
virtual QgsGeometryCollectionV2* clone() const;
1414

15+
/** Returns the number of geometries within the collection.
16+
*/
1517
int numGeometries() const;
18+
19+
/** Returns a const reference to a geometry from within the collection.
20+
* @param n index of geometry to return
21+
*/
1622
//const QgsAbstractGeometryV2* geometryN( int n ) const;
23+
24+
/** Returns a geometry from within the collection.
25+
* @param n index of geometry to return
26+
*/
1727
QgsAbstractGeometryV2* geometryN( int n );
1828

1929
//methods inherited from QgsAbstractGeometry
2030
virtual int dimension() const;
2131
virtual QString geometryType() const;
2232
virtual void clear();
2333

24-
/** Adds a geometry and takes ownership. Returns true in case of success*/
34+
/** Adds a geometry and takes ownership. Returns true in case of success.*/
2535
virtual bool addGeometry( QgsAbstractGeometryV2* g /Transfer/ );
2636

2737
/** Inserts a geometry before a specified index and takes ownership. Returns true in case of success.
@@ -30,14 +40,25 @@ class QgsGeometryCollectionV2: public QgsAbstractGeometryV2
3040
*/
3141
virtual bool insertGeometry( QgsAbstractGeometryV2* g /Transfer/, int index );
3242

43+
/** Removes a geometry from the collection.
44+
* @param nr index of geometry to remove
45+
* @returns true if removal was successful.
46+
*/
3347
virtual bool removeGeometry( int nr );
3448

49+
/** Transforms the geometry using a coordinate transform
50+
* @param ct coordinate transform
51+
* @param d transformation direction
52+
*/
3553
virtual void transform( const QgsCoordinateTransform& ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform );
3654
void transform( const QTransform& t );
55+
3756
//virtual void clip( const QgsRectangle& rect );
57+
3858
virtual void draw( QPainter& p ) const;
3959

4060
bool fromWkb( const unsigned char * wkb );
61+
virtual bool fromWkt( const QString& wkt );
4162
int wkbSize() const;
4263
unsigned char* asWkb( int& binarySize ) const;
4364
QString asWkt( int precision = 17 ) const;
@@ -62,13 +83,16 @@ class QgsGeometryCollectionV2: public QgsAbstractGeometryV2
6283

6384
bool hasCurvedSegments() const;
6485

86+
/** Returns a geometry without curves. Caller takes ownership*/
87+
QgsAbstractGeometryV2* segmentize() const;
88+
6589
/** Returns approximate rotation angle for a vertex. Usually average angle between adjacent segments.
6690
@param vertex the vertex id
6791
@return rotation in radians, clockwise from north*/
6892
double vertexAngle( const QgsVertexId& vertex ) const;
6993

70-
virtual int vertexCount(int part = 0, int ring = 0) const;
71-
virtual int ringCount(int part = 0) const;
94+
virtual int vertexCount( int part = 0, int ring = 0 ) const;
95+
virtual int ringCount( int part = 0 ) const;
7296
virtual int partCount() const;
7397
virtual QgsPointV2 vertexAt( const QgsVertexId& id ) const;
7498

‎python/core/geometry/qgslinestringv2.sip

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* \brief Line string geometry type, with support for z-dimension and m-values.
44
* \note added in QGIS 2.10
55
*/
6-
76
class QgsLineStringV2: public QgsCurveV2
87
{
98
%TypeHeaderCode
@@ -84,7 +83,8 @@ class QgsLineStringV2: public QgsCurveV2
8483
*/
8584
void setMAt( int index, double m );
8685

87-
/** Resets the line string to match the specified list of points.
86+
/** Resets the line string to match the specified list of points. The line string will
87+
* inherit the dimensionality of the first point in the list.
8888
* @param points new points for line string. If empty, line string will be cleared.
8989
*/
9090
void setPoints( const QList<QgsPointV2>& points );
@@ -102,8 +102,6 @@ class QgsLineStringV2: public QgsCurveV2
102102
/** Closes the line string by appending the first point to the end of the line, if it is not already closed.*/
103103
void close();
104104

105-
virtual QgsLineStringV2* reversed() const /Factory/;
106-
107105
/** Returns a QPolygonF representing the line string.
108106
*/
109107
QPolygonF asQPolygonF() const;
@@ -145,6 +143,8 @@ class QgsLineStringV2: public QgsCurveV2
145143
virtual bool moveVertex( const QgsVertexId& position, const QgsPointV2& newPos );
146144
virtual bool deleteVertex( const QgsVertexId& position );
147145

146+
virtual QgsLineStringV2* reversed() const /Factory/;
147+
148148
double closestSegment( const QgsPointV2& pt, QgsPointV2& segmentPt, QgsVertexId& vertexAfter, bool* leftOf, double epsilon ) const;
149149
bool pointAt( int i, QgsPointV2& vertex, QgsVertexId::VertexType& type ) const;
150150

‎python/core/geometry/qgspointv2.sip

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* \brief Point geometry type, with support for z-dimension and m-values.
44
* \note added in QGIS 2.10
55
*/
6-
76
class QgsPointV2: public QgsAbstractGeometryV2
87
{
98
%TypeHeaderCode
@@ -34,7 +33,7 @@ class QgsPointV2: public QgsAbstractGeometryV2
3433
* @param m m-value of point, for PointM or PointZM types
3534
*/
3635
QgsPointV2( QgsWKBTypes::Type type, double x = 0.0, double y = 0.0, double z = 0.0, double m = 0.0 );
37-
%MethodCode
36+
%MethodCode
3837
if ( QgsWKBTypes::flatType( a0 ) != QgsWKBTypes::Point )
3938
{
4039
PyErr_SetString(PyExc_ValueError,
@@ -128,7 +127,7 @@ class QgsPointV2: public QgsAbstractGeometryV2
128127

129128
/** Sets the point's m-value.
130129
* @note calling this will have no effect if the point does not contain a m-dimension. Use addMValue() to
131-
* add an m value and force the point to have an m dimension.
130+
* add a m value and force the point to have an m dimension.
132131
* @see m()
133132
* @see rm()
134133
*/
@@ -171,8 +170,8 @@ class QgsPointV2: public QgsAbstractGeometryV2
171170
@return 0.0*/
172171
double vertexAngle( const QgsVertexId& vertex ) const;
173172

174-
virtual int vertexCount(int part = 0, int ring = 0) const;
175-
virtual int ringCount(int part = 0) const;
173+
virtual int vertexCount( int /*part*/ = 0, int ring = 0 ) const;
174+
virtual int ringCount( int /*part*/ = 0 ) const;
176175
virtual int partCount() const;
177176
virtual QgsPointV2 vertexAt( const QgsVertexId& id ) const;
178177

‎python/core/geometry/qgspolygonv2.sip

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class QgsPolygonV2: public QgsCurvePolygonV2
1414
virtual QgsPolygonV2* clone() const;
1515

1616
virtual bool fromWkb( const unsigned char* wkb );
17+
1718
// inherited: bool fromWkt( const QString &wkt );
1819

1920
int wkbSize() const;
@@ -28,4 +29,5 @@ class QgsPolygonV2: public QgsCurvePolygonV2
2829
void addInteriorRing( QgsCurveV2* ring /Transfer/ );
2930
//overridden to handle LineString25D rings
3031
virtual void setExteriorRing( QgsCurveV2* ring /Transfer/ );
32+
3133
};

‎python/core/geometry/qgswkbtypes.sip

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ class QgsWKBTypes
161161
* @param type original type
162162
* @note added in QGIS 2.12
163163
* @see addM()
164+
* @see dropZ()
164165
* @see hasZ()
165166
*/
166167
static Type addZ( Type type );
@@ -169,6 +170,7 @@ class QgsWKBTypes
169170
* @param type original type
170171
* @note added in QGIS 2.12
171172
* @see addZ()
173+
* @see dropM()
172174
* @see hasM()
173175
*/
174176
static Type addM( Type type );

‎python/core/qgsclipper.sip

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,23 @@ class QgsClipper
3333
static const double MIN_Y;
3434

3535

36-
// A handy way to refer to the four boundaries
36+
//! A handy way to refer to the four boundaries
3737
enum Boundary {XMax, XMin, YMax, YMin};
3838

3939
%If (!ARM)
40-
// Trims the given feature to a rectangular box. Returns the trimmed
41-
// feature in x and y. The shapeOpen parameter determines whether
42-
// the function treats the points as a closed shape (polygon), or as
43-
// an open shape (linestring).
44-
//
45-
// @note not available in python bindings on android
40+
/**
41+
* Trims the given feature to a rectangular box. Returns the trimmed
42+
* feature in x and y. The shapeOpen parameter determines whether
43+
* the function treats the points as a closed shape (polygon), or as
44+
* an open shape (linestring).
45+
*
46+
* @note not available in python bindings on android
47+
*/
4648
static void trimFeature( QVector<double>& x,
4749
QVector<double>& y,
4850
bool shapeOpen );
4951
%End
52+
5053
static void trimPolygon( QPolygonF& pts, const QgsRectangle& clipRect );
5154

5255
/** Reads a polyline from WKB and clips it to clipExtent

‎python/core/symbology-ng/qgsrendererv2.sip

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class QgsSymbolV2LevelItem
1717
int layer();
1818
};
1919

20-
2120
// every level has list of items: symbol + symbol layer num
2221
// typedef QList< QgsSymbolV2LevelItem > QgsSymbolV2Level;
2322

@@ -62,17 +61,13 @@ class QgsFeatureRendererV2
6261
QString type() const;
6362

6463
/** To be overridden
65-
*
66-
* Must be called between startRender() and stopRender() calls.
6764
* @param feature feature
6865
* @return returns pointer to symbol or 0 if symbol was not found
6966
* @deprecated use symbolForFeature( QgsFeature& feature, QgsRenderContext& context ) instead
7067
*/
7168
virtual QgsSymbolV2* symbolForFeature( QgsFeature& feature ) /Deprecated/;
7269

7370
/** To be overridden
74-
*
75-
* Must be called between startRender() and stopRender() calls.
7671
* @param feature feature
7772
* @param context render context
7873
* @return returns pointer to symbol or 0 if symbol was not found
@@ -103,19 +98,17 @@ class QgsFeatureRendererV2
10398
virtual QgsSymbolV2* originalSymbolForFeature( QgsFeature& feature, QgsRenderContext& context ) /PyName=originalSymbolForFeature2/;
10499

105100
/**
106-
* Return legend keys matching a specified feature.
107-
* @note added in 2.14
101+
* Needs to be called when a new render cycle is started
102+
*
103+
* @param context Additional information passed to the renderer about the job which will be rendered
104+
* @param fields The fields available for rendering
105+
* @return Information passed back from the renderer that can e.g. be used to reduce the amount of requested features
108106
*/
109-
virtual QSet< QString > legendKeysForFeature( QgsFeature& feature, QgsRenderContext& context );
110-
111107
virtual void startRender( QgsRenderContext& context, const QgsFields& fields ) = 0;
112108

113109
//! @deprecated since 2.4 - not using QgsVectorLayer directly anymore
114110
virtual void startRender( QgsRenderContext& context, const QgsVectorLayer *vlayer ) /Deprecated/;
115111

116-
/**
117-
* Needs to be called when a render cycle has finished to clean up.
118-
*/
119112
virtual void stopRender( QgsRenderContext& context ) = 0;
120113

121114
/**
@@ -131,22 +124,17 @@ class QgsFeatureRendererV2
131124
*/
132125
virtual QString filter( const QgsFields& fields = QgsFields() );
133126

127+
/**
128+
* Returns a set of attributes required for this renderer.
129+
*
130+
* TODO QGIS3: Change QList to QSet
131+
*/
134132
virtual QList<QString> usedAttributes() = 0;
135133

136134
virtual ~QgsFeatureRendererV2();
137135

138136
virtual QgsFeatureRendererV2* clone() const = 0 /Factory/;
139137

140-
/**
141-
* Render a feature using this renderer in the given context.
142-
* Must be called between startRender() and stopRender() calls.
143-
* Default implementation renders a symbol as determined by symbolForFeature() call.
144-
* Returns true if the feature has been returned (this is used for example
145-
* to determine whether the feature may be labelled).
146-
*
147-
* If layer is not -1, the renderer should draw only a particula layer from symbols
148-
* (in order to support symbol level rendering).
149-
*/
150138
virtual bool renderFeature( QgsFeature& feature, QgsRenderContext& context, int layer = -1, bool selected = false, bool drawVertexMarker = false );
151139

152140
//! for debugging
@@ -247,8 +235,11 @@ class QgsFeatureRendererV2
247235
void setVertexMarkerAppearance( int type, int size );
248236

249237
//! return rotation field name (or empty string if not set or not supported by renderer)
238+
//! @deprecated use the symbol's methods instead
250239
virtual QString rotationField() const /Deprecated/;
240+
251241
//! sets rotation field of renderer (if supported by the renderer)
242+
//! @deprecated use the symbol's methods instead
252243
virtual void setRotationField( const QString& fieldName ) /Deprecated/;
253244

254245
/** Returns whether the renderer will render a feature or not.
@@ -290,7 +281,7 @@ class QgsFeatureRendererV2
290281
*/
291282
virtual QgsSymbolV2List originalSymbolsForFeature( QgsFeature& feat ) /Deprecated/;
292283

293-
/** Equivalent of originalSymbolsForFeature() call
284+
/** Equivalent of originalSymbolsForFeature() call
294285
* extended to support renderers that may use more symbols per feature - similar to symbolsForFeature()
295286
* @note added in 2.12
296287
* @note available in Python bindings as originalSymbolsForFeature2
@@ -382,14 +373,14 @@ class QgsFeatureRendererV2
382373

383374
/** Copies paint effect of this renderer to another renderer
384375
* @param destRenderer destination renderer for copied effect
376+
* @deprecated use copyRendererData instead
385377
*/
386378
void copyPaintEffect( QgsFeatureRendererV2 *destRenderer ) const;
387379

388380
/** @note this function is used to convert old sizeScale expresssions to symbol
389381
* level DataDefined size
390382
*/
391383
static void convertSymbolSizeScale( QgsSymbolV2 * symbol, QgsSymbolV2::ScaleMethod method, const QString & field );
392-
393384
/** @note this function is used to convert old rotations expresssions to symbol
394385
* level DataDefined angle
395386
*/

‎python/core/symbology-ng/qgssymbolv2.sip

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,32 @@ class QgsSymbolV2
9393
*/
9494
int symbolLayerCount();
9595

96-
//! insert symbol layer to specified index
96+
/**
97+
* Insert symbol layer to specified index
98+
* Ownership will be transferred.
99+
* @param index The index at which the layer should be added
100+
* @param layer The symbol layer to add
101+
* @return True if the layer is added, False if the index or the layer is bad
102+
*/
97103
bool insertSymbolLayer( int index, QgsSymbolLayerV2* layer /Transfer/ );
98104

99-
//! append symbol layer at the end of the list
105+
/**
106+
* Append symbol layer at the end of the list
107+
* Ownership will be transferred.
108+
* @param layer The layer to add
109+
* @return True if the layer is added, False if the layer is bad
110+
*/
100111
bool appendSymbolLayer( QgsSymbolLayerV2* layer /Transfer/ );
101112

102113
//! delete symbol layer at specified index
103114
bool deleteSymbolLayer( int index );
104115

105-
//! remove symbol layer from the list and return pointer to it
116+
/**
117+
* Remove symbol layer from the list and return pointer to it.
118+
* Ownership is handed to the caller.
119+
* @param index The index of the layer to remove
120+
* @return A pointer to the removed layer
121+
*/
106122
QgsSymbolLayerV2* takeSymbolLayer( int index ) /TransferBack/;
107123

108124
//! delete layer at specified index and set a new one
@@ -183,6 +199,7 @@ class QgsSymbolV2
183199
*/
184200
bool hasDataDefinedProperties() const;
185201

202+
//! @note the layer will be NULL after stopRender
186203
void setLayer( const QgsVectorLayer* layer );
187204
const QgsVectorLayer* layer() const;
188205

@@ -202,21 +219,27 @@ class QgsSymbolV2
202219
QgsSymbolV2( SymbolType type, const QgsSymbolLayerV2List& layers /Transfer/ ); // can't be instantiated
203220

204221
/**
205-
Creates a point in screen coordinates from a QgsPointV2 in map coordinates
222+
* Creates a point in screen coordinates from a QgsPointV2 in map coordinates
206223
*/
207224
static void _getPoint( QPointF& pt /Out/, QgsRenderContext& context, const QgsPointV2* point );
208225
/**
209226
* Creates a line string in screen coordinates from a wkb string in map
210227
* coordinates
211228
*/
212229
static const unsigned char* _getLineString( QPolygonF& pts, QgsRenderContext& context, const unsigned char* wkb, bool clipToExtent = true );
230+
213231
/**
214232
* Creates a polygon in screen coordinates from a wkb string in map
215233
* coordinates
216234
*/
217235
static const unsigned char* _getPolygon( QPolygonF& pts, QList<QPolygonF>& holes, QgsRenderContext& context, const unsigned char* wkb, bool clipToExtent = true );
218236

237+
/**
238+
* Retrieve a cloned list of all layers that make up this symbol.
239+
* Ownership is transferred to the caller.
240+
*/
219241
QgsSymbolLayerV2List cloneLayers() const /Factory/;
242+
220243
/**
221244
* Renders a context using a particular symbol layer without passing in a
222245
* geometry. This is used as fallback, if the symbol being rendered is not
@@ -230,7 +253,8 @@ class QgsSymbolV2
230253

231254
//! check whether a symbol layer type can be used within the symbol
232255
//! (marker-marker, line-line, fill-fill/line)
233-
bool isSymbolLayerCompatible( SymbolType t );
256+
//! @deprecated since 2.14, use QgsSymbolLayerV2::isCompatibleWithSymbol instead
257+
bool isSymbolLayerCompatible( SymbolType layerType );
234258

235259
private:
236260
QgsSymbolV2( const QgsSymbolV2& );
@@ -249,7 +273,7 @@ class QgsSymbolV2RenderContext
249273
~QgsSymbolV2RenderContext();
250274

251275
QgsRenderContext& renderContext();
252-
//void setRenderContext( QgsRenderContext& c );
276+
// const QgsRenderContext& renderContext() const;
253277

254278
/** Sets the original value variable value for data defined symbology
255279
* @param value value for original value variable. This usually represents the symbol property value
@@ -262,7 +286,7 @@ class QgsSymbolV2RenderContext
262286
void setOutputUnit( QgsSymbolV2::OutputUnit u );
263287

264288
QgsMapUnitScale mapUnitScale() const;
265-
void setMapUnitScale( const QgsMapUnitScale& scale);
289+
void setMapUnitScale( const QgsMapUnitScale& scale );
266290

267291
//! Get alpha transparency 1 for opaque, 0 for invisible
268292
qreal alpha() const;
@@ -308,7 +332,7 @@ class QgsSymbolV2RenderContext
308332

309333
private:
310334

311-
QgsSymbolV2RenderContext( const QgsSymbolV2RenderContext& rh );
335+
QgsSymbolV2RenderContext( const QgsSymbolV2RenderContext& rh );
312336
};
313337

314338

‎src/core/geometry/qgscircularstringv2.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@ class CORE_EXPORT QgsCircularStringV2: public QgsCurveV2
9393
*/
9494
void transform( const QgsCoordinateTransform& ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform ) override;
9595
void transform( const QTransform& t ) override;
96-
#if 0
97-
void clip( const QgsRectangle& rect ) override;
98-
#endif
9996
void addToPainterPath( QPainterPath& path ) const override;
10097

10198
/**

‎src/core/geometry/qgsgeometrycollectionv2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class CORE_EXPORT QgsGeometryCollectionV2: public QgsAbstractGeometryV2
7272

7373
/** Transforms the geometry using a coordinate transform
7474
* @param ct coordinate transform
75-
@param d transformation direction
75+
* @param d transformation direction
7676
*/
7777
virtual void transform( const QgsCoordinateTransform& ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform ) override;
7878
void transform( const QTransform& t ) override;

‎src/core/qgsgeometrysimplifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ bool QgsTopologyPreservingSimplifier::simplifyGeometry( QgsGeometry* geometry )
6565
if ( g )
6666
{
6767
int wkbSize = g->wkbSize();
68-
unsigned char* wkb = reinterpret_cast< unsigned char* >( malloc( wkbSize ) );
68+
unsigned char *wkb = new unsigned char[ wkbSize ];
6969
memcpy( wkb, g->asWkb(), wkbSize );
7070
geometry->fromWkb( wkb, wkbSize );
7171
delete g;

‎tests/src/core/testqgsgeometry.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -693,27 +693,27 @@ void TestQgsGeometry::pointV2()
693693

694694
//dropZ
695695
QgsPointV2 p25( QgsWKBTypes::PointZ, 1.0, 2.0, 3.0 );
696-
QVERIFY( p25.dropZValue( ) );
696+
QVERIFY( p25.dropZValue() );
697697
QCOMPARE( p25, QgsPointV2( 1.0, 2.0 ) );
698-
QVERIFY( !p25.dropZValue( ) );
698+
QVERIFY( !p25.dropZValue() );
699699
QgsPointV2 p26( QgsWKBTypes::PointZM, 1.0, 2.0, 3.0, 4.0 );
700-
QVERIFY( p26.dropZValue( ) );
700+
QVERIFY( p26.dropZValue() );
701701
QCOMPARE( p26, QgsPointV2( QgsWKBTypes::PointM, 1.0, 2.0, 0.0, 4.0 ) );
702-
QVERIFY( !p26.dropZValue( ) );
702+
QVERIFY( !p26.dropZValue() );
703703
QgsPointV2 p26a( QgsWKBTypes::Point25D, 1.0, 2.0, 3.0 );
704-
QVERIFY( p26a.dropZValue( ) );
704+
QVERIFY( p26a.dropZValue() );
705705
QCOMPARE( p26a, QgsPointV2( QgsWKBTypes::Point, 1.0, 2.0 ) );
706-
QVERIFY( !p26a.dropZValue( ) );
706+
QVERIFY( !p26a.dropZValue() );
707707

708708
//dropM
709709
QgsPointV2 p27( QgsWKBTypes::PointM, 1.0, 2.0, 0.0, 3.0 );
710-
QVERIFY( p27.dropMValue( ) );
710+
QVERIFY( p27.dropMValue() );
711711
QCOMPARE( p27, QgsPointV2( 1.0, 2.0 ) );
712-
QVERIFY( !p27.dropMValue( ) );
712+
QVERIFY( !p27.dropMValue() );
713713
QgsPointV2 p28( QgsWKBTypes::PointZM, 1.0, 2.0, 3.0, 4.0 );
714-
QVERIFY( p28.dropMValue( ) );
714+
QVERIFY( p28.dropMValue() );
715715
QCOMPARE( p28, QgsPointV2( QgsWKBTypes::PointZ, 1.0, 2.0, 3.0, 0.0 ) );
716-
QVERIFY( !p28.dropMValue( ) );
716+
QVERIFY( !p28.dropMValue() );
717717

718718
//convertTo
719719
QgsPointV2 p29( 1.0, 2.0 );
@@ -3187,7 +3187,8 @@ void TestQgsGeometry::smoothCheck()
31873187
QgsMultiPolygon multipoly = result->asMultiPolygon();
31883188
delete result;
31893189
QgsMultiPolygon expectedMultiPoly;
3190-
expectedMultiPoly << ( QgsPolygon() << ( QgsPolyline() << QgsPoint( 1.0, 0 ) << QgsPoint( 9, 0 ) << QgsPoint( 10.0, 1 )
3190+
expectedMultiPoly
3191+
<< ( QgsPolygon() << ( QgsPolyline() << QgsPoint( 1.0, 0 ) << QgsPoint( 9, 0 ) << QgsPoint( 10.0, 1 )
31913192
<< QgsPoint( 10.0, 9 ) << QgsPoint( 9, 10.0 ) << QgsPoint( 1, 10.0 ) << QgsPoint( 0, 9 )
31923193
<< QgsPoint( 0, 1 ) << QgsPoint( 1, 0 ) ) )
31933194
<< ( QgsPolygon() << ( QgsPolyline() << QgsPoint( 2.2, 2.0 ) << QgsPoint( 3.8, 2.0 ) << QgsPoint( 4.0, 2.2 )
@@ -3209,7 +3210,7 @@ void TestQgsGeometry::dataStream()
32093210
ds.device()->seek( 0 );
32103211
ds >> resultGeometry;
32113212

3212-
QCOMPARE( geom->geometry()->asWkt(), resultGeometry.geometry()->asWkt( ) );
3213+
QCOMPARE( geom->geometry()->asWkt(), resultGeometry.geometry()->asWkt() );
32133214

32143215
//also test with geometry without data
32153216
QScopedPointer<QgsGeometry> emptyGeom( new QgsGeometry() );

0 commit comments

Comments
 (0)
Please sign in to comment.