@@ -65,21 +65,21 @@ class QgsGeometry
65
65
bool isEmpty() const;
66
66
67
67
/** Creates a new geometry from a WKT string */
68
- static QgsGeometry* fromWkt( const QString& wkt ) /Factory/ ;
68
+ static QgsGeometry fromWkt( const QString& wkt );
69
69
/** Creates a new geometry from a QgsPoint object*/
70
- static QgsGeometry* fromPoint( const QgsPoint& point ) /Factory/ ;
70
+ static QgsGeometry fromPoint( const QgsPoint& point );
71
71
/** Creates a new geometry from a QgsMultiPoint object */
72
- static QgsGeometry* fromMultiPoint( const QgsMultiPoint& multipoint ) /Factory/ ;
72
+ static QgsGeometry fromMultiPoint( const QgsMultiPoint& multipoint );
73
73
/** Creates a new geometry from a QgsPolyline object */
74
- static QgsGeometry* fromPolyline( const QgsPolyline& polyline ) /Factory/ ;
74
+ static QgsGeometry fromPolyline( const QgsPolyline& polyline );
75
75
/** Creates a new geometry from a QgsMultiPolyline object*/
76
- static QgsGeometry* fromMultiPolyline( const QgsMultiPolyline& multiline ) /Factory/ ;
76
+ static QgsGeometry fromMultiPolyline( const QgsMultiPolyline& multiline );
77
77
/** Creates a new geometry from a QgsPolygon */
78
- static QgsGeometry* fromPolygon( const QgsPolygon& polygon ) /Factory/ ;
78
+ static QgsGeometry fromPolygon( const QgsPolygon& polygon );
79
79
/** Creates a new geometry from a QgsMultiPolygon */
80
- static QgsGeometry* fromMultiPolygon( const QgsMultiPolygon& multipoly ) /Factory/ ;
80
+ static QgsGeometry fromMultiPolygon( const QgsMultiPolygon& multipoly );
81
81
/** Creates a new geometry from a QgsRectangle */
82
- static QgsGeometry* fromRect( const QgsRectangle& rect ) /Factory/ ;
82
+ static QgsGeometry fromRect( const QgsRectangle& rect );
83
83
84
84
/**
85
85
* Set the geometry, feeding in a geometry in GEOS format.
@@ -393,49 +393,57 @@ class QgsGeometry
393
393
*/
394
394
int makeDifference( const QgsGeometry* other );
395
395
396
+ /** Returns the geometry formed by modifying this geometry such that it does not
397
+ * intersect the other geometry.
398
+ * @param other geometry that should not be intersect
399
+ * @return difference geometry, or empty geometry if difference could not be calculated
400
+ * @note added in QGIS 3.0
401
+ */
402
+ QgsGeometry makeDifference( const QgsGeometry& other ) const;
403
+
396
404
/** Returns the bounding box of this feature*/
397
405
QgsRectangle boundingBox() const;
398
406
399
407
/** Test for intersection with a rectangle (uses GEOS) */
400
408
bool intersects( const QgsRectangle& r ) const;
401
409
402
410
/** Test for intersection with a geometry (uses GEOS) */
403
- bool intersects( const QgsGeometry* geometry ) const;
411
+ bool intersects( const QgsGeometry& geometry ) const;
404
412
405
413
/** Test for containment of a point (uses GEOS) */
406
414
bool contains( const QgsPoint* p ) const;
407
415
408
416
/** Test for if geometry is contained in another (uses GEOS)
409
417
* @note added in 1.5 */
410
- bool contains( const QgsGeometry* geometry ) const;
418
+ bool contains( const QgsGeometry& geometry ) const;
411
419
412
420
/** Test for if geometry is disjoint of another (uses GEOS)
413
421
* @note added in 1.5 */
414
- bool disjoint( const QgsGeometry* geometry ) const;
422
+ bool disjoint( const QgsGeometry& geometry ) const;
415
423
416
424
/** Test for if geometry equals another (uses GEOS)
417
425
* @note added in 1.5 */
418
- bool equals( const QgsGeometry* geometry ) const;
426
+ bool equals( const QgsGeometry& geometry ) const;
419
427
420
428
/** Test for if geometry touch another (uses GEOS)
421
429
* @note added in 1.5 */
422
- bool touches( const QgsGeometry* geometry ) const;
430
+ bool touches( const QgsGeometry& geometry ) const;
423
431
424
432
/** Test for if geometry overlaps another (uses GEOS)
425
433
* @note added in 1.5 */
426
- bool overlaps( const QgsGeometry* geometry ) const;
434
+ bool overlaps( const QgsGeometry& geometry ) const;
427
435
428
436
/** Test for if geometry is within another (uses GEOS)
429
437
* @note added in 1.5 */
430
- bool within( const QgsGeometry* geometry ) const;
438
+ bool within( const QgsGeometry& geometry ) const;
431
439
432
440
/** Test for if geometry crosses another (uses GEOS)
433
441
* @note added in 1.5 */
434
- bool crosses( const QgsGeometry* geometry ) const;
442
+ bool crosses( const QgsGeometry& geometry ) const;
435
443
436
444
/** Returns a buffer region around this geometry having the given width and with a specified number
437
445
of segments used to approximate curves */
438
- QgsGeometry* buffer( double distance, int segments ) const /Factory/ ;
446
+ QgsGeometry buffer( double distance, int segments ) const;
439
447
440
448
/** Returns a buffer region around the geometry, with additional style options.
441
449
* @param distance buffer distance
@@ -446,44 +454,44 @@ class QgsGeometry
446
454
* @note added in 2.4
447
455
* @note needs GEOS >= 3.3 - otherwise always returns 0
448
456
*/
449
- QgsGeometry* buffer( double distance, int segments, int endCapStyle, int joinStyle, double mitreLimit ) const /Factory/ ;
457
+ QgsGeometry buffer( double distance, int segments, int endCapStyle, int joinStyle, double mitreLimit ) const;
450
458
451
459
/** Returns an offset line at a given distance and side from an input line.
452
460
* See buffer() method for details on parameters.
453
461
* @note added in 2.4
454
462
* @note needs GEOS >= 3.3 - otherwise always returns 0
455
463
*/
456
- QgsGeometry* offsetCurve( double distance, int segments, int joinStyle, double mitreLimit ) const /Factory/ ;
464
+ QgsGeometry offsetCurve( double distance, int segments, int joinStyle, double mitreLimit ) const;
457
465
458
466
/** Returns a simplified version of this geometry using a specified tolerance value */
459
- QgsGeometry* simplify( double tolerance ) const /Factory/ ;
467
+ QgsGeometry simplify( double tolerance ) const;
460
468
461
469
/** Returns the center of mass of a geometry
462
470
* @note for line based geometries, the center point of the line is returned,
463
471
* and for point based geometries, the point itself is returned
464
472
*/
465
- QgsGeometry* centroid() const /Factory/ ;
473
+ QgsGeometry centroid() const;
466
474
467
475
/** Returns a point within a geometry */
468
- QgsGeometry* pointOnSurface() const /Factory/ ;
476
+ QgsGeometry pointOnSurface() const;
469
477
470
478
/** Returns the smallest convex polygon that contains all the points in the geometry. */
471
- QgsGeometry* convexHull() const /Factory/ ;
479
+ QgsGeometry convexHull() const;
472
480
473
481
/**
474
482
* Return interpolated point on line at distance
475
483
* @note added in 1.9
476
484
*/
477
- QgsGeometry* interpolate( double distance ) /Factory/ ;
485
+ QgsGeometry interpolate( double distance );
478
486
479
487
/** Returns a geometry representing the points shared by this geometry and other. */
480
- QgsGeometry* intersection( const QgsGeometry* geometry ) const /Factory/ ;
488
+ QgsGeometry intersection( const QgsGeometry& geometry ) const;
481
489
482
490
/** Returns a geometry representing all the points in this geometry and other (a
483
491
* union geometry operation).
484
492
* @note this operation is not called union since its a reserved word in C++.
485
493
*/
486
- QgsGeometry* combine( const QgsGeometry* geometry ) const /Factory/ ;
494
+ QgsGeometry combine( const QgsGeometry& geometry ) const;
487
495
488
496
/** Merges any connected lines in a LineString/MultiLineString geometry and
489
497
* converts them to single line strings.
@@ -495,10 +503,10 @@ class QgsGeometry
495
503
QgsGeometry mergeLines() const;
496
504
497
505
/** Returns a geometry representing the points making up this geometry that do not make up other. */
498
- QgsGeometry* difference( const QgsGeometry* geometry ) const /Factory/ ;
506
+ QgsGeometry difference( const QgsGeometry& geometry ) const;
499
507
500
508
/** Returns a geometry representing the points making up this geometry that do not make up other. */
501
- QgsGeometry* symDifference( const QgsGeometry* geometry ) const /Factory/ ;
509
+ QgsGeometry symDifference( const QgsGeometry& geometry ) const;
502
510
503
511
/** Returns an extruded version of this geometry. */
504
512
QgsGeometry extrude( double x, double y );
@@ -523,7 +531,7 @@ class QgsGeometry
523
531
* @return the converted geometry or nullptr if the conversion fails.
524
532
* @note added in 2.2
525
533
*/
526
- QgsGeometry* convertToType( Qgis::GeometryType destType, bool destMultipart = false ) const /Factory/ ;
534
+ QgsGeometry convertToType( Qgis::GeometryType destType, bool destMultipart = false ) const;
527
535
528
536
/* Accessor functions for getting geometry data */
529
537
@@ -556,7 +564,7 @@ class QgsGeometry
556
564
557
565
/** Return contents of the geometry as a list of geometries
558
566
@note added in version 1.1 */
559
- QList<QgsGeometry* > asGeometryCollection() const /Factory/ ;
567
+ QList<QgsGeometry> asGeometryCollection() const;
560
568
561
569
/** Return contents of the geometry as a QPointF if wkbType is WKBPoint,
562
570
* otherwise returns a null QPointF.
@@ -635,7 +643,7 @@ class QgsGeometry
635
643
* @param geometryList a list of QgsGeometry* as input
636
644
* @returns the new computed QgsGeometry, or null
637
645
*/
638
- static QgsGeometry * unaryUnion( const QList<QgsGeometry* >& geometryList ) /Factory/ ;
646
+ static QgsGeometry unaryUnion( const QList<QgsGeometry>& geometryList );
639
647
640
648
/** Converts the geometry to straight line segments, if it is a curved geometry type.
641
649
* @note added in QGIS 2.10
@@ -696,15 +704,15 @@ class QgsGeometry
696
704
* @param point source QPointF
697
705
* @note added in QGIS 2.7
698
706
*/
699
- static QgsGeometry* fromQPointF( QPointF point ) /Factory/ ;
707
+ static QgsGeometry fromQPointF( QPointF point );
700
708
701
709
/** Construct geometry from a QPolygonF. If the polygon is closed than
702
710
* the resultant geometry will be a polygon, if it is open than the
703
711
* geometry will be a polyline.
704
712
* @param polygon source QPolygonF
705
713
* @note added in QGIS 2.7
706
714
*/
707
- static QgsGeometry* fromQPolygonF( const QPolygonF& polygon ) /Factory/ ;
715
+ static QgsGeometry fromQPolygonF( const QPolygonF& polygon );
708
716
709
717
/** Creates a QgsPolyline from a QPolygonF.
710
718
* @param polygon source polygon
@@ -760,7 +768,7 @@ class QgsGeometry
760
768
* of the geometry for each iteration. Smaller values result in "tighter" smoothing.
761
769
* @note added in 2.9
762
770
*/
763
- QgsGeometry* smooth( const unsigned int iterations, const double offset ) const;
771
+ QgsGeometry smooth( const unsigned int iterations, const double offset ) const;
764
772
765
773
/** Smooths a polygon using the Chaikin algorithm*/
766
774
QgsPolygon smoothPolygon( const QgsPolygon &polygon, const unsigned int iterations = 1, const double offset = 0.25 ) const;
@@ -786,5 +794,11 @@ class QgsGeometry
786
794
//! Allows direct construction of QVariants from geometry.
787
795
operator QVariant() const;
788
796
797
+ /** Returns true if the geometry is non empty (ie, isEmpty() returns false),
798
+ * or false if it is an empty, uninitialised geometry (ie, ieEmpty() returns true).
799
+ * @note added in QGIS 3.0
800
+ */
801
+ operator bool() const;
802
+
789
803
}; // class QgsGeometry
790
804
0 commit comments