127 for ( ; ringIt != ring.
constEnd(); ++ringIt )
132 return addRing( ringLine, targetFeatureIds, modifiedFeatureId );
143 int addRingReturnCode = 5;
147 if ( !targetFeatureIds.
isEmpty() )
167 if ( addRingReturnCode == 0 )
171 addRingReturnCode = 5;
174 if ( modifiedFeatureId )
175 *modifiedFeatureId = f.
id();
183 return addRingReturnCode;
193 return addPart( l, featureId );
202 bool firstPart =
false;
222 if ( errorCode == 0 )
242 bool firstPart =
false;
262 if ( errorCode == 0 )
293 int errorCode = geometry.
translate( dx, dy );
294 if ( errorCode == 0 )
309 double xMin, yMin, xMax, yMax;
312 int splitFunctionReturn;
313 int numberOfSplittedFeatures = 0;
344 else if ( bBox.
height() == 0.0 && bBox.
width() > 0 )
352 double bufferDistance = 0.000001;
354 bufferDistance = 0.00000001;
375 splitFunctionReturn = feat.
geometry()->
splitGeometry( splitLine, newGeometries, topologicalEditing, topologyTestPoints );
376 if ( splitFunctionReturn == 0 )
383 for (
int i = 0; i < newGeometries.
size(); ++i )
385 newGeometry = newGeometries.
at( i );
395 if ( !defaultValue.
isNull() )
397 newAttributes[ pkIdx ] = defaultValue;
401 newAttributes[ pkIdx ] =
QVariant();
407 newFeatures.
append( newFeature );
410 if ( topologicalEditing )
413 for ( ; topol_it != topologyTestPoints.
constEnd(); ++topol_it )
418 ++numberOfSplittedFeatures;
420 else if ( splitFunctionReturn > 1 )
422 returnCode = splitFunctionReturn;
426 if ( numberOfSplittedFeatures == 0 && !selectedIds.
isEmpty() )
446 double xMin, yMin, xMax, yMax;
449 int splitFunctionReturn;
450 int numberOfSplittedParts = 0;
480 else if ( bBox.
height() == 0.0 && bBox.
width() > 0 )
488 double bufferDistance = 0.000001;
490 bufferDistance = 0.00000001;
508 splitFunctionReturn = feat.
geometry()->
splitGeometry( splitLine, newGeometries, topologicalEditing, topologyTestPoints );
509 if ( splitFunctionReturn == 0 )
512 if ( !newGeometries.
isEmpty() )
515 for (
int i = 0; i < newGeometries.
size(); ++i )
528 switch ( addPartRet )
545 splitFunctionReturn = 2;
549 if ( topologicalEditing )
552 for ( ; topol_it != topologyTestPoints.
constEnd(); ++topol_it )
557 ++numberOfSplittedParts;
559 else if ( splitFunctionReturn > 1 )
561 returnCode = splitFunctionReturn;
564 qDeleteAll( newGeometries );
600 for ( ; line_it != theLine.
constEnd(); ++line_it )
617 for (
int i = 0; i < theMultiLine.
size(); ++i )
620 for ( ; line_it != currentPolyline.
constEnd(); ++line_it )
638 for (
int i = 0; i < thePolygon.
size(); ++i )
640 currentRing = thePolygon.
at( i );
642 for ( ; line_it != currentRing.
constEnd(); ++line_it )
661 for (
int i = 0; i < theMultiPolygon.
size(); ++i )
663 currentPolygon = theMultiPolygon.
at( i );
664 for (
int j = 0; j < currentPolygon.
size(); ++j )
666 currentRing = currentPolygon.
at( j );
668 for ( ; line_it != currentRing.
constEnd(); ++line_it )
698 double threshold = 0.0000001;
716 for ( ; snap_it != snapResults.
constEnd(); ++snap_it )
719 bool vertexAlreadyExists =
false;
725 vertex_snap_it = vertexSnapResults.
constBegin();
726 for ( ; vertex_snap_it != vertexSnapResults.
constEnd(); ++vertex_snap_it )
728 if ( snap_it.
value().snappedAtGeometry == vertex_snap_it.
value().snappedAtGeometry )
730 vertexAlreadyExists =
true;
734 if ( !vertexAlreadyExists )
736 filteredSnapResults.
push_back( *snap_it );
753 for ( ; it != snapResults.
constEnd(); ++it )
755 if ( it->snappedVertexNr == -1 )
757 layerPoint = it->snappedVertex;
758 if ( !
insertVertex( layerPoint.
x(), layerPoint.
y(), it->snappedAtGeometry, it->afterVertexNr ) )
772 if ( list.
size() < 1 )
784 if ( it->x() < xmin )
788 if ( it->x() > xmax )
792 if ( it->y() < ymin )
796 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.
virtual QVariant defaultValue(int fieldId, bool forceLazyEval=false)
Returns the default value for field specified by fieldId.
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.
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)