83 int addRingReturnCode = 5;
84 double xMin, yMin, xMax, yMax;
103 if ( addRingReturnCode == 0 )
112 return addRingReturnCode;
132 int errorCode = geometry.
addPart( points );
133 if ( errorCode == 0 )
158 int errorCode = geometry.
translate( dx, dy );
159 if ( errorCode == 0 )
173 double xMin, yMin, xMax, yMax;
176 int splitFunctionReturn;
177 int numberOfSplittedFeatures = 0;
182 if ( selectedIds.size() > 0 )
206 else if ( bBox.
height() == 0.0 && bBox.
width() > 0 )
224 QgsFeatureList::iterator select_it = featureList.begin();
225 for ( ; select_it != featureList.end(); ++select_it )
227 if ( !select_it->geometry() )
231 QList<QgsGeometry*> newGeometries;
232 QList<QgsPoint> topologyTestPoints;
234 splitFunctionReturn = select_it->geometry()->
splitGeometry( splitLine, newGeometries, topologicalEditing, topologyTestPoints );
235 if ( splitFunctionReturn == 0 )
241 for (
int i = 0; i < newGeometries.size(); ++i )
243 newGeometry = newGeometries.at( i );
253 if ( !defaultValue.isNull() )
255 newAttributes[ pkIdx ] = defaultValue;
259 newAttributes[ pkIdx ] = QVariant();
265 newFeatures.append( newFeature );
268 if ( topologicalEditing )
270 QList<QgsPoint>::const_iterator topol_it = topologyTestPoints.constBegin();
271 for ( ; topol_it != topologyTestPoints.constEnd(); ++topol_it )
276 ++numberOfSplittedFeatures;
278 else if ( splitFunctionReturn > 1 )
280 returnCode = splitFunctionReturn;
284 if ( numberOfSplittedFeatures == 0 && selectedIds.size() > 0 )
321 QgsPolyline::const_iterator line_it = theLine.constBegin();
322 for ( ; line_it != theLine.constEnd(); ++line_it )
339 for (
int i = 0; i < theMultiLine.size(); ++i )
341 QgsPolyline::const_iterator line_it = currentPolyline.constBegin();
342 for ( ; line_it != currentPolyline.constEnd(); ++line_it )
360 for (
int i = 0; i < thePolygon.size(); ++i )
362 currentRing = thePolygon.at( i );
363 QgsPolyline::const_iterator line_it = currentRing.constBegin();
364 for ( ; line_it != currentRing.constEnd(); ++line_it )
383 for (
int i = 0; i < theMultiPolygon.size(); ++i )
385 currentPolygon = theMultiPolygon.at( i );
386 for (
int j = 0; j < currentPolygon.size(); ++j )
388 currentRing = currentPolygon.at( j );
389 QgsPolyline::const_iterator line_it = currentRing.constBegin();
390 for ( ; line_it != currentRing.constEnd(); ++line_it )
413 QMultiMap<double, QgsSnappingResult> snapResults;
415 QMultiMap<double, QgsSnappingResult> vertexSnapResults;
417 QList<QgsSnappingResult> filteredSnapResults;
420 double threshold = 0.0000001;
436 QMultiMap<double, QgsSnappingResult>::const_iterator snap_it = snapResults.constBegin();
437 QMultiMap<double, QgsSnappingResult>::const_iterator vertex_snap_it;
438 for ( ; snap_it != snapResults.constEnd(); ++snap_it )
441 bool vertexAlreadyExists =
false;
447 vertex_snap_it = vertexSnapResults.constBegin();
448 for ( ; vertex_snap_it != vertexSnapResults.constEnd(); ++vertex_snap_it )
450 if ( snap_it.value().snappedAtGeometry == vertex_snap_it.value().snappedAtGeometry )
452 vertexAlreadyExists =
true;
456 if ( !vertexAlreadyExists )
458 filteredSnapResults.push_back( *snap_it );
474 QList<QgsSnappingResult>::const_iterator it = snapResults.constBegin();
475 for ( ; it != snapResults.constEnd(); ++it )
477 if ( it->snappedVertexNr == -1 )
479 layerPoint = it->snappedVertex;
480 if ( !
insertVertex( layerPoint.
x(), layerPoint.
y(), it->snappedAtGeometry, it->afterVertexNr ) )
494 if ( list.size() < 1 )
504 for ( QList<QgsPoint>::const_iterator it = list.constBegin(); it != list.constEnd(); ++it )
506 if ( it->x() < xmin )
510 if ( it->x() > xmax )
514 if ( it->y() < ymin )
518 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.
QgsFeatureList selectedFeatures()
Get a copy of the user-selected features.
void setXMaximum(double x)
Set the maximum x value.
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)
Adds a new island polygon to a multipolygon feature.
A geometry is the spatial representation of a 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 ...
double ANALYSIS_EXPORT max(double x, double y)
returns the maximum of two doubles or the first argument if both are equal
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
QGis::WkbType wkbType() const
Returns type of wkb (point / linestring / polygon etc.)
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 geometry.
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
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)...
bool hasGeometryType() const
Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeome...
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.
QVector< QVariant > QgsAttributes
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.
double xMinimum() const
Get the x minimum value (left side of rectangle)
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