QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
QgsVectorLayerEditUtils Class Reference

#include <qgsvectorlayereditutils.h>

Public Member Functions

 QgsVectorLayerEditUtils (QgsVectorLayer *layer)
 
Qgis::GeometryOperationResult addPart (const QgsPointSequence &ring, QgsFeatureId featureId)
 Adds a new part polygon to a multipart feature.
 
Q_DECL_DEPRECATED Qgis::GeometryOperationResult addPart (const QVector< QgsPointXY > &ring, QgsFeatureId featureId)
 Adds a new part polygon to a multipart feature.
 
Qgis::GeometryOperationResult addPart (QgsCurve *ring, QgsFeatureId featureId)
 Adds a new part polygon to a multipart feature.
 
Qgis::GeometryOperationResult addRing (const QgsPointSequence &ring, const QgsFeatureIds &targetFeatureIds=QgsFeatureIds(), QgsFeatureId *modifiedFeatureId=nullptr)
 Adds a ring to polygon/multipolygon features.
 
Q_DECL_DEPRECATED Qgis::GeometryOperationResult addRing (const QVector< QgsPointXY > &ring, const QgsFeatureIds &targetFeatureIds=QgsFeatureIds(), QgsFeatureId *modifiedFeatureId=nullptr)
 Adds a ring to polygon/multipolygon features.
 
Qgis::GeometryOperationResult addRing (QgsCurve *ring, const QgsFeatureIds &targetFeatureIds=QgsFeatureIds(), QgsFeatureId *modifiedFeatureId=nullptr)
 Adds a ring to polygon/multipolygon features.
 
Qgis::GeometryOperationResult addRingV2 (QgsCurve *ring, const QgsFeatureIds &targetFeatureIds=QgsFeatureIds(), QgsFeatureIds *modifiedFeatureIds=nullptr)
 Adds a ring to polygon/multipolygon features.
 
int addTopologicalPoints (const QgsGeometry &geom)
 Adds topological points for every vertex of the geometry.
 
int addTopologicalPoints (const QgsPoint &p)
 Adds a vertex to segments which intersect point p but don't already have a vertex there.
 
int addTopologicalPoints (const QgsPointSequence &ps)
 Adds a vertex to segments which intersect point p but don't already have a vertex there.
 
int addTopologicalPoints (const QgsPointXY &p)
 Adds a vertex to segments which intersect point p but don't already have a vertex there.
 
Qgis::VectorEditResult deleteVertex (QgsFeatureId featureId, int vertex)
 Deletes a vertex from a feature.
 
bool insertVertex (const QgsPoint &point, QgsFeatureId atFeatureId, int beforeVertex)
 Inserts a new vertex before the given vertex number, in the given ring, item (first number is index 0), and feature Not meaningful for Point geometries.
 
bool insertVertex (double x, double y, QgsFeatureId atFeatureId, int beforeVertex)
 Insert a new vertex before the given vertex number, in the given ring, item (first number is index 0), and feature Not meaningful for Point geometries.
 
bool mergeFeatures (const QgsFeatureId &targetFeatureId, const QgsFeatureIds &mergeFeatureIds, const QgsAttributes &mergeAttributes, const QgsGeometry &unionGeometry, QString &errorMessage)
 Merge features into a single one.
 
bool moveVertex (const QgsPoint &p, QgsFeatureId atFeatureId, int atVertex)
 Moves the vertex at the given position number, ring and item (first number is index 0), and feature to the given coordinates.
 
bool moveVertex (double x, double y, QgsFeatureId atFeatureId, int atVertex)
 Moves the vertex at the given position number, ring and item (first number is index 0), and feature to the given coordinates.
 
Qgis::GeometryOperationResult splitFeatures (const QgsCurve *curve, QgsPointSequence &topologyTestPoints, bool preserveCircular=false, bool topologicalEditing=false)
 Splits features cut by the given curve.
 
Qgis::GeometryOperationResult splitFeatures (const QgsPointSequence &splitLine, bool topologicalEditing=false)
 Splits features cut by the given line.
 
Q_DECL_DEPRECATED Qgis::GeometryOperationResult splitFeatures (const QVector< QgsPointXY > &splitLine, bool topologicalEditing=false)
 Splits features cut by the given line.
 
Qgis::GeometryOperationResult splitParts (const QgsPointSequence &splitLine, bool topologicalEditing=false)
 Splits parts cut by the given line.
 
Q_DECL_DEPRECATED Qgis::GeometryOperationResult splitParts (const QVector< QgsPointXY > &splitLine, bool topologicalEditing=false)
 Splits parts cut by the given line.
 
int translateFeature (QgsFeatureId featureId, double dx, double dy)
 Translates feature by dx, dy.
 

