1
1
2
- /** polyline is just a list of points */
2
+ /** polyline is represented as a vector of points */
3
3
typedef QVector<QgsPoint> QgsPolyline;
4
4
5
5
/** polygon: first item of the list is outer ring, inner rings (if any) start from second item */
6
6
typedef QVector< QVector<QgsPoint> > QgsPolygon;
7
-
7
+
8
8
/** a collection of QgsPoints that share a common collection of attributes */
9
9
typedef QVector<QgsPoint> QgsMultiPoint;
10
10
@@ -23,36 +23,34 @@ class QgsGeometry
23
23
%End
24
24
25
25
public:
26
-
27
26
//! Constructor
28
27
QgsGeometry();
29
-
28
+
30
29
/** copy constructor will prompt a deep copy of the object */
31
30
QgsGeometry( const QgsGeometry & );
32
-
31
+
33
32
34
33
//! Destructor
35
34
~QgsGeometry();
36
35
37
-
38
36
/** static method that creates geometry from Wkt */
39
- static QgsGeometry* fromWkt(QString wkt) /Factory/;
40
-
37
+ static QgsGeometry* fromWkt( QString wkt ) /Factory/;
38
+
41
39
/** construct geometry from a point */
42
- static QgsGeometry* fromPoint(const QgsPoint& point) /Factory/;
40
+ static QgsGeometry* fromPoint( const QgsPoint& point ) /Factory/;
43
41
/** construct geometry from a multipoint */
44
- static QgsGeometry* fromMultiPoint(const QgsMultiPoint& multipoint) /Factory/;
42
+ static QgsGeometry* fromMultiPoint( const QgsMultiPoint& multipoint ) /Factory/;
45
43
/** construct geometry from a polyline */
46
- static QgsGeometry* fromPolyline(const QgsPolyline& polyline) /Factory/;
44
+ static QgsGeometry* fromPolyline( const QgsPolyline& polyline ) /Factory/;
47
45
/** construct geometry from a multipolyline*/
48
- static QgsGeometry* fromMultiPolyline(const QgsMultiPolyline& multiline) /Factory/;
46
+ static QgsGeometry* fromMultiPolyline( const QgsMultiPolyline& multiline ) /Factory/;
49
47
/** construct geometry from a polygon */
50
- static QgsGeometry* fromPolygon(const QgsPolygon& polygon) /Factory/;
48
+ static QgsGeometry* fromPolygon( const QgsPolygon& polygon ) /Factory/;
51
49
/** construct geometry from a multipolygon */
52
- static QgsGeometry* fromMultiPolygon(const QgsMultiPolygon& multipoly) /Factory/;
50
+ static QgsGeometry* fromMultiPolygon( const QgsMultiPolygon& multipoly ) /Factory/;
53
51
/** construct geometry from a rectangle */
54
- static QgsGeometry* fromRect(const QgsRectangle& rect) /Factory/;
55
-
52
+ static QgsGeometry* fromRect( const QgsRectangle& rect ) /Factory/;
53
+
56
54
57
55
58
56
/**
@@ -77,10 +75,10 @@ class QgsGeometry
77
75
%End
78
76
79
77
/**
80
- Returns the size of the WKB in asWkb().
81
- */
78
+ * Returns the size of the WKB in asWkb().
79
+ */
82
80
size_t wkbSize();
83
-
81
+
84
82
/** Returns type of wkb (point / linestring / polygon etc.) */
85
83
QGis::WkbType wkbType();
86
84
@@ -105,29 +103,24 @@ class QgsGeometry
105
103
*/
106
104
bool isGeosEmpty();
107
105
108
- /**
109
- Set the geometry, feeding in a geometry in GEOS format.
110
- */
111
- // TODO: unsupported class... would be possible to use PyGEOS?
112
- //void fromGeos(geos::Geometry* geos);
113
-
114
- /** get area using GEOS
106
+ /** get area of geometry using GEOS
115
107
@note added in 1.5
116
108
*/
117
109
double area();
118
110
119
- /** get length using GEOS
111
+ /** get length of geometry using GEOS
120
112
@note added in 1.5
121
113
*/
122
114
double length();
123
115
124
- double distance(QgsGeometry& geom);
116
+ double distance( QgsGeometry& geom );
125
117
126
118
/**
127
- Returns the vertex closest to the given point
128
- ( and also vertex index, squared distance and indexes of the vertices before/after)
119
+ Returns the vertex closest to the given point, the corresponding vertex index, squared distance snap point / target point
120
+ and the indices of the vertices before/after. The vertices before/after are -1 if not present
129
121
*/
130
- QgsPoint closestVertex(const QgsPoint& point, int& atVertex /Out/, int& beforeVertex /Out/, int& afterVertex /Out/, double& sqrDist /Out/);
122
+ QgsPoint closestVertex( const QgsPoint& point, int& atVertex /Out/, int& beforeVertex /Out/, int& afterVertex /Out/, double& sqrDist /Out/);
123
+
131
124
132
125
/**
133
126
Returns the indexes of the vertices before and after the given vertex index.
@@ -141,120 +134,129 @@ class QgsGeometry
141
134
account the first vertex is equal to the last vertex (and will
142
135
skip equal vertex positions).
143
136
*/
144
- void adjacentVertices(int atVertex, int& beforeVertex /Out/, int& afterVertex /Out/);
137
+ void adjacentVertices( int atVertex, int& beforeVertex /Out/, int& afterVertex /Out/ );
138
+
145
139
146
140
/** Insert a new vertex before the given vertex index,
147
141
* ring and item (first number is index 0)
148
142
* If the requested vertex number (beforeVertex.back()) is greater
149
143
* than the last actual vertex on the requested ring and item,
150
144
* it is assumed that the vertex is to be appended instead of inserted.
151
- * Returns FALSE if atVertex does not correspond to a valid vertex
145
+ * Returns false if atVertex does not correspond to a valid vertex
152
146
* on this geometry (including if this geometry is a Point).
153
147
* It is up to the caller to distinguish between
154
148
* these error conditions. (Or maybe we add another method to this
155
149
* object to help make the distinction?)
156
150
*/
157
- bool insertVertex(double x, double y, int beforeVertex);
151
+ bool insertVertex( double x, double y, int beforeVertex );
158
152
159
- /** Moves the vertex at the given position number,
160
- * ring and item (first number is index 0)
153
+ /** Moves the vertex at the given position number
154
+ * and item (first number is index 0)
161
155
* to the given coordinates.
162
- * Returns FALSE if atVertex does not correspond to a valid vertex
163
- * on this geometry
156
+ * Returns false if atVertex does not correspond to a valid vertex
157
+ * on this geometry
164
158
*/
165
- bool moveVertex(double x, double y, int atVertex);
166
-
167
- /** Deletes the vertex at the given position number,
168
- * ring and item (first number is index 0)
169
- * Returns FALSE if atVertex does not correspond to a valid vertex
159
+ bool moveVertex( double x, double y, int atVertex );
160
+
161
+ /** Deletes the vertex at the given position number and item
162
+ * (first number is index 0)
163
+ * Returns false if atVertex does not correspond to a valid vertex
170
164
* on this geometry (including if this geometry is a Point),
171
165
* or if the number of remaining verticies in the linestring
172
166
* would be less than two.
173
167
* It is up to the caller to distinguish between
174
168
* these error conditions. (Or maybe we add another method to this
175
169
* object to help make the distinction?)
176
170
*/
177
- bool deleteVertex(int atVertex);
171
+ bool deleteVertex( int atVertex );
178
172
179
173
/**
180
174
* Returns coordinates of a vertex.
181
175
* @param atVertex index of the vertex
182
176
* @return Coordinates of the vertex or QgsPoint(0,0) on error
183
177
*/
184
- QgsPoint vertexAt(int atVertex);
178
+ QgsPoint vertexAt( int atVertex );
185
179
186
180
/**
187
- Returns the squared cartesian distance between the given point
188
- to the given vertex index*/
189
- double sqrDistToVertexAt(QgsPoint& point /In/, int atVertex);
181
+ * Returns the squared cartesian distance between the given point
182
+ * to the given vertex index (vertex at the given position number,
183
+ * ring and item (first number is index 0))
184
+ */
185
+ double sqrDistToVertexAt( QgsPoint& point /In/, int atVertex );
190
186
191
-
192
- /**
187
+ /**
193
188
* Searches for the the closest vertex in this geometry to the given point.
194
189
* @param point Specifiest the point for search
195
190
* @param atVertex Receives index of the closest vertex
196
191
* @return The squared cartesian distance is also returned in sqrDist, negative number on error
197
192
*/
198
- double closestVertexWithContext(const QgsPoint& point, int& atVertex /Out/);
193
+ double closestVertexWithContext( const QgsPoint& point, int& atVertex /Out/ );
199
194
200
195
/**
201
196
* Searches for the closest segment of geometry to the given point
202
197
* @param point Specifies the point for search
203
198
* @param minDistPoint Receives the nearest point on the segment
204
- * @param beforeVertex Receives index of the vertex before the closest segment
199
+ * @param afterVertex Receives index of the vertex after the closest segment. The vertex
200
+ * before the closest segment is always afterVertex - 1
201
+ * @param leftOf Out: Returns if the point lies on the left of right side of the segment ( < 0 means left, > 0 means right )
202
+ * @param epsilon epsilon for segment snapping (added in 1.8)
205
203
* @return The squared cartesian distance is also returned in sqrDist, negative number on error
206
204
*/
207
- double closestSegmentWithContext(const QgsPoint& point, QgsPoint& minDistPoint /Out/, int& beforeVertex /Out/);
205
+ double closestSegmentWithContext( const QgsPoint& point, QgsPoint& minDistPoint /Out/, int& beforeVertex /Out/ );
208
206
209
- /**Adds a new ring to this geometry. This makes only sense for polygon and multipolygons.
210
- @return 0 in case of success (ring added), 1 problem with geometry type, 2 ring not closed, \
207
+ /**Adds a new ring to this geometry. This makes only sense for polygon and multipolygons.
208
+ @return 0 in case of success (ring added), 1 problem with geometry type, 2 ring not closed,
211
209
3 ring is not valid geometry, 4 ring not disjoint with existing rings, 5 no polygon found which contained the ring*/
212
- int addRing(const QList<QgsPoint>& ring);
210
+ int addRing( const QList<QgsPoint>& ring );
213
211
214
- /**Adds a new island polygon to a multipolygon feature
215
- @return 0 in case of success, 1 if not a multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring \
216
- not disjoint with existing polygons of the feature*/
217
- int addPart(const QList<QgsPoint>& ring);
212
+ /**Adds a new island polygon to a multipolygon feature
213
+ @return 0 in case of success, 1 if not a multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring
214
+ not disjoint with existing polygons of the feature*/
215
+ int addPart( const QList<QgsPoint>& ring );
218
216
int addIsland( const QList<QgsPoint> &ring ) /Deprecated/;
219
217
220
- /**Translate this geometry by dx, dy
218
+ /**Translate this geometry by dx, dy
221
219
@return 0 in case of success*/
222
- int translate(double dx, double dy);
220
+ int translate( double dx, double dy );
223
221
224
- /**Transform this geometry as described by CoordinateTranasform ct
222
+ /**Transform this geometry as described by CoordinateTranasform ct
225
223
@return 0 in case of success*/
226
224
int transform( const QgsCoordinateTransform& ct );
227
225
228
- /**Splits this geometry according to a given line. Note that the geometry is only split once. If there are several intersections
229
- between geometry and splitLine, only the first one is considered.
226
+ /**Splits this geometry according to a given line. Note that the geometry is only split once. If there are several intersections
227
+ between geometry and splitLine, only the first one is considered.
230
228
@param splitLine the line that splits the geometry
231
- @param newGeometrys OUT: list of new geometries that have been created with the split
229
+ @param[out] newGeometries list of new geometries that have been created with the split
232
230
@param topological true if topological editing is enabled
233
- @topologyTestPoints OUT: points that need to be tested for topological completeness in the dataset
231
+ @param[out] topologyTestPoints points that need to be tested for topological completeness in the dataset
234
232
@return 0 in case of success, 1 if geometry has not been split, error else*/
235
- int splitGeometry(const QList<QgsPoint>& splitLine, QList<QgsGeometry*>& newGeometries /Out/, bool topological, QList<QgsPoint>& topologyTestPoints /Out/);
233
+ int splitGeometry( const QList<QgsPoint>& splitLine,
234
+ QList<QgsGeometry*>&newGeometries /Out/,
235
+ bool topological,
236
+ QList<QgsPoint> &topologyTestPoints /Out/);
236
237
237
- /**Replaces a part of this geometry with another line
238
+ /**Replaces a part of this geometry with another line
238
239
@return 0 in case of success
239
240
@note: this function was added in version 1.3*/
240
241
int reshapeGeometry( const QList<QgsPoint>& reshapeWithLine );
241
242
242
- /**Changes this geometry such that it does not intersect the other geometry
243
+ /**Changes this geometry such that it does not intersect the other geometry
243
244
@param other geometry that should not be intersect
244
245
@return 0 in case of success*/
245
- int makeDifference(QgsGeometry* other);
246
+ int makeDifference( QgsGeometry* other );
246
247
247
248
/**Returns the bounding box of this feature*/
248
249
QgsRectangle boundingBox();
249
250
250
251
/** Test for intersection with a rectangle (uses GEOS) */
251
- bool intersects(const QgsRectangle& r);
252
- /** Test for intersection with a geoemetry (uses GEOS) */
253
- bool intersects(QgsGeometry* geometry);
252
+ bool intersects( const QgsRectangle& r );
253
+
254
+ /** Test for intersection with a geometry (uses GEOS) */
255
+ bool intersects( QgsGeometry* geometry );
254
256
255
257
/** Test for containment of a point (uses GEOS) */
256
- bool contains(QgsPoint* p);
257
-
258
+ bool contains( QgsPoint* p );
259
+
258
260
/** Test for if geometry is contained in an other (uses GEOS)
259
261
* @note added in 1.5 */
260
262
bool contains( QgsGeometry* geometry );
@@ -285,11 +287,11 @@ not disjoint with existing polygons of the feature*/
285
287
286
288
/** Returns a buffer region around this geometry having the given width and with a specified number
287
289
of segments used to approximate curves */
288
- QgsGeometry* buffer(double distance, int segments) /Factory/;
290
+ QgsGeometry* buffer( double distance, int segments ) /Factory/;
289
291
290
292
/** Returns a simplified version of this geometry using a specified tolerance value */
291
- QgsGeometry* simplify(double tolerance) /Factory/;
292
-
293
+ QgsGeometry* simplify( double tolerance ) /Factory/;
294
+
293
295
/** Returns the center of mass of a geometry
294
296
* @note for line based geometries, the center point of the line is returned,
295
297
* and for point based geometries, the point itself is returned */
@@ -298,53 +300,59 @@ not disjoint with existing polygons of the feature*/
298
300
/** Returns the smallest convex polygon that contains all the points in the geometry. */
299
301
QgsGeometry* convexHull() /Factory/;
300
302
303
+ /* Return interpolated point on line at distance
304
+ * @note added in 1.9
305
+ */
301
306
QgsGeometry* interpolate( double distance ) /Factory/;
302
-
307
+
303
308
/** Returns a geometry representing the points shared by this geometry and other. */
304
- QgsGeometry* intersection(QgsGeometry* geometry) /Factory/;
305
-
309
+ QgsGeometry* intersection( QgsGeometry* geometry ) /Factory/;
310
+
306
311
/** Returns a geometry representing all the points in this geometry and other (a
307
- * union geometry operation).
312
+ * union geometry operation).
308
313
* @note this operation is not called union since its a reserved word in C++.*/
309
314
QgsGeometry* combine( QgsGeometry* geometry ) /Factory/;
310
-
315
+
311
316
/** Returns a geometry representing the points making up this geometry that do not make up other. */
312
- QgsGeometry* difference(QgsGeometry* geometry) /Factory/;
313
-
317
+ QgsGeometry* difference( QgsGeometry* geometry ) /Factory/;
318
+
314
319
/** Returns a Geometry representing the points making up this Geometry that do not make up other. */
315
- QgsGeometry* symDifference(QgsGeometry* geometry) /Factory/;
316
-
317
- /**Creates a geos geometry from this features geometry. Note, that the returned object needs to be deleted*/
318
- // TODO: unsupported class... would be possible to use PyGEOS?
319
- //geos::Geometry* geosGeometry() const;
320
+ QgsGeometry* symDifference( QgsGeometry* geometry ) /Factory/;
320
321
321
322
/** Exports the geometry to mWkt
322
- @return true in case of success and false else
323
+ * @return true in case of success and false else
323
324
*/
324
325
QString exportToWkt();
325
-
326
+
327
+ /** Exports the geometry to mGeoJSON
328
+ * @return true in case of success and false else
329
+ * @note added in 1.8
330
+ * @note python binding added in 1.9
331
+ */
332
+ QString exportToGeoJSON();
333
+
326
334
/* Accessor functions for getting geometry data */
327
-
335
+
328
336
/** return contents of the geometry as a point
329
337
if wkbType is WKBPoint, otherwise returns [0,0] */
330
338
QgsPoint asPoint();
331
-
339
+
332
340
/** return contents of the geometry as a polyline
333
341
if wkbType is WKBLineString, otherwise an empty list */
334
342
QgsPolyline asPolyline();
335
-
343
+
336
344
/** return contents of the geometry as a polygon
337
345
if wkbType is WKBPolygon, otherwise an empty list */
338
346
QgsPolygon asPolygon();
339
-
347
+
340
348
/** return contents of the geometry as a multi point
341
- if wkbType is WKBMultiPint , otherwise an empty list */
349
+ if wkbType is WKBMultiPoint , otherwise an empty list */
342
350
QgsMultiPoint asMultiPoint();
343
-
351
+
344
352
/** return contents of the geometry as a multi linestring
345
353
if wkbType is WKBMultiLineString, otherwise an empty list */
346
354
QgsMultiPolyline asMultiPolyline();
347
-
355
+
348
356
/** return contents of the geometry as a multi polygon
349
357
if wkbType is WKBMultiPolygon, otherwise an empty list */
350
358
QgsMultiPolygon asMultiPolygon();
@@ -356,12 +364,12 @@ not disjoint with existing polygons of the feature*/
356
364
357
365
/** delete a ring in polygon or multipolygon.
358
366
Ring 0 is outer ring and can't be deleted.
359
- @return TRUE on success
367
+ @return true on success
360
368
@note added in version 1.2 */
361
369
bool deleteRing( int ringNum, int partNum = 0 );
362
370
363
371
/** delete part identified by the part number
364
- @return TRUE on success
372
+ @return true on success
365
373
@note added in version 1.2 */
366
374
bool deletePart( int partNum );
367
375
@@ -388,7 +396,7 @@ not disjoint with existing polygons of the feature*/
388
396
QgsPoint where();
389
397
bool hasWhere();
390
398
};
391
-
399
+
392
400
/** Validate geometry and produce a list of geometry errors
393
401
* @note python binding added in 1.6
394
402
**/
0 commit comments