105 int addRingReturnCode = 5;
106 double xMin, yMin, xMax, yMax;
125 if ( addRingReturnCode == 0 )
134 return addRingReturnCode;
155 if ( errorCode == 0 )
180 int errorCode = geometry.
translate( dx, dy );
181 if ( errorCode == 0 )
195 double xMin, yMin, xMax, yMax;
198 int splitFunctionReturn;
199 int numberOfSplittedFeatures = 0;
204 if ( selectedIds.
size() > 0 )
228 else if ( bBox.
height() == 0.0 && bBox.
width() > 0 )
236 double bufferDistance = 0.000001;
238 bufferDistance = 0.00000001;
259 splitFunctionReturn = feat.
geometry()->
splitGeometry( splitLine, newGeometries, topologicalEditing, topologyTestPoints );
260 if ( splitFunctionReturn == 0 )
266 for (
int i = 0; i < newGeometries.
size(); ++i )
268 newGeometry = newGeometries.
at( i );
278 if ( !defaultValue.
isNull() )
280 newAttributes[ pkIdx ] = defaultValue;
284 newAttributes[ pkIdx ] =
QVariant();
290 newFeatures.
append( newFeature );
293 if ( topologicalEditing )
296 for ( ; topol_it != topologyTestPoints.
constEnd(); ++topol_it )
301 ++numberOfSplittedFeatures;
303 else if ( splitFunctionReturn > 1 )
305 returnCode = splitFunctionReturn;
309 if ( numberOfSplittedFeatures == 0 && selectedIds.
size() > 0 )
328 double xMin, yMin, xMax, yMax;
331 int splitFunctionReturn;
332 int numberOfSplittedParts = 0;
360 else if ( bBox.
height() == 0.0 && bBox.
width() > 0 )
368 double bufferDistance = 0.000001;
370 bufferDistance = 0.00000001;
388 splitFunctionReturn = feat.
geometry()->
splitGeometry( splitLine, newGeometries, topologicalEditing, topologyTestPoints );
389 if ( splitFunctionReturn == 0 )
392 for (
int i = 0; i < newGeometries.
size(); ++i )
409 switch ( addPartRet )
426 if ( topologicalEditing )
429 for ( ; topol_it != topologyTestPoints.
constEnd(); ++topol_it )
434 ++numberOfSplittedParts;
436 else if ( splitFunctionReturn > 1 )
438 returnCode = splitFunctionReturn;
441 qDeleteAll( newGeometries );
477 for ( ; line_it != theLine.
constEnd(); ++line_it )
494 for (
int i = 0; i < theMultiLine.
size(); ++i )
497 for ( ; line_it != currentPolyline.
constEnd(); ++line_it )
515 for (
int i = 0; i < thePolygon.
size(); ++i )
517 currentRing = thePolygon.
at( i );
519 for ( ; line_it != currentRing.
constEnd(); ++line_it )
538 for (
int i = 0; i < theMultiPolygon.
size(); ++i )
540 currentPolygon = theMultiPolygon.
at( i );
541 for (
int j = 0; j < currentPolygon.
size(); ++j )
543 currentRing = currentPolygon.
at( j );
545 for ( ; line_it != currentRing.
constEnd(); ++line_it )
575 double threshold = 0.0000001;
593 for ( ; snap_it != snapResults.
constEnd(); ++snap_it )
596 bool vertexAlreadyExists =
false;
602 vertex_snap_it = vertexSnapResults.
constBegin();
603 for ( ; vertex_snap_it != vertexSnapResults.
constEnd(); ++vertex_snap_it )
605 if ( snap_it.
value().snappedAtGeometry == vertex_snap_it.
value().snappedAtGeometry )
607 vertexAlreadyExists =
true;
611 if ( !vertexAlreadyExists )
613 filteredSnapResults.
push_back( *snap_it );
630 for ( ; it != snapResults.
constEnd(); ++it )
632 if ( it->snappedVertexNr == -1 )
634 layerPoint = it->snappedVertex;
635 if ( !
insertVertex( layerPoint.
x(), layerPoint.
y(), it->snappedAtGeometry, it->afterVertexNr ) )
649 if ( list.
size() < 1 )
661 if ( it->x() < xmin )
665 if ( it->x() > xmax )
669 if ( it->y() < ymin )
673 if ( it->y() > ymax )
QgsFeatureId id() const
Get the feature ID for this feature.
Wrapper for iterator of features from vector data provider or vector layer.
A rectangle specified with double values.
bool isEmpty() const
test if rectangle is empty.
int insertSegmentVerticesForSnap(const QList< QgsSnappingResult > &snapResults)
Inserts vertices to the snapped segments.
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)
double yMaximum() const
Get the y maximum value (top side of rectangle)
QgsMultiPolyline asMultiPolyline() const
Return contents of the geometry as a multi linestring if wkbType is WKBMultiLineString, otherwise an empty list.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request.
QgsPolygon asPolygon() const
Return contents of the geometry as a polygon if wkbType is WKBPolygon, otherwise an empty list...
const_iterator constEnd() const
const_iterator constBegin() const
const T & at(int i) const
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 island polygon to a multipolygon feature.
A geometry is the spatial representation of a feature.
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
WkbType
Used for symbology operations.
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.
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...
bool deleteVertex(QgsFeatureId atFeatureId, int atVertex)
Deletes a vertex from a feature.
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.
QgsMultiPolygon asMultiPolygon() const
Return contents of the geometry as a multi polygon if wkbType is WKBMultiPolygon, otherwise an empty ...
int splitGeometry(const QList< QgsPoint > &splitLine, QList< QgsGeometry * > &newGeometries, bool topological, QList< QgsPoint > &topologyTestPoints)
Splits this geometry according to a given line.
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)
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
double xMaximum() const
Get the x maximum value (right side of rectangle)
const QgsFeatureIds & selectedFeaturesIds() const
Return reference to identifiers of selected features.
QgsAttributes attributes() const
Returns the feature's attributes.
int addTopologicalPoints(const QgsGeometry *geom)
Adds topological points for every vertex of the geometry.
int snapWithContext(const QgsPoint &startPoint, double snappingTolerance, QMultiMap< double, QgsSnappingResult > &snappingResults, QgsSnapper::SnappingType snap_to)
Snaps to segment or vertex within given tolerance.
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
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
QGis::WkbType wkbType() const
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
QGis::GeometryType geometryType() const
Returns point, line or polygon.
A class to represent a point.
int translate(double dx, double dy)
Translate this geometry by dx, dy.
QgsGeometryCache * cache()
QgsGeometry * geometry()
Get the geometry object associated with this feature.
QgsFeatureIterator selectedFeaturesIterator(QgsFeatureRequest request=QgsFeatureRequest())
Get an iterator of the selected features.
QgsPolyline asPolyline() const
Return contents of the geometry as a polyline if wkbType is WKBLineString, otherwise an empty list...
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
bool hasGeometryType() const
Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeome...
const_iterator constBegin() const
int addRing(const QList< QgsPoint > &ring)
Adds a ring to polygon/multipolygon features.
virtual QVariant defaultValue(int fieldId)
Returns the default value for field specified by fieldId.
void setYMaximum(double y)
Set the maximum y value.
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
const QgsCoordinateReferenceSystem & crs() const
Returns layer's spatial reference system.
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
double width() const
Width of the rectangle.
Represents a vector layer which manages a vector based data sets.
bool geographicFlag() const
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.
double xMinimum() const
Get the x minimum value (left side of rectangle)
virtual bool changeGeometry(QgsFeatureId fid, QgsGeometry *geom)
change feature's geometry
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.
double height() const
Height of the rectangle.
QgsVectorLayerEditUtils(QgsVectorLayer *layer)
QGis::UnitType mapUnits() const