105 int addRingReturnCode = 5;
106 double xMin, yMin, xMax, yMax;
125 if ( addRingReturnCode == 0 )
135 return addRingReturnCode;
156 if ( errorCode == 0 )
181 int errorCode = geometry.
translate( dx, dy );
182 if ( errorCode == 0 )
196 double xMin, yMin, xMax, yMax;
199 int splitFunctionReturn;
200 int numberOfSplittedFeatures = 0;
205 if ( selectedIds.size() > 0 )
229 else if ( bBox.
height() == 0.0 && bBox.
width() > 0 )
237 double bufferDistance = 0.000001;
239 bufferDistance = 0.00000001;
257 QList<QgsGeometry*> newGeometries;
258 QList<QgsPoint> topologyTestPoints;
260 splitFunctionReturn = feat.
geometry()->
splitGeometry( splitLine, newGeometries, topologicalEditing, topologyTestPoints );
261 if ( splitFunctionReturn == 0 )
267 for (
int i = 0; i < newGeometries.size(); ++i )
269 newGeometry = newGeometries.at( i );
279 if ( !defaultValue.isNull() )
281 newAttributes[ pkIdx ] = defaultValue;
285 newAttributes[ pkIdx ] = QVariant();
291 newFeatures.append( newFeature );
294 if ( topologicalEditing )
296 QList<QgsPoint>::const_iterator topol_it = topologyTestPoints.constBegin();
297 for ( ; topol_it != topologyTestPoints.constEnd(); ++topol_it )
302 ++numberOfSplittedFeatures;
304 else if ( splitFunctionReturn > 1 )
306 returnCode = splitFunctionReturn;
310 if ( numberOfSplittedFeatures == 0 && selectedIds.size() > 0 )
329 double xMin, yMin, xMax, yMax;
332 int splitFunctionReturn;
333 int numberOfSplittedParts = 0;
361 else if ( bBox.
height() == 0.0 && bBox.
width() > 0 )
369 double bufferDistance = 0.000001;
371 bufferDistance = 0.00000001;
387 QList<QgsGeometry*> newGeometries;
388 QList<QgsPoint> topologyTestPoints;
389 splitFunctionReturn = feat.
geometry()->
splitGeometry( splitLine, newGeometries, topologicalEditing, topologyTestPoints );
390 if ( splitFunctionReturn == 0 )
393 for (
int i = 0; i < newGeometries.size(); ++i )
410 switch ( addPartRet )
427 if ( topologicalEditing )
429 QList<QgsPoint>::const_iterator topol_it = topologyTestPoints.constBegin();
430 for ( ; topol_it != topologyTestPoints.constEnd(); ++topol_it )
435 ++numberOfSplittedParts;
437 else if ( splitFunctionReturn > 1 )
439 returnCode = splitFunctionReturn;
442 qDeleteAll( newGeometries );
477 QgsPolyline::const_iterator line_it = theLine.constBegin();
478 for ( ; line_it != theLine.constEnd(); ++line_it )
495 for (
int i = 0; i < theMultiLine.size(); ++i )
497 QgsPolyline::const_iterator line_it = currentPolyline.constBegin();
498 for ( ; line_it != currentPolyline.constEnd(); ++line_it )
516 for (
int i = 0; i < thePolygon.size(); ++i )
518 currentRing = thePolygon.at( i );
519 QgsPolyline::const_iterator line_it = currentRing.constBegin();
520 for ( ; line_it != currentRing.constEnd(); ++line_it )
539 for (
int i = 0; i < theMultiPolygon.size(); ++i )
541 currentPolygon = theMultiPolygon.at( i );
542 for (
int j = 0; j < currentPolygon.size(); ++j )
544 currentRing = currentPolygon.at( j );
545 QgsPolyline::const_iterator line_it = currentRing.constBegin();
546 for ( ; line_it != currentRing.constEnd(); ++line_it )
569 QMultiMap<double, QgsSnappingResult> snapResults;
571 QMultiMap<double, QgsSnappingResult> vertexSnapResults;
573 QList<QgsSnappingResult> filteredSnapResults;
576 double threshold = 0.0000001;
592 QMultiMap<double, QgsSnappingResult>::const_iterator snap_it = snapResults.constBegin();
593 QMultiMap<double, QgsSnappingResult>::const_iterator vertex_snap_it;
594 for ( ; snap_it != snapResults.constEnd(); ++snap_it )
597 bool vertexAlreadyExists =
false;
603 vertex_snap_it = vertexSnapResults.constBegin();
604 for ( ; vertex_snap_it != vertexSnapResults.constEnd(); ++vertex_snap_it )
606 if ( snap_it.value().snappedAtGeometry == vertex_snap_it.value().snappedAtGeometry )
608 vertexAlreadyExists =
true;
612 if ( !vertexAlreadyExists )
614 filteredSnapResults.push_back( *snap_it );
630 QList<QgsSnappingResult>::const_iterator it = snapResults.constBegin();
631 for ( ; it != snapResults.constEnd(); ++it )
633 if ( it->snappedVertexNr == -1 )
635 layerPoint = it->snappedVertex;
636 if ( !
insertVertex( layerPoint.
x(), layerPoint.
y(), it->snappedAtGeometry, it->afterVertexNr ) )
650 if ( list.size() < 1 )
660 for ( QList<QgsPoint>::const_iterator it = list.constBegin(); it != list.constEnd(); ++it )
662 if ( it->x() < xmin )
666 if ( it->x() > xmax )
670 if ( it->y() < ymin )
674 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.
double yMaximum() const
Get the y maximum value (top side of rectangle)
QSet< QgsFeatureId > QgsFeatureIds
QList< QgsFeature > QgsFeatureList
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.
QVector< QgsPoint > QgsPolyline
polyline is represented as a vector of points
QgsGeometry * geometry() const
Get the geometry object associated with this feature.
QgsPolygon asPolygon() const
return contents of the geometry as a polygon if wkbType is WKBPolygon, otherwise an empty list ...
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.
void setAttributes(const QgsAttributes &attrs)
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 (deep copy)
QgsVectorLayerEditBuffer * editBuffer()
Buffer with uncommitted editing operations. Only valid after editing has been turned on...
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.
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
int addTopologicalPoints(QgsGeometry *geom)
Adds topological points for every vertex of the geometry.
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...
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)...
QVector< QgsPolygon > QgsMultiPolygon
a collection of QgsPolygons that share a common collection of attributes
QList< int > QgsAttributeList
const QgsAttributes & attributes() const
QGis::WkbType wkbType() const
Returns type of wkb (point / linestring / polygon etc.)
QGis::GeometryType geometryType() const
Returns point, line or polygon.
QVector< QgsPolyline > QgsPolygon
polygon: first item of the list is outer ring, inner rings (if any) start from second item ...
A class to represent a point.
int translate(double dx, double dy)
Translate this geometry by dx, dy.
QgsGeometryCache * cache()
QVector< QgsPolyline > QgsMultiPolyline
a collection of QgsPolylines that share a common collection of attributes
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)...
int addRing(const QList< QgsPoint > &ring, QgsFeatureId *featureId=0)
Adds a ring to polygon/multipolygon features.
bool hasGeometryType() const
Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeome...
virtual QVariant defaultValue(int fieldId)
Returns the default value for field specified by fieldId.
void setYMaximum(double y)
Set the maximum y value.
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.
bool nextFeature(QgsFeature &f)
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