19
19
#include " qgis_core.h"
20
20
#include " qgis.h"
21
21
#include " qgsfeature.h"
22
-
23
- #include " qgsvectorlayer.h"
24
22
#include " qgsgeometry.h"
23
+ #include " qgsvectorlayer.h"
25
24
26
25
class QgsCurve ;
27
26
@@ -33,138 +32,146 @@ class CORE_EXPORT QgsVectorLayerEditUtils
33
32
public:
34
33
QgsVectorLayerEditUtils ( QgsVectorLayer *layer );
35
34
36
- /* * Insert a new vertex before the given vertex number,
37
- * in the given ring, item (first number is index 0), and feature
38
- * Not meaningful for Point geometries
35
+ /* *
36
+ * Insert a new vertex before the given vertex number,
37
+ * in the given ring, item (first number is index 0), and feature
38
+ * Not meaningful for Point geometries
39
39
*/
40
40
bool insertVertex ( double x, double y, QgsFeatureId atFeatureId, int beforeVertex );
41
41
42
- /* * Insert a new vertex before the given vertex number,
43
- * in the given ring, item (first number is index 0), and feature
44
- * Not meaningful for Point geometries
42
+ /* *
43
+ * Inserts a new vertex before the given vertex number,
44
+ * in the given ring, item (first number is index 0), and feature
45
+ * Not meaningful for Point geometries
45
46
*/
46
47
bool insertVertex ( const QgsPoint &point, QgsFeatureId atFeatureId, int beforeVertex );
47
48
48
- /* * Moves the vertex at the given position number,
49
- * ring and item (first number is index 0), and feature
50
- * to the given coordinates
49
+ /* *
50
+ * Moves the vertex at the given position number,
51
+ * ring and item (first number is index 0), and feature
52
+ * to the given coordinates
51
53
*/
52
54
bool moveVertex ( double x, double y, QgsFeatureId atFeatureId, int atVertex );
53
55
54
- /* * Moves the vertex at the given position number,
55
- * ring and item (first number is index 0), and feature
56
- * to the given coordinates
57
- * \note available in Python bindings as moveVertexV2
56
+ /* *
57
+ * Moves the vertex at the given position number,
58
+ * ring and item (first number is index 0), and feature
59
+ * to the given coordinates
60
+ * \note available in Python bindings as moveVertexV2
58
61
*/
59
62
bool moveVertex ( const QgsPoint &p, QgsFeatureId atFeatureId, int atVertex ) SIP_PYNAME( moveVertexV2 );
60
63
61
- /* * Deletes a vertex from a feature.
64
+ /* *
65
+ * Deletes a vertex from a feature.
62
66
* \param featureId ID of feature to remove vertex from
63
67
* \param vertex index of vertex to delete
64
68
* \since QGIS 2.14
65
69
*/
66
70
QgsVectorLayer::EditResult deleteVertex ( QgsFeatureId featureId, int vertex );
67
71
68
- /* * Adds a ring to polygon/multipolygon features
72
+ /* *
73
+ * Adds a ring to polygon/multipolygon features
69
74
* \param ring ring to add
70
75
* \param targetFeatureIds if specified, only these features will be the candidates for adding a ring. Otherwise
71
76
* all intersecting features are tested and the ring is added to the first valid feature.
72
77
* \param modifiedFeatureId if specified, feature ID for feature that ring was added to will be stored in this parameter
73
- * \returns
74
- * 0 in case of success,
75
- * 1 problem with feature type,
76
- * 2 ring not closed,
77
- * 3 ring not valid,
78
- * 4 ring crosses existing rings,
79
- * 5 no feature found where ring can be inserted
80
- */
81
- // TODO QGIS 3.0 returns an enum instead of a magic constant
82
- int addRing ( const QList<QgsPointXY> &ring, const QgsFeatureIds &targetFeatureIds = QgsFeatureIds(), QgsFeatureId *modifiedFeatureId = nullptr );
83
-
84
- /* * Adds a ring to polygon/multipolygon features
78
+ * \return OperationResult result code: success or reason of failure
79
+ */
80
+ QgsGeometry::OperationResult addRing ( const QList<QgsPointXY> &ring, const QgsFeatureIds &targetFeatureIds = QgsFeatureIds(), QgsFeatureId *modifiedFeatureId = nullptr );
81
+
82
+ /* *
83
+ * Adds a ring to polygon/multipolygon features
85
84
* \param ring ring to add
86
85
* \param targetFeatureIds if specified, only these features will be the candidates for adding a ring. Otherwise
87
86
* all intersecting features are tested and the ring is added to the first valid feature.
88
87
* \param modifiedFeatureId if specified, feature ID for feature that ring was added to will be stored in this parameter
89
- * \returns
90
- * 0 in case of success,
91
- * 1 problem with feature type,
92
- * 2 ring not closed,
93
- * 3 ring not valid,
94
- * 4 ring crosses existing rings,
95
- * 5 no feature found where ring can be inserted
96
- * \note available in Python bindings as addCurvedRing
97
- */
98
- // TODO QGIS 3.0 returns an enum instead of a magic constant
99
- int addRing ( QgsCurve *ring, const QgsFeatureIds &targetFeatureIds = QgsFeatureIds(), QgsFeatureId *modifiedFeatureId = nullptr ) SIP_PYNAME( addCurvedRing );
100
-
101
- /* * Adds a new part polygon to a multipart feature
102
- * \returns
103
- * 0 in case of success,
104
- * 1 if selected feature is not multipart,
105
- * 2 if ring is not a valid geometry,
106
- * 3 if new polygon ring not disjoint with existing rings,
107
- * 4 if no feature was selected,
108
- * 5 if several features are selected,
109
- * 6 if selected geometry not found
110
- */
111
- // TODO QGIS 3.0 returns an enum instead of a magic constant
112
- int addPart ( const QList<QgsPointXY> &ring, QgsFeatureId featureId );
113
-
114
- /* * Adds a new part polygon to a multipart feature
115
- * \returns
116
- * 0 in case of success,
117
- * 1 if selected feature is not multipart,
118
- * 2 if ring is not a valid geometry,
119
- * 3 if new polygon ring not disjoint with existing rings,
120
- * 4 if no feature was selected,
121
- * 5 if several features are selected,
122
- * 6 if selected geometry not found
123
- * \note available in Python bindings as addPartV2
124
- */
125
- // TODO QGIS 3.0 returns an enum instead of a magic constant
126
- int addPart ( const QgsPointSequence &ring, QgsFeatureId featureId );
127
-
128
- // ! \note available in Python bindings as addCurvedPart
129
- // TODO QGIS 3.0 returns an enum instead of a magic constant
130
- int addPart ( QgsCurve *ring, QgsFeatureId featureId ) SIP_PYNAME( addCurvedPart );
131
-
132
- /* * Translates feature by dx, dy
88
+ * \return OperationResult result code: success or reason of failure
89
+ * \note available in python bindings as addCurvedRing
90
+ */
91
+ QgsGeometry::OperationResult addRing ( QgsCurve *ring, const QgsFeatureIds &targetFeatureIds = QgsFeatureIds(), QgsFeatureId *modifiedFeatureId = nullptr ) SIP_PYNAME( addCurvedRing );
92
+
93
+ /* *
94
+ * Adds a new part polygon to a multipart feature
95
+ * \return
96
+ * - QgsGeometry::Success
97
+ * - QgsGeometry::AddPartSelectedGeometryNotFound
98
+ * - QgsGeometry::AddPartNotMultiGeometry
99
+ * - QgsGeometry::InvalidBaseGeometry
100
+ * - QgsGeometry::InvalidInput
101
+ */
102
+ QgsGeometry::OperationResult addPart ( const QList<QgsPointXY> &ring, QgsFeatureId featureId );
103
+
104
+ /* *
105
+ * Adds a new part polygon to a multipart feature
106
+ *
107
+ * \return
108
+ * - QgsGeometry::Success
109
+ * - QgsGeometry::AddPartSelectedGeometryNotFound
110
+ * - QgsGeometry::AddPartNotMultiGeometry
111
+ * - QgsGeometry::InvalidBaseGeometry
112
+ * - QgsGeometry::InvalidInput
113
+ * \note available in python bindings as addPartV2
114
+ */
115
+ QgsGeometry::OperationResult addPart ( const QgsPointSequence &ring, QgsFeatureId featureId );
116
+
117
+ /* *
118
+ * Adds a new part polygon to a multipart feature
119
+ *
120
+ * \return
121
+ * - QgsGeometry::Success
122
+ * - QgsGeometry::AddPartSelectedGeometryNotFound
123
+ * - QgsGeometry::AddPartNotMultiGeometry
124
+ * - QgsGeometry::InvalidBaseGeometry
125
+ * - QgsGeometry::InvalidInput
126
+ *
127
+ * \note available in python bindings as addCurvedPart
128
+ */
129
+ QgsGeometry::OperationResult addPart ( QgsCurve *ring, QgsFeatureId featureId ) SIP_PYNAME( addCurvedPart );
130
+
131
+ /* *
132
+ * Translates feature by dx, dy
133
133
* \param featureId id of the feature to translate
134
134
* \param dx translation of x-coordinate
135
135
* \param dy translation of y-coordinate
136
- * \returns 0 in case of success
136
+ * \return 0 in case of success
137
137
*/
138
138
int translateFeature ( QgsFeatureId featureId, double dx, double dy );
139
139
140
- /* * Splits parts cut by the given line
141
- * \param splitLine line that splits the layer feature parts
142
- * \param topologicalEditing true if topological editing is enabled
143
- * \returns
144
- * 0 in case of success,
145
- * 4 if there is a selection but no feature split
140
+ /* *
141
+ * Splits parts cut by the given line
142
+ * \param splitLine line that splits the layer feature parts
143
+ * \param topologicalEditing true if topological editing is enabled
144
+ * \return
145
+ * - QgsGeometry::InvalidBaseGeometry
146
+ * - QgsGeometry::Success
147
+ * - QgsGeometry::InvalidInput
148
+ * - QgsGeometry::NothingHappened if a selection is present but no feature has been split
149
+ * - QgsGeometry::InvalidBaseGeometry
150
+ * - QgsGeometry::GeometryEngineError
151
+ * - QgsGeometry::SplitCannotSplitPoint
146
152
*/
147
- // TODO QGIS 3.0 returns an enum instead of a magic constant
148
- int splitParts ( const QList<QgsPointXY> &splitLine, bool topologicalEditing = false );
153
+ QgsGeometry::OperationResult splitParts ( const QList<QgsPointXY> &splitLine, bool topologicalEditing = false );
149
154
150
- /* * Splits features cut by the given line
151
- * \param splitLine line that splits the layer features
152
- * \param topologicalEditing true if topological editing is enabled
153
- * \returns
154
- * 0 in case of success,
155
- * 4 if there is a selection but no feature split
155
+ /* *
156
+ * Splits features cut by the given line
157
+ * \param splitLine line that splits the layer features
158
+ * \param topologicalEditing true if topological editing is enabled
159
+ * \return
160
+ * 0 in case of success,
161
+ * 4 if there is a selection but no feature split
156
162
*/
157
- // TODO QGIS 3.0 returns an enum instead of a magic constant
158
- int splitFeatures ( const QList<QgsPointXY> &splitLine, bool topologicalEditing = false );
163
+ QgsGeometry::OperationResult splitFeatures ( const QList<QgsPointXY> &splitLine, bool topologicalEditing = false );
159
164
160
- /* * Adds topological points for every vertex of the geometry.
165
+ /* *
166
+ * Adds topological points for every vertex of the geometry.
161
167
* \param geom the geometry where each vertex is added to segments of other features
162
168
* \note geom is not going to be modified by the function
163
169
* \returns 0 in case of success
164
170
*/
165
171
int addTopologicalPoints ( const QgsGeometry &geom );
166
172
167
- /* * Adds a vertex to segments which intersect point p but don't
173
+ /* *
174
+ * Adds a vertex to segments which intersect point p but don't
168
175
* already have a vertex there. If a feature already has a vertex at position p,
169
176
* no additional vertex is inserted. This method is useful for topological
170
177
* editing.
@@ -173,15 +180,15 @@ class CORE_EXPORT QgsVectorLayerEditUtils
173
180
*/
174
181
int addTopologicalPoints ( const QgsPointXY &p );
175
182
176
- protected:
177
-
178
- /* * Little helper function that gives bounding box from a list of points.
179
- \returns 0 in case of success */
180
- int boundingBoxFromPointList ( const QList<QgsPointXY> &list, double &xmin, double &ymin, double &xmax, double &ymax ) const ;
181
-
182
183
private:
183
184
184
- QgsVectorLayer *L = nullptr ;
185
+ /* *
186
+ * Little helper function that gives bounding box from a list of points.
187
+ * \returns True in case of success
188
+ */
189
+ bool boundingBoxFromPointList ( const QList<QgsPointXY> &list, double &xmin, double &ymin, double &xmax, double &ymax ) const ;
190
+
191
+ QgsVectorLayer *mLayer = nullptr ;
185
192
};
186
193
187
194
#endif // QGSVECTORLAYEREDITUTILS_H
0 commit comments