QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QgsVectorLayerEditUtils Class Reference

#include <qgsvectorlayereditutils.h>

Public Member Functions

 QgsVectorLayerEditUtils (QgsVectorLayer *layer)
 
int addPart (const QList< QgsPoint > &ring, QgsFeatureId featureId)
 Adds a new part polygon to a multipart feature. More...
 
int addPart (const QgsPointSequenceV2 &ring, QgsFeatureId featureId)
 Adds a new part polygon to a multipart feature. More...
 
int addPart (QgsCurveV2 *ring, QgsFeatureId featureId)
 
int addRing (const QList< QgsPoint > &ring, const QgsFeatureIds &targetFeatureIds=QgsFeatureIds(), QgsFeatureId *modifiedFeatureId=nullptr)
 Adds a ring to polygon/multipolygon features. More...
 
int addRing (QgsCurveV2 *ring, const QgsFeatureIds &targetFeatureIds=QgsFeatureIds(), QgsFeatureId *modifiedFeatureId=nullptr)
 Adds a ring to polygon/multipolygon features. More...
 
int addTopologicalPoints (const QgsGeometry *geom)
 Adds topological points for every vertex of the geometry. More...
 
int addTopologicalPoints (const QgsPoint &p)
 Adds a vertex to segments which intersect point p but don't already have a vertex there. More...
 
QgsGeometryCachecache ()
 
Q_DECL_DEPRECATED bool deleteVertex (QgsFeatureId atFeatureId, int atVertex)
 Deletes a vertex from a feature. More...
 
QgsVectorLayer::EditResult deleteVertexV2 (QgsFeatureId featureId, int vertex)
 Deletes a vertex from a feature. More...
 
int insertSegmentVerticesForSnap (const QList< QgsSnappingResult > &snapResults)
 Inserts vertices to the snapped segments. More...
 
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. More...
 
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. More...
 
