28 #include <QProgressDialog> 31 const QString& shapefileName,
bool onlySelectedFeatures,
34 if ( !layerA || !layerB )
50 combineFieldLists( fieldsA, fieldsB );
57 if ( onlySelectedFeatures )
61 for ( ; it != selectionB.
constEnd(); ++it )
76 int processedFeatures = 0;
78 for ( ; it != selectionA.
constEnd(); ++it )
93 intersectFeature( currentFeature, &vWriter, layerB, &index );
116 int processedFeatures = 0;
131 intersectFeature( currentFeature, &vWriter, layerB, &index );
158 for ( ; it != intersects.
constEnd(); ++it )
172 combineAttributeMaps( attributesA, attributesB );
184 void QgsOverlayAnalyzer::combineFieldLists(
QgsFields& fieldListA,
const QgsFields& fieldListB )
187 Q_FOREACH (
const QgsField& field, fieldListA )
190 for (
int idx = 0; idx < fieldListB.
count(); ++idx )
200 fieldListA.
append( field );
207 attributesA += attributesB;
QString encoding() const
Get encoding which is used for accessing data.
Wrapper for iterator of features from vector data provider or vector layer.
QgsAttributes attributes() const
Returns the feature's attributes.
bool intersects(const QgsRectangle &r) const
Test for intersection with a rectangle (uses GEOS)
void setMaximum(int maximum)
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request.
QList< QgsFeatureId > intersects(const QgsRectangle &rect) const
Returns features that intersect the specified rectangle.
const QgsCoordinateReferenceSystem & crs() const
Returns layer's spatial reference system.
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
bool addFeature(QgsFeature &feature, QgsFeatureRendererV2 *renderer=nullptr, QGis::UnitType outputUnit=QGis::Meters)
Add feature to the currently opened data source.
WkbType
Used for symbology operations.
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
A convenience class for writing vector files to disk.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
int count() const
Return number of items.
QgsFields fields() const
Returns the list of fields of this layer.
long featureCount(QgsSymbolV2 *symbol)
Number of features rendered with specified symbol.
bool intersection(QgsVectorLayer *layerA, QgsVectorLayer *layerB, const QString &shapefileName, bool onlySelectedFeatures=false, QProgressDialog *p=nullptr)
Perform an intersection on two input vector layers and write output to a new shape file...
void setValue(int progress)
void setGeometry(const QgsGeometry &geom)
Set this feature's geometry from another QgsGeometry object.
void append(const T &value)
This class wraps a request for features to a vector layer (or directly its vector data provider)...
bool append(const QgsField &field, FieldOrigin origin=OriginProvider, int originIndex=-1)
Append a field. The field must have unique name, otherwise it is rejected (returns false) ...
const_iterator constEnd() const
Encapsulate a field in an attribute table or data source.
virtual QGis::WkbType geometryType() const =0
Get feature type.
bool contains(const T &value) const
const_iterator constBegin() const
const QgsFeatureIds & selectedFeaturesIds() const
Return reference to identifiers of selected features.
bool insertFeature(const QgsFeature &f)
Add feature to index.
QgsRectangle boundingBox() const
Returns the bounding box of this feature.
Class for storing a coordinate reference system (CRS)
QgsGeometry * intersection(const QgsGeometry *geometry) const
Returns a geometry representing the points shared by this geometry and other.
QgsVectorDataProvider * dataProvider()
Returns the data provider.
const_iterator constEnd() const
bool nextFeature(QgsFeature &f)
const_iterator constBegin() const
This is the base class for vector data providers.
Represents a vector layer which manages a vector based data sets.
QVariant::Type type() const
Gets variant type of the field as it will be retrieved from data source.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const