Detailed Description

Definition at line 31 of file qgsvectorlayereditutils.h.

Constructor & Destructor Documentation

◆ QgsVectorLayerEditUtils()

QgsVectorLayerEditUtils::QgsVectorLayerEditUtils ( QgsVectorLayer layer)

Definition at line 36 of file qgsvectorlayereditutils.cpp.

Member Function Documentation

◆ addPart() [1/3]

Qgis::GeometryOperationResult QgsVectorLayerEditUtils::addPart ( const QgsPointSequence ring,
QgsFeatureId  featureId 
)

Adds a new part polygon to a multipart feature.

Returns
- QgsGeometry::Success
  • QgsGeometry::AddPartSelectedGeometryNotFound
  • QgsGeometry::AddPartNotMultiGeometry
  • QgsGeometry::InvalidBaseGeometry
  • QgsGeometry::InvalidInput
Note
available in python bindings as addPartV2

Definition at line 260 of file qgsvectorlayereditutils.cpp.

◆ addPart() [2/3]

Qgis::GeometryOperationResult QgsVectorLayerEditUtils::addPart ( const QVector< QgsPointXY > &  ring,
QgsFeatureId  featureId 
)

Adds a new part polygon to a multipart feature.

Returns
- QgsGeometry::Success
  • QgsGeometry::AddPartSelectedGeometryNotFound
  • QgsGeometry::AddPartNotMultiGeometry
  • QgsGeometry::InvalidBaseGeometry
  • QgsGeometry::InvalidInput

    Deprecated:
    since QGIS 3.12 - will be removed in QGIS 4.0. Use the variant which accepts QgsPoint objects instead of QgsPointXY.

Definition at line 250 of file qgsvectorlayereditutils.cpp.

◆ addPart() [3/3]

Qgis::GeometryOperationResult QgsVectorLayerEditUtils::addPart ( QgsCurve ring,
QgsFeatureId  featureId 
)

Adds a new part polygon to a multipart feature.

Returns
- QgsGeometry::Success
  • QgsGeometry::AddPartSelectedGeometryNotFound
  • QgsGeometry::AddPartNotMultiGeometry
  • QgsGeometry::InvalidBaseGeometry
  • QgsGeometry::InvalidInput
Note
available in python bindings as addCurvedPart

Definition at line 295 of file qgsvectorlayereditutils.cpp.

◆ addRing() [1/3]

Qgis::GeometryOperationResult QgsVectorLayerEditUtils::addRing ( const QgsPointSequence ring,
const QgsFeatureIds targetFeatureIds = QgsFeatureIds(),
QgsFeatureId modifiedFeatureId = nullptr 
)

Adds a ring to polygon/multipolygon features.

Parameters
ringring to add
targetFeatureIdsif specified, only these features will be the candidates for adding a ring. Otherwise all intersecting features are tested and the ring is added to the first valid feature.
modifiedFeatureIdif specified, feature ID for feature that ring was added to will be stored in this parameter
Returns
OperationResult result code: success or reason of failure

Definition at line 222 of file qgsvectorlayereditutils.cpp.

◆ addRing() [2/3]

Qgis::GeometryOperationResult QgsVectorLayerEditUtils::addRing ( const QVector< QgsPointXY > &  ring,
const QgsFeatureIds targetFeatureIds = QgsFeatureIds(),
QgsFeatureId modifiedFeatureId = nullptr 
)

Adds a ring to polygon/multipolygon features.

Parameters
ringring to add
targetFeatureIdsif specified, only these features will be the candidates for adding a ring. Otherwise all intersecting features are tested and the ring is added to the first valid feature.
modifiedFeatureIdif specified, feature ID for feature that ring was added to will be stored in this parameter
Returns
OperationResult result code: success or reason of failure
Deprecated:
since QGIS 3.12 - will be removed in QGIS 4.0. Use the variant which accepts QgsPoint objects instead of QgsPointXY.

Definition at line 212 of file qgsvectorlayereditutils.cpp.

◆ addRing() [3/3]

Qgis::GeometryOperationResult QgsVectorLayerEditUtils::addRing ( QgsCurve ring,
const QgsFeatureIds targetFeatureIds = QgsFeatureIds(),
QgsFeatureId modifiedFeatureId = nullptr 
)

Adds a ring to polygon/multipolygon features.

Parameters
ringring to add
targetFeatureIdsif specified, only these features will be the candidates for adding a ring. Otherwise all intersecting features are tested and the ring is added to the first valid feature.
modifiedFeatureIdif specified, feature ID for feature that ring was added to will be stored in this parameter
Returns
OperationResult result code: success or reason of failure
Note
available in python bindings as addCurvedRing