bool moveVertex (const QgsPointV2 &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. More...
 
int splitFeatures (const QList< QgsPoint > &splitLine, bool topologicalEditing=false)
 Splits features cut by the given line. More...
 
int splitParts (const QList< QgsPoint > &splitLine, bool topologicalEditing=false)
 Splits parts cut by the given line. More...
 
int translateFeature (QgsFeatureId featureId, double dx, double dy)
 Translates feature by dx, dy. More...
 

Protected Member Functions

int boundingBoxFromPointList (const QList< QgsPoint > &list, double &xmin, double &ymin, double &xmax, double &ymax) const
 Little helper function that gives bounding box from a list of points. More...
 

Protected Attributes

QgsVectorLayerL
 

Detailed Description

Definition at line 29 of file qgsvectorlayereditutils.h.

Constructor & Destructor Documentation

◆ QgsVectorLayerEditUtils()

QgsVectorLayerEditUtils::QgsVectorLayerEditUtils ( QgsVectorLayer layer)

Definition at line 30 of file qgsvectorlayereditutils.cpp.

Member Function Documentation

◆ addPart() [1/3]

int QgsVectorLayerEditUtils::addPart ( const QList< QgsPoint > &  ring,
QgsFeatureId  featureId 
)

Adds a new part polygon to a multipart feature.

Returns
0 in case of success, 1 if selected feature is not multipart, 2 if ring is not a valid geometry, 3 if new polygon ring not disjoint with existing rings, 4 if no feature was selected, 5 if several features are selected, 6 if selected geometry not found

Definition at line 186 of file qgsvectorlayereditutils.cpp.

◆ addPart() [2/3]

int QgsVectorLayerEditUtils::addPart ( const QgsPointSequenceV2 ring,
QgsFeatureId  featureId 
)

Adds a new part polygon to a multipart feature.

Returns
0 in case of success, 1 if selected feature is not multipart, 2 if ring is not a valid geometry, 3 if new polygon ring not disjoint with existing rings, 4 if no feature was selected, 5 if several features are selected, 6 if selected geometry not found
Note
available in python bindings as addPartV2

Definition at line 196 of file qgsvectorlayereditutils.cpp.

◆ addPart() [3/3]

int QgsVectorLayerEditUtils::addPart ( QgsCurveV2 ring,
QgsFeatureId  featureId 
)

Definition at line 236 of file qgsvectorlayereditutils.cpp.

◆ addRing() [1/2]

int QgsVectorLayerEditUtils::addRing ( const QList< QgsPoint > &  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
0 in case of success, 1 problem with feature type, 2 ring not closed, 3 ring not valid, 4 ring crosses existing rings, 5 no feature found where ring can be inserted

Definition at line 122 of file qgsvectorlayereditutils.cpp.

◆ addRing() [2/2]

int QgsVectorLayerEditUtils::addRing ( QgsCurveV2 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
0 in case of success, 1 problem with feature type, 2 ring not closed, 3 ring not valid, 4 ring crosses existing rings, 5 no feature found where ring can be inserted
Note
available in python bindings as addCurvedRing

Definition at line 135 of file qgsvectorlayereditutils.cpp.

◆ addTopologicalPoints() [1/2]

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
Note
geom is not going to be modified by the function
Returns
0 in case of success

Definition at line 578 of file qgsvectorlayereditutils.cpp.

◆ addTopologicalPoints() [2/2]

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.

Parameters
pposition of the vertex
Returns
0 in case of success

Definition at line 686 of file qgsvectorlayereditutils.cpp.

◆ boundingBoxFromPointList()

int QgsVectorLayerEditUtils::boundingBoxFromPointList ( const QList< QgsPoint > &  list,
double &  xmin,
double &  ymin,
double &  xmax,
double &  ymax 
) const
protected

Little helper function that gives bounding box from a list of points.

Returns
0 in case of success

Definition at line 770 of file qgsvectorlayereditutils.cpp.

◆ cache()

QgsGeometryCache* QgsVectorLayerEditUtils::cache ( )
inline

Definition at line 34 of file qgsvectorlayereditutils.h.

◆ deleteVertex()

bool QgsVectorLayerEditUtils::deleteVertex ( QgsFeatureId  atFeatureId,
int  atVertex 
)

Deletes a vertex from a feature.

Deprecated:
use deleteVertexV2() instead

Definition at line 85 of file qgsvectorlayereditutils.cpp.

◆ deleteVertexV2()

QgsVectorLayer::EditResult QgsVectorLayerEditUtils::deleteVertexV2 ( QgsFeatureId  featureId,
int  vertex 
)

Deletes a vertex from a feature.

Parameters
featureIdID of feature to remove vertex from
vertexindex of vertex to delete
Note
added in QGIS 2.14

Definition at line 91 of file qgsvectorlayereditutils.cpp.

◆ insertSegmentVerticesForSnap()

int QgsVectorLayerEditUtils::insertSegmentVerticesForSnap ( const QList< QgsSnappingResult > &  snapResults)

Inserts vertices to the snapped segments.

This is useful for topological editing if snap to segment is enabled.

Parameters
snapResultsresults collected from the snapping operation
Returns
0 in case of success

Definition at line 744 of file qgsvectorlayereditutils.cpp.

◆ insertVertex()

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 35 of file qgsvectorlayereditutils.cpp.

◆ moveVertex() [1/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 57 of file qgsvectorlayereditutils.cpp.

◆ moveVertex() [2/2]

bool QgsVectorLayerEditUtils::moveVertex ( const QgsPointV2 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 63 of file qgsvectorlayereditutils.cpp.

◆ splitFeatures()

int QgsVectorLayerEditUtils::splitFeatures ( const QList< QgsPoint > &  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
0 in case of success, 4 if there is a selection but no feature split

Definition at line 303 of file qgsvectorlayereditutils.cpp.

◆ splitParts()

int QgsVectorLayerEditUtils::splitParts ( const QList< QgsPoint > &  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
0 in case of success, 4 if there is a selection but no feature split

Definition at line 441 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 277 of file qgsvectorlayereditutils.cpp.

Member Data Documentation

◆ L

QgsVectorLayer* QgsVectorLayerEditUtils::L
protected

Definition at line 190 of file qgsvectorlayereditutils.h.


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