@@ -44,6 +44,23 @@ class QgsGeometry
44
44
#include "qgsgeometry.h"
45
45
%End
46
46
public:
47
+
48
+ enum OperationResult
49
+ {
50
+ Success,
51
+ NothingHappened,
52
+ InvalidBaseGeometry,
53
+ InvalidInput,
54
+ GeometryEngineError,
55
+ AddPartSelectedGeometryNotFound,
56
+ AddPartNotMultiGeometry,
57
+ AddRingNotClosed,
58
+ AddRingNotValid,
59
+ AddRingCrossesExistingRings,
60
+ AddRingNotInExistingFeature,
61
+ SplitCannotSplitPoint,
62
+ };
63
+
47
64
QgsGeometry();
48
65
%Docstring
49
66
Constructor
@@ -380,63 +397,58 @@ Returns true if WKB of the geometry is of WKBMulti* type
380
397
:rtype: float
381
398
%End
382
399
383
- int addRing( const QList<QgsPointXY> &ring );
400
+ OperationResult addRing( const QList<QgsPointXY> &ring );
384
401
%Docstring
385
402
Adds a new ring to this geometry. This makes only sense for polygon and multipolygons.
386
- :return: 0 in case of success ( ring added), 1 problem with geometry type, 2 ring not closed,
387
- 3 ring is not valid geometry, 4 ring not disjoint with existing rings, 5 no polygon found which contained the ring*
388
- :rtype: int
403
+ \param ring The ring to be added
404
+ :return: OperationResult a result code: success or reason of failure
405
+ :rtype: OperationResult
389
406
%End
390
407
391
- int addRing( QgsCurve *ring /Transfer/ );
408
+ OperationResult addRing( QgsCurve *ring /Transfer/ );
392
409
%Docstring
393
410
Adds a new ring to this geometry. This makes only sense for polygon and multipolygons.
394
- :return: 0 in case of success ( ring added), 1 problem with geometry type, 2 ring not closed,
395
- 3 ring is not valid geometry, 4 ring not disjoint with existing rings, 5 no polygon found which contained the ring*
396
- :rtype: int
411
+ \param ring The ring to be added
412
+ :return: OperationResult a result code: success or reason of failure
413
+ :rtype: OperationResult
397
414
%End
398
415
399
- int addPart( const QList<QgsPointXY> &points, QgsWkbTypes::GeometryType geomType = QgsWkbTypes::UnknownGeometry ) /PyName=addPoints/;
416
+ OperationResult addPart( const QList<QgsPointXY> &points, QgsWkbTypes::GeometryType geomType = QgsWkbTypes::UnknownGeometry ) /PyName=addPoints/;
400
417
%Docstring
401
418
Adds a new part to a the geometry.
402
419
\param points points describing part to add
403
420
\param geomType default geometry type to create if no existing geometry
404
- :return: 0 in case of success, 1 if not a multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring
405
- not disjoint with existing polygons of the feature
406
- :rtype: int
421
+ :return: OperationResult a result code: success or reason of failure
422
+ :rtype: OperationResult
407
423
%End
408
424
409
- int addPart( const QgsPointSequence &points, QgsWkbTypes::GeometryType geomType = QgsWkbTypes::UnknownGeometry ) /PyName=addPointsV2/;
425
+ OperationResult addPart( const QgsPointSequence &points, QgsWkbTypes::GeometryType geomType = QgsWkbTypes::UnknownGeometry ) /PyName=addPointsV2/;
410
426
%Docstring
411
427
Adds a new part to a the geometry.
412
428
\param points points describing part to add
413
429
\param geomType default geometry type to create if no existing geometry
414
- :return: 0 in case of success, 1 if not a multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring
415
- not disjoint with existing polygons of the feature
416
- :rtype: int
430
+ :return: OperationResult a result code: success or reason of failure
431
+ :rtype: OperationResult
417
432
%End
418
433
419
- int addPart( QgsAbstractGeometry *part /Transfer/, QgsWkbTypes::GeometryType geomType = QgsWkbTypes::UnknownGeometry );
434
+ OperationResult addPart( QgsAbstractGeometry *part /Transfer/, QgsWkbTypes::GeometryType geomType = QgsWkbTypes::UnknownGeometry );
420
435
%Docstring
421
436
Adds a new part to this geometry.
422
437
\param part part to add (ownership is transferred)
423
438
\param geomType default geometry type to create if no existing geometry
424
- :return: 0 in case of success, 1 if not a multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring
425
- not disjoint with existing polygons of the feature
426
- :rtype: int
439
+ :return: OperationResult a result code: success or reason of failure
440
+ :rtype: OperationResult
427
441
%End
428
442
429
443
430
- int addPart( const QgsGeometry &newPart ) /PyName=addPartGeometry/;
444
+ OperationResult addPart( const QgsGeometry &newPart ) /PyName=addPartGeometry/;
431
445
%Docstring
432
446
Adds a new island polygon to a multipolygon feature
433
- :return: 0 in case of success, 1 if not a multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring
434
- not disjoint with existing polygons of the feature
447
+ :return: OperationResult a result code: success or reason of failure
435
448
.. note::
436
449
437
- available in Python bindings as addPartGeometry
438
- .. versionadded:: 2.2
439
- :rtype: int
450
+ available in python bindings as addPartGeometry
451
+ :rtype: OperationResult
440
452
%End
441
453
442
454
QgsGeometry removeInteriorRings( double minimumAllowedArea = -1 ) const;
@@ -448,52 +460,52 @@ not disjoint with existing polygons of the feature
448
460
:rtype: QgsGeometry
449
461
%End
450
462
451
- int translate( double dx, double dy );
463
+ OperationResult translate( double dx, double dy );
452
464
%Docstring
453
465
Translate this geometry by dx, dy
454
- :return: 0 in case of success*
455
- :rtype: int
466
+ :return: OperationResult a result code: success or reason of failure
467
+ :rtype: OperationResult
456
468
%End
457
469
458
- int transform( const QgsCoordinateTransform &ct );
470
+ OperationResult transform( const QgsCoordinateTransform &ct );
459
471
%Docstring
460
472
Transform this geometry as described by CoordinateTransform ct
461
- :return: 0 in case of success*
462
- :rtype: int
473
+ :return: OperationResult a result code: success or reason of failure
474
+ :rtype: OperationResult
463
475
%End
464
476
465
- int transform( const QTransform &ct );
477
+ OperationResult transform( const QTransform &ct );
466
478
%Docstring
467
479
Transform this geometry as described by QTransform ct
468
- .. versionadded:: 2.8
469
- :return: 0 in case of success*
470
- :rtype: int
480
+ :return: OperationResult a result code: success or reason of failure
481
+ :rtype: OperationResult
471
482
%End
472
483
473
- int rotate( double rotation, const QgsPointXY ¢er );
484
+ OperationResult rotate( double rotation, const QgsPointXY ¢er );
474
485
%Docstring
475
486
Rotate this geometry around the Z axis
476
- .. versionadded:: 2.8
477
- \param rotation clockwise rotation in degrees
478
- \param center rotation center
479
- :return: 0 in case of success*
480
- :rtype: int
487
+ \param rotation clockwise rotation in degrees
488
+ \param center rotation center
489
+ :return: OperationResult a result code: success or reason of failure
490
+ :rtype: OperationResult
481
491
%End
482
492
483
- int splitGeometry( const QList<QgsPointXY> &splitLine,
484
- QList<QgsGeometry> &newGeometries /Out/,
485
- bool topological,
486
- QList<QgsPointXY> &topologyTestPoints /Out/ );
493
+ OperationResult splitGeometry( const QList<QgsPointXY> &splitLine, QList<QgsGeometry> &newGeometries, bool topological, QList<QgsPointXY> &topologyTestPoints );
487
494
%Docstring
488
- :rtype: int
495
+ Splits this geometry according to a given line.
496
+ \param splitLine the line that splits the geometry
497
+ \param[out] newGeometries list of new geometries that have been created with the split
498
+ \param topological true if topological editing is enabled
499
+ \param[out] topologyTestPoints points that need to be tested for topological completeness in the dataset
500
+ :return: OperationResult a result code: success or reason of failure
501
+ :rtype: OperationResult
489
502
%End
490
503
491
- int reshapeGeometry( const QgsLineString &reshapeLineString );
504
+ OperationResult reshapeGeometry( const QgsLineString &reshapeLineString );
492
505
%Docstring
493
506
Replaces a part of this geometry with another line
494
- :return: 0 in case of success
495
- .. versionadded:: 1.3
496
- :rtype: int
507
+ :return: OperationResult a result code: success or reason of failure
508
+ :rtype: OperationResult
497
509
%End
498
510
499
511
0 commit comments