127 for ( ; ringIt != ring.
constEnd(); ++ringIt )
132 return addRing( ringLine, targetFeatureIds, modifiedFeatureId );
143 int addRingReturnCode = 5;
147 if ( !targetFeatureIds.
isEmpty() )
167 if ( addRingReturnCode == 0 )
170 if ( modifiedFeatureId )
171 *modifiedFeatureId = f.
id();
179 return addRingReturnCode;
189 return addPart( l, featureId );
198 bool firstPart =
false;
218 if ( errorCode == 0 )
237 bool firstPart =
false;
257 if ( errorCode == 0 )
287 int errorCode = geometry.
translate( dx, dy );
288 if ( errorCode == 0 )
302 double xMin, yMin, xMax, yMax;
305 int splitFunctionReturn;
306 int numberOfSplittedFeatures = 0;
337 else if ( bBox.
height() == 0.0 && bBox.
width() > 0 )
345 double bufferDistance = 0.000001;
347 bufferDistance = 0.00000001;
368 splitFunctionReturn = feat.
geometry()->
splitGeometry( splitLine, newGeometries, topologicalEditing, topologyTestPoints );
369 if ( splitFunctionReturn == 0 )
375 for (
int i = 0; i < newGeometries.
size(); ++i )
377 newGeometry = newGeometries.
at( i );
387 if ( !defaultValue.
isNull() )
389 newAttributes[ pkIdx ] = defaultValue;
393 newAttributes[ pkIdx ] =
QVariant();
399 newFeatures.
append( newFeature );
402 if ( topologicalEditing )
405 for ( ; topol_it != topologyTestPoints.
constEnd(); ++topol_it )
410 ++numberOfSplittedFeatures;
412 else if ( splitFunctionReturn > 1 )
414 returnCode = splitFunctionReturn;
418 if ( numberOfSplittedFeatures == 0 && !selectedIds.
isEmpty() )
437 double xMin, yMin, xMax, yMax;
440 int splitFunctionReturn;
441 int numberOfSplittedParts = 0;
471 else if ( bBox.
height() == 0.0 && bBox.
width() > 0 )
479 double bufferDistance = 0.000001;
481 bufferDistance = 0.00000001;
499 splitFunctionReturn = feat.
geometry()->
splitGeometry( splitLine, newGeometries, topologicalEditing, topologyTestPoints );
500 if ( splitFunctionReturn == 0 )
503 if ( !newGeometries.
isEmpty() )
506 for (
int i = 0; i < newGeometries.
size(); ++i )
523 switch ( addPartRet )
540 if ( topologicalEditing )
543 for ( ; topol_it != topologyTestPoints.
constEnd(); ++topol_it )
548 ++numberOfSplittedParts;
550 else if ( splitFunctionReturn > 1 )
552 returnCode = splitFunctionReturn;
555 qDeleteAll( newGeometries );
591 for ( ; line_it != theLine.
constEnd(); ++line_it )
608 for (
int i = 0; i < theMultiLine.
size(); ++i )
611 for ( ; line_it != currentPolyline.
constEnd(); ++line_it )
629 for (
int i = 0; i < thePolygon.
size(); ++i )
631 currentRing = thePolygon.
at( i );
633 for ( ; line_it != currentRing.
constEnd(); ++line_it )
652 for (
int i = 0; i < theMultiPolygon.
size(); ++i )
654 currentPolygon = theMultiPolygon.
at( i );
655 for (
int j = 0; j < currentPolygon.
size(); ++j )
657 currentRing = currentPolygon.
at( j );
659 for ( ; line_it != currentRing.
constEnd(); ++line_it )
689 double threshold = 0.0000001;
707 for ( ; snap_it != snapResults.
constEnd(); ++snap_it )
710 bool vertexAlreadyExists =
false;
716 vertex_snap_it = vertexSnapResults.
constBegin();
717 for ( ; vertex_snap_it != vertexSnapResults.
constEnd(); ++vertex_snap_it )
719 if ( snap_it.
value().snappedAtGeometry == vertex_snap_it.
value().snappedAtGeometry )
721 vertexAlreadyExists =
true;
725 if ( !vertexAlreadyExists )
727 filteredSnapResults.
push_back( *snap_it );
744 for ( ; it != snapResults.
constEnd(); ++it )
746 if ( it->snappedVertexNr == -1 )
748 layerPoint = it->snappedVertex;
749 if ( !
insertVertex( layerPoint.
x(), layerPoint.
y(), it->snappedAtGeometry, it->afterVertexNr ) )
763 if ( list.
size() < 1 )
775 if ( it->x() < xmin )
779 if ( it->x() > xmax )
783 if ( it->y() < ymin )
787 if ( it->y() > ymax )
QgsPolygon asPolygon() const
Return contents of the geometry as a polygon if wkbType is WKBPolygon, otherwise an empty list...
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.
Wrapper for iterator of features from vector data provider or vector layer.
QgsMultiPolyline asMultiPolyline() const
Return contents of the geometry as a multi linestring if wkbType is WKBMultiLineString, otherwise an empty list.
A rectangle specified with double values.
QGis::WkbType wkbType() const
Returns the WKBType or WKBUnknown in case of error.
static bool isSingleType(Type type)
Returns true if the WKB type is a single type.
int insertSegmentVerticesForSnap(const QList< QgsSnappingResult > &snapResults)
Inserts vertices to the snapped segments.
QgsAttributes attributes() const
Returns the feature's attributes.
QGis::WkbType wkbType() const
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
void setXMaximum(double x)
Set the maximum x value.
virtual bool addFeatures(QgsFeatureList &features)
Insert a copy of the given features into the layer (but does not commit it)
Use exact geometry intersection (slower) instead of bounding boxes.
void push_back(const T &value)
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request.
const_iterator constEnd() const
const_iterator constBegin() const
const T & at(int i) const
const QgsCoordinateReferenceSystem & crs() const
Returns layer's spatial reference system.
void setGeometry(QgsAbstractGeometryV2 *geometry)
Sets the underlying geometry store.
bool moveVertex(double x, double y, int atVertex)
Moves the vertex at the given position number and item (first number is index 0) to the given coordin...
int addPart(const QList< QgsPoint > &points, QGis::GeometryType geomType=QGis::UnknownGeometry)
Adds a new part to a the geometry.
A geometry is the spatial representation of a feature.
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
WkbType
Used for symbology operations.
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
Edit operation resulted in an empty geometry.
int addPart(const QList< QgsPoint > &ring, QgsFeatureId featureId)
Adds a new part polygon to a multipart feature.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
virtual QgsAttributeList pkAttributeIndexes()
Return list of indexes of fields that make up the primary key.
virtual QgsCurveV2 * clone() const override=0
Clones the geometry by performing a deep copy.
bool insertVertex(double x, double y, int beforeVertex)
Insert a new vertex before the given vertex index, ring and item (first number is index 0) If the req...
Q_DECL_DEPRECATED bool deleteVertex(QgsFeatureId atFeatureId, int atVertex)
Deletes a vertex from a feature.
QgsPolyline asPolyline() const
Return contents of the geometry as a polyline if wkbType is WKBLineString, otherwise an empty list...
double y() const
Get the y value of the point.
double ANALYSIS_EXPORT max(double x, double y)
Returns the maximum of two doubles or the first argument if both are equal.
bool hasGeometryType() const
Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeome...
virtual bool doesStrictFeatureTypeCheck() const
Returns true if the provider is strict about the type of inserted features (e.g.
static QgsWKBTypes::Type fromOldWkbType(QGis::WkbType type)
Converts from old (pre 2.10) WKB type (OGR) to new WKB type.
void setGeometry(const QgsGeometry &geom)
Set this feature's geometry from another QgsGeometry object.
QgsVectorLayerEditBuffer * editBuffer()
Buffer with uncommitted editing operations. Only valid after editing has been turned on...
void append(const T &value)
bool convertToSingleType()
Converts multi type geometry into single type geometry e.g.
bool isEmpty() const
test if rectangle is empty.
Line string geometry type, with support for z-dimension and m-values.
int addTopologicalPoints(const QgsGeometry *geom)
Adds topological points for every vertex of the geometry.
void setPoints(const QgsPointSequenceV2 &points)
Resets the line string to match the specified list of points.
int snapWithContext(const QgsPoint &startPoint, double snappingTolerance, QMultiMap< double, QgsSnappingResult > &snappingResults, QgsSnapper::SnappingType snap_to)
Snaps to segment or vertex within given tolerance.
double width() const
Width of the rectangle.
Point geometry type, with support for z-dimension and m-values.
bool geometry(QgsFeatureId fid, QgsGeometry &geometry)
fetch geometry from cache, return true if successful
void setYMinimum(double y)
Set the minimum y value.
bool deleteVertex(int atVertex)
Deletes the vertex at the given position number and item (first number is index 0) Returns false if a...
const_iterator constEnd() const
QGis::UnitType mapUnits() const
Returns the units for the projection used by the CRS.
int translateFeature(QgsFeatureId featureId, double dx, double dy)
Translates feature by dx, dy.
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)...
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QList< int > QgsAttributeList
bool isEmpty() const
Returns true if the geometry is empty (ie, contains no underlying geometry accessible via geometry)...
QGis::GeometryType geometryType() const
Returns point, line or polygon.
int splitGeometry(const QList< QgsPoint > &splitLine, QList< QgsGeometry *> &newGeometries, bool topological, QList< QgsPoint > &topologyTestPoints)
Splits this geometry according to a given line.
A class to represent a point.
int translate(double dx, double dy)
Translate this geometry by dx, dy.
QgsGeometryCache * cache()
QgsFeatureId id() const
Get the feature ID for this feature.
virtual int nCoordinates() const
Returns the number of nodes contained in the geometry.
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
QgsGeometry * geometry()
Get the geometry object associated with this feature.
double xMaximum() const
Get the x maximum value (right side of rectangle)
QgsFeatureIterator selectedFeaturesIterator(QgsFeatureRequest request=QgsFeatureRequest())
Get an iterator of the selected features.
const QgsFeatureIds & selectedFeaturesIds() const
Return reference to identifiers of selected features.
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)...
const T & at(int i) const
const_iterator constBegin() const
int addRing(const QList< QgsPoint > &ring, const QgsFeatureIds &targetFeatureIds=QgsFeatureIds(), QgsFeatureId *modifiedFeatureId=nullptr)
Adds a ring to polygon/multipolygon features.
bool convertToMultiType()
Converts single type geometry into multitype geometry e.g.
QgsAbstractGeometryV2 * geometry() const
Returns the underlying geometry store.
virtual QVariant defaultValue(int fieldId)
Returns the default value for field specified by fieldId.
QgsVectorLayer::EditResult deleteVertexV2(QgsFeatureId featureId, int vertex)
Deletes a vertex from a feature.
void setYMaximum(double y)
Set the maximum y value.
QgsMultiPolygon asMultiPolygon() const
Return contents of the geometry as a multi polygon if wkbType is WKBMultiPolygon, otherwise an empty ...
Edit operation was successful.
double xMinimum() const
Get the x minimum value (left side of rectangle)
double yMaximum() const
Get the y maximum value (top side of rectangle)
Edit failed due to invalid layer.
int addRing(const QList< QgsPoint > &ring)
Adds a new ring to this geometry.
QgsVectorDataProvider * dataProvider()
Returns the data provider.
const_iterator constEnd() const
bool nextFeature(QgsFeature &f)
const_iterator constBegin() const
Abstract base class for curved geometry type.
Represents a vector layer which manages a vector based data sets.
int splitParts(const QList< QgsPoint > &splitLine, bool topologicalEditing=false)
Splits parts cut by the given line.
int selectedFeatureCount()
The number of features that are selected in this layer.
EditResult
Result of an edit operation.
virtual bool changeGeometry(QgsFeatureId fid, QgsGeometry *geom)
Change feature's geometry.
Unable to fetch requested feature.
double x() const
Get the x value of the point.
int splitFeatures(const QList< QgsPoint > &splitLine, bool topologicalEditing=false)
Splits features cut by the given line.
void setXMinimum(double x)
Set the minimum x value.
virtual QgsRectangle boundingBox() const override
Returns the minimal bounding box for the geometry.
double height() const
Height of the rectangle.
bool geographicFlag() const
Returns whether the CRS is a geographic CRS.
QgsVectorLayerEditUtils(QgsVectorLayer *layer)