Definition at line 228 of file qgsvectorlayereditutils.cpp.

◆ addRingV2()

Qgis::GeometryOperationResult QgsVectorLayerEditUtils::addRingV2 ( QgsCurve ring,
const QgsFeatureIds targetFeatureIds = QgsFeatureIds(),
QgsFeatureIds modifiedFeatureIds = nullptr 
)

Adds a ring to polygon/multipolygon features.

Parameters
ringring to add (ownership is transferred)
targetFeatureIdsif specified, only these features will be the candidates for adding a ring. Otherwise all intersecting features are tested and the ring is added to all valid features.
modifiedFeatureIdsif specified, feature IDS for features that ring was added to will be stored in this parameter
Returns
OperationResult result code: success or reason of failure
Since
QGIS 3.28

Definition at line 241 of file qgsvectorlayereditutils.cpp.

◆ addTopologicalPoints() [1/4]

int QgsVectorLayerEditUtils::addTopologicalPoints ( const QgsGeometry geom)

Adds topological points for every vertex of the geometry.

Parameters
geomthe geometry where each vertex is added to segments of other features
Returns
0 in case of success
1 in case of error
2 in case no vertices needed to be added
Note
geom is not going to be modified by the function

Definition at line 753 of file qgsvectorlayereditutils.cpp.

◆ addTopologicalPoints() [2/4]

int QgsVectorLayerEditUtils::addTopologicalPoints ( const QgsPoint p)

Adds a vertex to segments which intersect point p but don't already have a vertex there.

If a feature already has a vertex at position p, no additional vertex is inserted. This method is useful for topological editing.

Returns
0 in case of success
1 in case of error
2 in case no vertices needed to be added
Since
QGIS 3.10

Definition at line 778 of file qgsvectorlayereditutils.cpp.

◆ addTopologicalPoints() [3/4]

int QgsVectorLayerEditUtils::addTopologicalPoints ( const QgsPointSequence ps)

Adds a vertex to segments which intersect point p but don't already have a vertex there.

If a feature already has a vertex at position p, no additional vertex is inserted. This method is useful for topological editing.

Returns
0 in case of success
1 in case of error
2 in case vertex already exists or point does not intersect segment
Since
QGIS 3.16

Definition at line 857 of file qgsvectorlayereditutils.cpp.

◆ addTopologicalPoints() [4/4]

int QgsVectorLayerEditUtils::addTopologicalPoints ( const QgsPointXY p)

Adds a vertex to segments which intersect point p but don't already have a vertex there.

If a feature already has a vertex at position p, no additional vertex is inserted. This method is useful for topological editing.

Returns
0 in case of success
1 in case of error
2 in case no vertices needed to be added

Definition at line 882 of file qgsvectorlayereditutils.cpp.

◆ deleteVertex()

Qgis::VectorEditResult QgsVectorLayerEditUtils::deleteVertex ( QgsFeatureId  featureId,
int  vertex 
)

Deletes a vertex from a feature.

Parameters
featureIdID of feature to remove vertex from
vertexindex of vertex to delete

Definition at line 112 of file qgsvectorlayereditutils.cpp.

◆ insertVertex() [1/2]

bool QgsVectorLayerEditUtils::insertVertex ( const QgsPoint point,
QgsFeatureId  atFeatureId,
int  beforeVertex 
)

Inserts a new vertex before the given vertex number, in the given ring, item (first number is index 0), and feature Not meaningful for Point geometries.

Definition at line 58 of file qgsvectorlayereditutils.cpp.

◆ insertVertex() [2/2]

bool QgsVectorLayerEditUtils::insertVertex ( double  x,
double  y,
QgsFeatureId  atFeatureId,
int  beforeVertex 
)

Insert a new vertex before the given vertex number, in the given ring, item (first number is index 0), and feature Not meaningful for Point geometries.

Definition at line 41 of file qgsvectorlayereditutils.cpp.

◆ mergeFeatures()

bool QgsVectorLayerEditUtils::mergeFeatures ( const QgsFeatureId targetFeatureId,
const QgsFeatureIds mergeFeatureIds,
const QgsAttributes mergeAttributes,
const QgsGeometry unionGeometry,
QString &  errorMessage 
)

Merge features into a single one.

Parameters
targetFeatureIdid of the target feature (will be updated)
mergeFeatureIdsid list of features to merge (will be deleted)
mergeAttributesare the resulting attributes in the merged feature
unionGeometryis the resulting geometry of the merged feature
errorMessagewill be set to a descriptive error message if any occurs
Returns
true if the merge was successful, or false if the operation failed.
Since
QGIS 3.30

Definition at line 887 of file qgsvectorlayereditutils.cpp.

