115 for ( ; ringIt != ring.
constEnd(); ++ringIt )
120 return addRing( ringLine, targetFeatureIds, modifiedFeatureId );
131 int addRingReturnCode = 5;
135 if ( !targetFeatureIds.
isEmpty() )
155 if ( addRingReturnCode == 0 )
158 if ( modifiedFeatureId )
159 *modifiedFeatureId = f.
id();
167 return addRingReturnCode;
176 bool firstPart =
false;
196 if ( errorCode == 0 )
215 bool firstPart =
false;
235 if ( errorCode == 0 )
265 int errorCode = geometry.
translate( dx, dy );
266 if ( errorCode == 0 )
280 double xMin, yMin, xMax, yMax;
283 int splitFunctionReturn;
284 int numberOfSplittedFeatures = 0;
289 if ( selectedIds.
size() > 0 )
313 else if ( bBox.
height() == 0.0 && bBox.
width() > 0 )
321 double bufferDistance = 0.000001;
323 bufferDistance = 0.00000001;
344 splitFunctionReturn = feat.
geometry()->
splitGeometry( splitLine, newGeometries, topologicalEditing, topologyTestPoints );
345 if ( splitFunctionReturn == 0 )
351 for (
int i = 0; i < newGeometries.
size(); ++i )
353 newGeometry = newGeometries.
at( i );
363 if ( !defaultValue.
isNull() )
365 newAttributes[ pkIdx ] = defaultValue;
369 newAttributes[ pkIdx ] =
QVariant();
375 newFeatures.
append( newFeature );
378 if ( topologicalEditing )
381 for ( ; topol_it != topologyTestPoints.
constEnd(); ++topol_it )
386 ++numberOfSplittedFeatures;
388 else if ( splitFunctionReturn > 1 )
390 returnCode = splitFunctionReturn;
394 if ( numberOfSplittedFeatures == 0 && selectedIds.
size() > 0 )
413 double xMin, yMin, xMax, yMax;
416 int splitFunctionReturn;
417 int numberOfSplittedParts = 0;
445 else if ( bBox.
height() == 0.0 && bBox.
width() > 0 )
453 double bufferDistance = 0.000001;
455 bufferDistance = 0.00000001;
473 splitFunctionReturn = feat.
geometry()->
splitGeometry( splitLine, newGeometries, topologicalEditing, topologyTestPoints );
474 if ( splitFunctionReturn == 0 )
477 if ( !newGeometries.
isEmpty() )
480 for (
int i = 0; i < newGeometries.
size(); ++i )
497 switch ( addPartRet )
514 if ( topologicalEditing )
517 for ( ; topol_it != topologyTestPoints.
constEnd(); ++topol_it )
522 ++numberOfSplittedParts;
524 else if ( splitFunctionReturn > 1 )
526 returnCode = splitFunctionReturn;
529 qDeleteAll( newGeometries );
565 for ( ; line_it != theLine.
constEnd(); ++line_it )
582 for (
int i = 0; i < theMultiLine.
size(); ++i )
585 for ( ; line_it != currentPolyline.
constEnd(); ++line_it )
603 for (
int i = 0; i < thePolygon.
size(); ++i )
605 currentRing = thePolygon.
at( i );
607 for ( ; line_it != currentRing.
constEnd(); ++line_it )
626 for (
int i = 0; i < theMultiPolygon.
size(); ++i )
628 currentPolygon = theMultiPolygon.
at( i );
629 for (
int j = 0; j < currentPolygon.
size(); ++j )
631 currentRing = currentPolygon.
at( j );
633 for ( ; line_it != currentRing.
constEnd(); ++line_it )
663 double threshold = 0.0000001;
681 for ( ; snap_it != snapResults.
constEnd(); ++snap_it )
684 bool vertexAlreadyExists =
false;
690 vertex_snap_it = vertexSnapResults.
constBegin();
691 for ( ; vertex_snap_it != vertexSnapResults.
constEnd(); ++vertex_snap_it )
693 if ( snap_it.
value().snappedAtGeometry == vertex_snap_it.
value().snappedAtGeometry )
695 vertexAlreadyExists =
true;
699 if ( !vertexAlreadyExists )
701 filteredSnapResults.
push_back( *snap_it );
718 for ( ; it != snapResults.
constEnd(); ++it )
720 if ( it->snappedVertexNr == -1 )
722 layerPoint = it->snappedVertex;
723 if ( !
insertVertex( layerPoint.
x(), layerPoint.
y(), it->snappedAtGeometry, it->afterVertexNr ) )
737 if ( list.
size() < 1 )
749 if ( it->x() < xmin )
753 if ( it->x() > xmax )
757 if ( it->y() < ymin )
761 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 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.
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.
double x() const
Get the x value of the point.
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 ...
QGis::WkbType wkbType() const
Returns the WKBType or WKBUnknown in case of error.
int addRing(const QList< QgsPoint > &ring, const QgsFeatureIds &targetFeatureIds=QgsFeatureIds(), QgsFeatureId *modifiedFeatureId=0)
Adds a ring to polygon/multipolygon features.
double ANALYSIS_EXPORT max(double x, double y)
Returns the maximum of two doubles or the first argument if both are equal.
static QgsWKBTypes::Type fromOldWkbType(QGis::WkbType type)
Converts from old (pre 2.10) WKB type to new WKB type.
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)
bool convertToSingleType()
Converts multi type geometry into single type geometry e.g.
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.
Line string geometry type.
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
bool convertToMultiType()
Converts single type geometry into multitype geometry e.g.
virtual QVariant defaultValue(int fieldId)
Returns the default value for field specified by fieldId.
void setPoints(const QList< QgsPointV2 > &points)
static bool isSingleType(Type type)
virtual bool doesStrictFeatureTypeCheck() const
Returns true if the provider is strict about the type of inserted features (e.g.
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.
double y() const
Get the y value of the point.
const QgsCoordinateReferenceSystem & crs() const
Returns layer's spatial reference system.
bool isEmpty() const
Returns true if the geometry is empty (ie, contains no underlying geometry accessible via geometry)...
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
QgsRectangle boundingBox() const
Returns the minimal bounding box for the geometry.
virtual QgsAbstractGeometryV2 * clone() const =0
Clones the geometry by performing a deep copy.
Abstract base class for curved geometry type.
double width() const
Width of the rectangle.
Represents a vector layer which manages a vector based data sets.
bool geographicFlag() const
Get this Geographic? flag.
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
Get the units that the projection is in.