@@ -34,31 +34,36 @@ class QgsGeometry
34
34
/** copy constructor will prompt a deep copy of the object */
35
35
QgsGeometry( const QgsGeometry & );
36
36
37
- QgsGeometry( QgsAbstractGeometryV2* geom /Transfer/ );
38
-
37
+ /** Creates a geometry from an abstract geometry object.
38
+ * @note added in QGIS 2.10
39
+ */
40
+ QgsGeometry( QgsAbstractGeometryV2* geom );
39
41
40
42
//! Destructor
41
43
~QgsGeometry();
42
44
45
+ /** Returns the underlying geometry store.
46
+ * @note added in QGIS 2.10
47
+ */
43
48
const QgsAbstractGeometryV2* geometry() const;
44
49
45
- /** static method that creates geometry from Wkt */
50
+ /** Creates a new geometry from a WKT string */
46
51
static QgsGeometry* fromWkt( QString wkt ) /Factory/;
47
-
48
- /** construct geometry from a point */
52
+ /** Creates a new geometry from a QgsPoint object*/
49
53
static QgsGeometry* fromPoint( const QgsPoint& point ) /Factory/;
50
- /** construct geometry from a multipoint */
54
+ /** Creates a new geometry from a QgsMultiPoint object */
51
55
static QgsGeometry* fromMultiPoint( const QgsMultiPoint& multipoint ) /Factory/;
52
- /** construct geometry from a polyline */
56
+ /** Creates a new geometry from a QgsPolyline object */
53
57
static QgsGeometry* fromPolyline( const QgsPolyline& polyline ) /Factory/;
54
- /** construct geometry from a multipolyline */
58
+ /** Creates a new geometry from a QgsMultiPolyline object */
55
59
static QgsGeometry* fromMultiPolyline( const QgsMultiPolyline& multiline ) /Factory/;
56
- /** construct geometry from a polygon */
60
+ /** Creates a new geometry from a QgsPolygon */
57
61
static QgsGeometry* fromPolygon( const QgsPolygon& polygon ) /Factory/;
58
- /** construct geometry from a multipolygon */
62
+ /** Creates a new geometry from a QgsMultiPolygon */
59
63
static QgsGeometry* fromMultiPolygon( const QgsMultiPolygon& multipoly ) /Factory/;
60
- /** construct geometry from a rectangle */
64
+ /** Creates a new geometry from a QgsRectangle */
61
65
static QgsGeometry* fromRect( const QgsRectangle& rect ) /Factory/;
66
+
62
67
/**
63
68
Set the geometry, feeding in a geometry in GEOS format.
64
69
This class will take ownership of the buffer.
@@ -80,6 +85,7 @@ class QgsGeometry
80
85
/**
81
86
Returns the buffer containing this geometry in WKB format.
82
87
You may wish to use in conjunction with wkbSize().
88
+ @see wkbSize
83
89
*/
84
90
SIP_PYOBJECT asWkb();
85
91
%MethodCode
@@ -88,49 +94,57 @@ class QgsGeometry
88
94
89
95
/**
90
96
* Returns the size of the WKB in asWkb().
97
+ * @see asWkb
91
98
*/
92
99
size_t wkbSize() const;
93
100
94
- /**Returns a geos geomtry . QgsGeometry keeps ownership, don't delete the returned object!
101
+ /** Returns a geos geometry . QgsGeometry retains ownership of the geometry, so the returned object should not be deleted.
95
102
@note this method was added in version 1.1
96
103
@note not available in python bindings
97
104
*/
98
105
// const GEOSGeometry* asGeos() const;
99
106
100
- /** Returns type of wkb (point / linestring / polygon etc.) */
107
+ /** Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
108
+ * @see type
109
+ */
101
110
QGis::WkbType wkbType() const;
102
111
103
- /** Returns type of the vector */
112
+ /** Returns type of the geometry as a QGis::GeometryType
113
+ * @see wkbType
114
+ */
104
115
QGis::GeometryType type() const;
105
116
106
- /** Returns true if wkb of the geometry is of WKBMulti* type */
117
+ /** Returns true if WKB of the geometry is of WKBMulti* type */
107
118
bool isMultipart() const;
108
119
109
- /** compare geometries using GEOS
120
+ /** Compares the geometry with another geometry using GEOS
110
121
@note added in 1.5
111
122
*/
112
123
bool isGeosEqual( const QgsGeometry& ) const;
113
124
114
- /** check validity using GEOS
125
+ /** Checks validity of the geometry using GEOS
115
126
@note added in 1.5
116
127
*/
117
128
bool isGeosValid() const;
118
129
119
- /** check if geometry is empty using GEOS
130
+ /** Check if the geometry is empty using GEOS
120
131
@note added in 1.5
121
132
*/
122
133
bool isGeosEmpty() const;
123
134
124
- /** get area of geometry using GEOS
135
+ /** Returns the area of the geometry using GEOS
125
136
@note added in 1.5
126
137
*/
127
138
double area() const;
128
139
129
- /** get length of geometry using GEOS
140
+ /** Returns the length of geometry using GEOS
130
141
@note added in 1.5
131
142
*/
132
143
double length() const;
133
144
145
+ /** Returns the minimum distanace between this geometry and another geometry, using GEOS
146
+ * @param geom geometry to find minimum distance to
147
+ */
134
148
double distance( const QgsGeometry& geom ) const;
135
149
136
150
/**
@@ -243,31 +257,30 @@ class QgsGeometry
243
257
not disjoint with existing polygons of the feature*/
244
258
int addPart( const QList<QgsPoint> &points, QGis::GeometryType geomType = QGis::UnknownGeometry );
245
259
260
+ /**Adds a new part to this geometry (takes ownership)
261
+ @return 0 in case of success, 1 if not a multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring
262
+ not disjoint with existing polygons of the feature*/
263
+ int addPart( QgsCurveV2* part /Transfer/ );
264
+
246
265
/**Adds a new island polygon to a multipolygon feature
247
266
@return 0 in case of success, 1 if not a multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring
248
267
not disjoint with existing polygons of the feature
249
268
@note not available in python bindings
250
269
*/
251
270
// int addPart( GEOSGeometry *newPart );
252
271
253
- /**Adds a new part to this geometry (takes ownership)
254
- @return 0 in case of success, 1 if not a multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring
255
- not disjoint with existing polygons of the feature*/
256
- int addPart( QgsCurveV2* part /Transfer/ );
257
-
258
-
259
272
/**Adds a new island polygon to a multipolygon feature
260
273
@return 0 in case of success, 1 if not a multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring
261
274
not disjoint with existing polygons of the feature
262
- @note available in python bindings as addPartGeometry (added in 2.1 )
275
+ @note available in python bindings as addPartGeometry (added in 2.2 )
263
276
*/
264
277
int addPart( const QgsGeometry *newPart /Transfer/ ) /PyName=addPartGeometry/;
265
278
266
279
/**Translate this geometry by dx, dy
267
280
@return 0 in case of success*/
268
281
int translate( double dx, double dy );
269
282
270
- /**Transform this geometry as described by CoordinateTranasform ct
283
+ /**Transform this geometry as described by CoordinateTransform ct
271
284
@return 0 in case of success*/
272
285
int transform( const QgsCoordinateTransform& ct );
273
286
@@ -283,8 +296,7 @@ class QgsGeometry
283
296
@return 0 in case of success*/
284
297
int rotate( double rotation, const QgsPoint& center );
285
298
286
- /**Splits this geometry according to a given line. Note that the geometry is only split once. If there are several intersections
287
- between geometry and splitLine, only the first one is considered.
299
+ /**Splits this geometry according to a given line.
288
300
@param splitLine the line that splits the geometry
289
301
@param[out] newGeometries list of new geometries that have been created with the split
290
302
@param topological true if topological editing is enabled
@@ -303,7 +315,7 @@ class QgsGeometry
303
315
/**Changes this geometry such that it does not intersect the other geometry
304
316
@param other geometry that should not be intersect
305
317
@return 0 in case of success*/
306
- int makeDifference( QgsGeometry* other );
318
+ int makeDifference( const QgsGeometry* other );
307
319
308
320
/**Returns the bounding box of this feature*/
309
321
QgsRectangle boundingBox() const;
@@ -350,6 +362,7 @@ class QgsGeometry
350
362
QgsGeometry* buffer( double distance, int segments ) const /Factory/;
351
363
352
364
/** Returns a buffer region around the geometry, with additional style options.
365
+ * @param distance buffer distance
353
366
* @param segments For round joins, number of segments to approximate quarter-circle
354
367
* @param endCapStyle Round (1) / Flat (2) / Square (3) end cap style
355
368
* @param joinStyle Round (1) / Mitre (2) / Bevel (3) join style
@@ -386,18 +399,18 @@ class QgsGeometry
386
399
QgsGeometry* interpolate( double distance ) /Factory/;
387
400
388
401
/** Returns a geometry representing the points shared by this geometry and other. */
389
- QgsGeometry* intersection( QgsGeometry* geometry ) const /Factory/;
402
+ QgsGeometry* intersection( const QgsGeometry* geometry ) const /Factory/;
390
403
391
404
/** Returns a geometry representing all the points in this geometry and other (a
392
405
* union geometry operation).
393
406
* @note this operation is not called union since its a reserved word in C++.*/
394
- QgsGeometry* combine( QgsGeometry* geometry ) const /Factory/;
407
+ QgsGeometry* combine( const QgsGeometry* geometry ) const /Factory/;
395
408
396
409
/** Returns a geometry representing the points making up this geometry that do not make up other. */
397
- QgsGeometry* difference( QgsGeometry* geometry ) const /Factory/;
410
+ QgsGeometry* difference( const QgsGeometry* geometry ) const /Factory/;
398
411
399
412
/** Returns a Geometry representing the points making up this Geometry that do not make up other. */
400
- QgsGeometry* symDifference( QgsGeometry* geometry ) const /Factory/;
413
+ QgsGeometry* symDifference( const QgsGeometry* geometry ) const /Factory/;
401
414
402
415
/** Exports the geometry to WKT
403
416
* @note precision parameter added in 2.4
@@ -464,13 +477,13 @@ class QgsGeometry
464
477
*/
465
478
QPolygonF asQPolygonF() const;
466
479
467
- /** delete a ring in polygon or multipolygon.
480
+ /** Delete a ring in polygon or multipolygon.
468
481
Ring 0 is outer ring and can't be deleted.
469
482
@return true on success
470
483
@note added in version 1.2 */
471
484
bool deleteRing( int ringNum, int partNum = 0 );
472
485
473
- /** delete part identified by the part number
486
+ /** Delete part identified by the part number
474
487
@return true on success
475
488
@note added in version 1.2 */
476
489
bool deletePart( int partNum );
@@ -514,21 +527,61 @@ class QgsGeometry
514
527
*/
515
528
static QgsGeometry *unaryUnion( const QList<QgsGeometry*>& geometryList ) /Factory/;
516
529
530
+ /** Converts the geometry to straight line segments, if it is a curved geometry type.
531
+ * @note added in QGIS 2.10
532
+ * @see requiresConversionToStraightSegments
533
+ */
534
+ void convertToStraightSegment();
535
+
517
536
/** Returns true if the geometry is a curved geometry type which requires conversion to
518
537
* display as straight line segments.
519
538
* @note added in QGIS 2.10
520
539
* @see convertToStraightSegment
521
540
*/
522
541
bool requiresConversionToStraightSegments() const;
523
542
543
+ /** Transforms the geometry from map units to pixels in place.
544
+ * @param mtp map to pixel transform
545
+ * @note added in QGIS 2.10
546
+ */
524
547
void mapToPixel( const QgsMapToPixel& mtp );
525
-
526
- //void clip( const QgsRectangle& rect );
548
+
549
+ // not implemented for 2.10
550
+ /** Clips the geometry using the specified rectangle
551
+ * @param rect clip rectangle
552
+ * @note added in QGIS 2.10
553
+ */
554
+ // void clip( const QgsRectangle& rect );
555
+
556
+ /** Draws the geometry onto a QPainter
557
+ * @param p destination QPainter
558
+ * @note added in QGIS 2.10
559
+ */
527
560
void draw( QPainter& p ) const;
528
561
562
+ /** Calculates the vertex ID from a vertex number
563
+ * @param nr vertex number
564
+ * @param id reference to QgsVertexId for storing result
565
+ * @returns true if vertex was found
566
+ * @note added in QGIS 2.10
567
+ * @see vertexNrFromVertexId
568
+ */
529
569
bool vertexIdFromVertexNr( int nr, QgsVertexId& id ) const;
570
+
571
+ /** Returns the vertex number corresponding to a vertex idd
572
+ * @param i vertex id
573
+ * @returns vertex number
574
+ * @note added in QGIS 2.10
575
+ * @see vertexIdFromVertexNr
576
+ */
530
577
int vertexNrFromVertexId( const QgsVertexId& i ) const;
531
578
579
+ /** return GEOS context handle
580
+ * @note added in 2.6
581
+ * @note not available in Python
582
+ */
583
+ // static GEOSContextHandle_t getGEOSHandler();
584
+
532
585
/**Construct geometry from a QPointF
533
586
* @param point source QPointF
534
587
* @note added in QGIS 2.7
@@ -542,9 +595,20 @@ class QgsGeometry
542
595
* @note added in QGIS 2.7
543
596
*/
544
597
static QgsGeometry* fromQPolygonF( const QPolygonF& polygon ) /Factory/;
598
+
599
+ /** Creates a QgsPolyline from a QPolygonF.
600
+ * @param polygon source polygon
601
+ * @returns QgsPolyline
602
+ * @see createPolygonFromQPolygonF
603
+ */
545
604
static QgsPolyline createPolylineFromQPolygonF( const QPolygonF &polygon ) /Factory/;
546
- static QgsPolygon createPolygonFromQPolygonF( const QPolygonF &polygon ) /Factory/;
547
605
606
+ /** Creates a QgsPolygon from a QPolygonF.
607
+ * @param polygon source polygon
608
+ * @returns QgsPolygon
609
+ * @see createPolylineFromQPolygonF
610
+ */
611
+ static QgsPolygon createPolygonFromQPolygonF( const QPolygonF &polygon ) /Factory/;
548
612
549
613
/** Compares two polylines for equality within a specified tolerance.
550
614
* @param p1 first polyline
@@ -586,7 +650,7 @@ class QgsGeometry
586
650
* of the geometry for each iteration. Smaller values result in "tighter" smoothing.
587
651
* @note added in 2.9
588
652
*/
589
- QgsGeometry* smooth( const unsigned int iterations, const double offset ) const;
653
+ QgsGeometry* smooth( const unsigned int iterations, const double offset ) const;
590
654
591
655
/**Smooths a polygon using the Chaikin algorithm*/
592
656
QgsPolygon smoothPolygon( const QgsPolygon &polygon, const unsigned int iterations = 1, const double offset = 0.25 ) const;
0 commit comments