◆ moveVertex() [1/2]

bool QgsVectorLayerEditUtils::moveVertex ( const QgsPoint p,
QgsFeatureId  atFeatureId,
int  atVertex 
)

Moves the vertex at the given position number, ring and item (first number is index 0), and feature to the given coordinates.

Note
available in Python bindings as moveVertexV2

Definition at line 81 of file qgsvectorlayereditutils.cpp.

◆ moveVertex() [2/2]

bool QgsVectorLayerEditUtils::moveVertex ( double  x,
double  y,
QgsFeatureId  atFeatureId,
int  atVertex 
)

Moves the vertex at the given position number, ring and item (first number is index 0), and feature to the given coordinates.

Definition at line 75 of file qgsvectorlayereditutils.cpp.

◆ splitFeatures() [1/3]

Qgis::GeometryOperationResult QgsVectorLayerEditUtils::splitFeatures ( const QgsCurve curve,
QgsPointSequence topologyTestPoints,
bool  preserveCircular = false,
bool  topologicalEditing = false 
)

Splits features cut by the given curve.

Parameters
curveline that splits the layer features
[out]topologyTestPointstopological points to be tested against other layers
preserveCircularwhether circular strings are preserved after splitting
topologicalEditingtrue if topological editing is enabled
Returns
QgsGeometry::OperationResult
Since
QGIS 3.16

Definition at line 374 of file qgsvectorlayereditutils.cpp.

◆ splitFeatures() [2/3]

Qgis::GeometryOperationResult QgsVectorLayerEditUtils::splitFeatures ( const QgsPointSequence splitLine,
bool  topologicalEditing = false 
)

Splits features cut by the given line.

Parameters
splitLineline that splits the layer features
topologicalEditingtrue if topological editing is enabled
Returns
QgsGeometry::OperationResult

Definition at line 366 of file qgsvectorlayereditutils.cpp.

◆ splitFeatures() [3/3]

Qgis::GeometryOperationResult QgsVectorLayerEditUtils::splitFeatures ( const QVector< QgsPointXY > &  splitLine,
bool  topologicalEditing = false 
)

Splits features cut by the given line.

Parameters
splitLineline that splits the layer features
topologicalEditingtrue if topological editing is enabled
Returns
QgsGeometry::OperationResult
Deprecated:
since QGIS 3.12 - will be removed in QGIS 4.0. Use the variant which accepts QgsPoint objects instead of QgsPointXY.

Definition at line 355 of file qgsvectorlayereditutils.cpp.

◆ splitParts() [1/2]

Qgis::GeometryOperationResult QgsVectorLayerEditUtils::splitParts ( const QgsPointSequence splitLine,
bool  topologicalEditing = false 
)

Splits parts cut by the given line.

Parameters
splitLineline that splits the layer feature parts
topologicalEditingtrue if topological editing is enabled
Returns
- QgsGeometry::InvalidBaseGeometry
  • QgsGeometry::Success
  • QgsGeometry::InvalidInput
  • QgsGeometry::NothingHappened if a selection is present but no feature has been split
  • QgsGeometry::InvalidBaseGeometry
  • QgsGeometry::GeometryEngineError
  • QgsGeometry::SplitCannotSplitPoint

Definition at line 631 of file qgsvectorlayereditutils.cpp.

◆ splitParts() [2/2]

Qgis::GeometryOperationResult QgsVectorLayerEditUtils::splitParts ( const QVector< QgsPointXY > &  splitLine,
bool  topologicalEditing = false 
)

Splits parts cut by the given line.

Parameters
splitLineline that splits the layer feature parts
topologicalEditingtrue if topological editing is enabled
Returns
- QgsGeometry::InvalidBaseGeometry
  • QgsGeometry::Success
  • QgsGeometry::InvalidInput
  • QgsGeometry::NothingHappened if a selection is present but no feature has been split
  • QgsGeometry::InvalidBaseGeometry
  • QgsGeometry::GeometryEngineError
  • QgsGeometry::SplitCannotSplitPoint

    Deprecated:
    since QGIS 3.12 - will be removed in QGIS 4.0. Use the variant which accepts QgsPoint objects instead of QgsPointXY.

Definition at line 621 of file qgsvectorlayereditutils.cpp.

◆ translateFeature()

int QgsVectorLayerEditUtils::translateFeature ( QgsFeatureId  featureId,
double  dx,
double  dy 
)

Translates feature by dx, dy.

Parameters
featureIdid of the feature to translate
dxtranslation of x-coordinate
dytranslation of y-coordinate
Returns
0 in case of success

Definition at line 336 of file qgsvectorlayereditutils.cpp.


The documentation for this class was generated from the following files: