Skip to content

Commit 7a63a07

Browse files
committed
Add return cases to the docs and fully qualified enums
1 parent 4f82adf commit 7a63a07

File tree

5 files changed

+120
-32
lines changed

5 files changed

+120
-32
lines changed

python/core/qgsvectorlayer.sip

+44
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,13 @@ Return the provider type for this layer
10491049
\param ring ring to add
10501050
\param featureId if specified, feature ID for feature ring was added to will be stored in this parameter
10511051
:return: QgsGeometry.OperationResult
1052+
- Success
1053+
- LayerNotEditable
1054+
- AddRingNotInExistingFeature
1055+
- InvalidInputGeometryType
1056+
- AddRingNotClosed
1057+
- AddRingNotValid
1058+
- AddRingCrossesExistingRings
10521059
:rtype: QgsGeometry.OperationResult
10531060
%End
10541061

@@ -1058,6 +1065,13 @@ Return the provider type for this layer
10581065
\param ring ring to add
10591066
\param featureId if specified, feature ID for feature ring was added to will be stored in this parameter
10601067
:return: QgsGeometry.OperationResult
1068+
- Success
1069+
- LayerNotEditable
1070+
- AddRingNotInExistingFeature
1071+
- InvalidInputGeometryType
1072+
- AddRingNotClosed
1073+
- AddRingNotValid
1074+
- AddRingCrossesExistingRings
10611075
.. note::
10621076

10631077
available in Python as addCurvedRing
@@ -1068,13 +1082,29 @@ Return the provider type for this layer
10681082
%Docstring
10691083
Adds a new part polygon to a multipart feature
10701084
:return: QgsGeometry.OperationResult
1085+
- Success
1086+
- LayerNotEditable
1087+
- SelectionIsEmpty
1088+
- SelectionIsGreaterThanOne
1089+
- AddPartSelectedGeometryNotFound
1090+
- AddPartNotMultiGeometry
1091+
- InvalidBaseGeometry
1092+
- InvalidInputGeometryType
10711093
:rtype: QgsGeometry.OperationResult
10721094
%End
10731095

10741096
QgsGeometry::OperationResult addPart( const QgsPointSequence &ring ) /PyName=addPartV2/;
10751097
%Docstring
10761098
Adds a new part polygon to a multipart feature
10771099
:return: QgsGeometry.OperationResult
1100+
- Success
1101+
- LayerNotEditable
1102+
- SelectionIsEmpty
1103+
- SelectionIsGreaterThanOne
1104+
- AddPartSelectedGeometryNotFound
1105+
- AddPartNotMultiGeometry
1106+
- InvalidBaseGeometry
1107+
- InvalidInputGeometryType
10781108
.. note::
10791109

10801110
available in Python bindings as addPartV2
@@ -1105,6 +1135,13 @@ Return the provider type for this layer
11051135
\param splitLine line that splits the layer features
11061136
\param topologicalEditing true if topological editing is enabled
11071137
:return: QgsGeometry.OperationResult
1138+
- Success
1139+
- NothingHappened
1140+
- LayerNotEditable
1141+
- InvalidInputGeometryType
1142+
- InvalidBaseGeometry
1143+
- GeometryEngineError
1144+
- SplitCannotSplitPoint
11081145
:rtype: QgsGeometry.OperationResult
11091146
%End
11101147

@@ -1114,6 +1151,13 @@ Return the provider type for this layer
11141151
\param splitLine line that splits the layer features
11151152
\param topologicalEditing true if topological editing is enabled
11161153
:return: QgsGeometry.OperationResult
1154+
- Success
1155+
- NothingHappened
1156+
- LayerNotEditable
1157+
- InvalidInputGeometryType
1158+
- InvalidBaseGeometry
1159+
- GeometryEngineError
1160+
- SplitCannotSplitPoint
11171161
:rtype: QgsGeometry.OperationResult
11181162
%End
11191163

src/core/geometry/qgsgeometry.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ QgsGeometry::OperationResult QgsGeometry::addPart( QgsAbstractGeometry *part, Qg
674674
break;
675675
default:
676676
reset( nullptr );
677-
return QgsGeometry::AddPartNotMultiGeometry;
677+
return QgsGeometry::OperationResult::AddPartNotMultiGeometry;
678678
}
679679
}
680680
else
@@ -785,7 +785,7 @@ QgsGeometry::OperationResult QgsGeometry::splitGeometry( const QVector<QgsPointX
785785
{
786786
if ( !d->geometry )
787787
{
788-
return InvalidBaseGeometry;
788+
return QgsGeometry::OperationResult::InvalidBaseGeometry;
789789
}
790790

791791
QVector<QgsGeometry > newGeoms;
@@ -808,19 +808,19 @@ QgsGeometry::OperationResult QgsGeometry::splitGeometry( const QVector<QgsPointX
808808
switch ( result )
809809
{
810810
case QgsGeometryEngine::Success:
811-
return QgsGeometry::Success;
811+
return QgsGeometry::OperationResult::Success;
812812
case QgsGeometryEngine::MethodNotImplemented:
813813
case QgsGeometryEngine::EngineError:
814814
case QgsGeometryEngine::NodedGeometryError:
815-
return QgsGeometry::GeometryEngineError;
815+
return QgsGeometry::OperationResult::GeometryEngineError;
816816
case QgsGeometryEngine::InvalidBaseGeometry:
817-
return QgsGeometry::InvalidBaseGeometry;
817+
return QgsGeometry::OperationResult::InvalidBaseGeometry;
818818
case QgsGeometryEngine::InvalidInput:
819-
return QgsGeometry::InvalidInputGeometryType;
819+
return QgsGeometry::OperationResult::InvalidInputGeometryType;
820820
case QgsGeometryEngine::SplitCannotSplitPoint:
821-
return QgsGeometry::SplitCannotSplitPoint;
821+
return QgsGeometry::OperationResult::SplitCannotSplitPoint;
822822
case QgsGeometryEngine::NothingHappened:
823-
return QgsGeometry::NothingHappened;
823+
return QgsGeometry::OperationResult::NothingHappened;
824824
//default: do not implement default to handle properly all cases
825825
}
826826

src/core/geometry/qgsgeometryeditutils.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,17 @@ QgsGeometry::OperationResult QgsGeometryEditUtils::addRing( QgsAbstractGeometry
5050
}
5151
else
5252
{
53-
return QgsGeometry::InvalidInputGeometryType; //not polygon / multipolygon;
53+
return QgsGeometry::OperationResult::InvalidInputGeometryType; //not polygon / multipolygon;
5454
}
5555

5656
//ring must be closed
5757
if ( !ring->isClosed() )
5858
{
59-
return QgsGeometry::AddRingNotClosed;
59+
return QgsGeometry::OperationResult::AddRingNotClosed;
6060
}
6161
else if ( !ring->isRing() )
6262
{
63-
return QgsGeometry::AddRingNotValid;
63+
return QgsGeometry::OperationResult::AddRingNotValid;
6464
}
6565

6666
std::unique_ptr<QgsGeometryEngine> ringGeom( QgsGeometry::createGeometryEngine( ring.get() ) );
@@ -78,7 +78,7 @@ QgsGeometry::OperationResult QgsGeometryEditUtils::addRing( QgsAbstractGeometry
7878
{
7979
if ( !ringGeom->disjoint( ( *polyIter )->interiorRing( i ) ) )
8080
{
81-
return QgsGeometry::AddRingCrossesExistingRings;
81+
return QgsGeometry::OperationResult::AddRingCrossesExistingRings;
8282
}
8383
}
8484

@@ -89,29 +89,29 @@ QgsGeometry::OperationResult QgsGeometryEditUtils::addRing( QgsAbstractGeometry
8989
ring->addMValue( 0 );
9090

9191
( *polyIter )->addInteriorRing( ring.release() );
92-
return QgsGeometry::Success; //success
92+
return QgsGeometry::OperationResult::Success; //success
9393
}
9494
}
95-
return QgsGeometry::AddRingNotInExistingFeature; //not contained in any outer ring
95+
return QgsGeometry::OperationResult::AddRingNotInExistingFeature; //not contained in any outer ring
9696
}
9797

9898
QgsGeometry::OperationResult QgsGeometryEditUtils::addPart( QgsAbstractGeometry *geom, std::unique_ptr<QgsAbstractGeometry> part )
9999
{
100100
if ( !geom )
101101
{
102-
return QgsGeometry::InvalidBaseGeometry;
102+
return QgsGeometry::OperationResult::InvalidBaseGeometry;
103103
}
104104

105105
if ( !part )
106106
{
107-
return QgsGeometry::InvalidInputGeometryType;
107+
return QgsGeometry::OperationResult::InvalidInputGeometryType;
108108
}
109109

110110
//multitype?
111111
QgsGeometryCollection *geomCollection = qgsgeometry_cast<QgsGeometryCollection *>( geom );
112112
if ( !geomCollection )
113113
{
114-
return QgsGeometry::AddPartNotMultiGeometry;
114+
return QgsGeometry::OperationResult::AddPartNotMultiGeometry;
115115
}
116116

117117
bool added = false;
@@ -155,19 +155,19 @@ QgsGeometry::OperationResult QgsGeometryEditUtils::addPart( QgsAbstractGeometry
155155
{
156156
while ( geomCollection->numGeometries() > n )
157157
geomCollection->removeGeometry( n );
158-
return QgsGeometry::InvalidInputGeometryType;
158+
return QgsGeometry::OperationResult::InvalidInputGeometryType;
159159
}
160160
}
161161
else
162162
{
163-
return QgsGeometry::InvalidInputGeometryType;
163+
return QgsGeometry::OperationResult::InvalidInputGeometryType;
164164
}
165165
}
166166
else
167167
{
168168
added = geomCollection->addGeometry( part.release() );
169169
}
170-
return added ? QgsGeometry::Success : QgsGeometry::InvalidInputGeometryType;
170+
return added ? QgsGeometry::Success : QgsGeometry::OperationResult::InvalidInputGeometryType;
171171
}
172172

173173
bool QgsGeometryEditUtils::deleteRing( QgsAbstractGeometry *geom, int ringNum, int partNum )

src/core/qgsvectorlayer.h

+44
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,13 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
10501050
* \param ring ring to add
10511051
* \param featureId if specified, feature ID for feature ring was added to will be stored in this parameter
10521052
* \returns QgsGeometry::OperationResult
1053+
* - Success
1054+
* - LayerNotEditable
1055+
* - AddRingNotInExistingFeature
1056+
* - InvalidInputGeometryType
1057+
* - AddRingNotClosed
1058+
* - AddRingNotValid
1059+
* - AddRingCrossesExistingRings
10531060
*/
10541061
QgsGeometry::OperationResult addRing( const QVector<QgsPointXY> &ring, QgsFeatureId *featureId = nullptr );
10551062

@@ -1058,19 +1065,42 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
10581065
* \param ring ring to add
10591066
* \param featureId if specified, feature ID for feature ring was added to will be stored in this parameter
10601067
* \returns QgsGeometry::OperationResult
1068+
* - Success
1069+
* - LayerNotEditable
1070+
* - AddRingNotInExistingFeature
1071+
* - InvalidInputGeometryType
1072+
* - AddRingNotClosed
1073+
* - AddRingNotValid
1074+
* - AddRingCrossesExistingRings
10611075
* \note available in Python as addCurvedRing
10621076
*/
10631077
QgsGeometry::OperationResult addRing( QgsCurve *ring SIP_TRANSFER, QgsFeatureId *featureId = nullptr ) SIP_PYNAME( addCurvedRing );
10641078

10651079
/**
10661080
* Adds a new part polygon to a multipart feature
10671081
* \returns QgsGeometry::OperationResult
1082+
* - Success
1083+
* - LayerNotEditable
1084+
* - SelectionIsEmpty
1085+
* - SelectionIsGreaterThanOne
1086+
* - AddPartSelectedGeometryNotFound
1087+
* - AddPartNotMultiGeometry
1088+
* - InvalidBaseGeometry
1089+
* - InvalidInputGeometryType
10681090
*/
10691091
QgsGeometry::OperationResult addPart( const QList<QgsPointXY> &ring );
10701092

10711093
/**
10721094
* Adds a new part polygon to a multipart feature
10731095
* \returns QgsGeometry::OperationResult
1096+
* - Success
1097+
* - LayerNotEditable
1098+
* - SelectionIsEmpty
1099+
* - SelectionIsGreaterThanOne
1100+
* - AddPartSelectedGeometryNotFound
1101+
* - AddPartNotMultiGeometry
1102+
* - InvalidBaseGeometry
1103+
* - InvalidInputGeometryType
10741104
* \note available in Python bindings as addPartV2
10751105
*/
10761106
QgsGeometry::OperationResult addPart( const QgsPointSequence &ring ) SIP_PYNAME( addPartV2 );
@@ -1092,6 +1122,13 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
10921122
* \param splitLine line that splits the layer features
10931123
* \param topologicalEditing true if topological editing is enabled
10941124
* \returns QgsGeometry::OperationResult
1125+
* - Success
1126+
* - NothingHappened
1127+
* - LayerNotEditable
1128+
* - InvalidInputGeometryType
1129+
* - InvalidBaseGeometry
1130+
* - GeometryEngineError
1131+
* - SplitCannotSplitPoint
10951132
*/
10961133
QgsGeometry::OperationResult splitParts( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false );
10971134

@@ -1100,6 +1137,13 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
11001137
* \param splitLine line that splits the layer features
11011138
* \param topologicalEditing true if topological editing is enabled
11021139
* \returns QgsGeometry::OperationResult
1140+
* - Success
1141+
* - NothingHappened
1142+
* - LayerNotEditable
1143+
* - InvalidInputGeometryType
1144+
* - InvalidBaseGeometry
1145+
* - GeometryEngineError
1146+
* - SplitCannotSplitPoint
11031147
*/
11041148
QgsGeometry::OperationResult splitFeatures( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false );
11051149

0 commit comments

Comments
 (0)