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 for (
int idx = 0; idx < fieldListA.
count(); ++idx )
188 names.
append( fieldListA[idx].name() );
190 for (
int idx = 0; idx < fieldListB.
count(); ++idx )
200 fieldListA.
append( field );
207 attributesA += attributesB;
const QString & name() const
Gets the name of the field.
Wrapper for iterator of features from vector data provider or vector layer.
void setMaximum(int maximum)
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request.
QgsRectangle boundingBox() const
Returns the bounding box of this feature.
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.
WkbType
Used for symbology operations.
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...
QList< QgsFeatureId > intersects(QgsRectangle rect) const
returns features that intersect the specified rectangle
QString encoding() const
Get encoding which is used for accessing data.
void setValue(int progress)
void setGeometry(const QgsGeometry &geom)
Set this feature's geometry from another QgsGeometry object.
void append(const T &value)
const QgsFeatureIds & selectedFeaturesIds() const
Return reference to identifiers of selected features.
QgsAttributes attributes() const
Returns the feature's attributes.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
bool addFeature(QgsFeature &feature, QgsFeatureRendererV2 *renderer=0, QGis::UnitType outputUnit=QGis::Meters)
add feature to the currently opened shapefile
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
int count() const
Return number of items.
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
QgsGeometry * intersection(const QgsGeometry *geometry) const
Returns a geometry representing the points shared by this geometry and other.
virtual long featureCount() const
Number of features in the layer.
bool insertFeature(const QgsFeature &f)
add feature to index
Class for storing a coordinate reference system (CRS)
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.
const QgsFields & pendingFields() const
returns field list in the to-be-committed state
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.
bool intersects(const QgsRectangle &r) const
Test for intersection with a rectangle (uses GEOS)
Represents a vector layer which manages a vector based data sets.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
bool intersection(QgsVectorLayer *layerA, QgsVectorLayer *layerB, const QString &shapefileName, bool onlySelectedFeatures=false, QProgressDialog *p=0)
Perform an intersection on two input vector layers and write output to a new shape file...
QVariant::Type type() const
Gets variant type of the field as it will be retrieved from data source.