28 #include <QProgressDialog>
31 const QString& shapefileName,
bool onlySelectedFeatures,
34 if ( !layerA && !layerB )
57 if ( onlySelectedFeatures )
60 QgsFeatureIds::const_iterator it = selectionB.constBegin();
61 for ( ; it != selectionB.constEnd(); ++it )
73 p->setMaximum( selectionA.size() );
76 int processedFeatures = 0;
77 it = selectionA.constBegin();
78 for ( ; it != selectionA.constEnd(); ++it )
82 p->setValue( processedFeatures );
85 if ( p && p->wasCanceled() )
99 p->setValue( selectionA.size() );
114 p->setMaximum( featureCount );
116 int processedFeatures = 0;
125 p->setValue( processedFeatures );
127 if ( p && p->wasCanceled() )
136 p->setValue( featureCount );
149 if ( !featureGeometry )
154 QList<QgsFeatureId> intersects;
156 QList<QgsFeatureId>::const_iterator it = intersects.constBegin();
158 for ( ; it != intersects.constEnd(); ++it )
186 QList<QString> names;
187 for (
int idx = 0; idx < fieldListA.
count(); ++idx )
188 names.append( fieldListA[idx].name() );
190 for (
int idx = 0; idx < fieldListB.
count(); ++idx )
194 while ( names.contains( field.
name() ) )
196 QString name = QString(
"%1_%2" ).arg( field.
name() ).arg( count );
200 fieldListA.
append( field );
201 names.append( field.
name() );
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.
QSet< QgsFeatureId > QgsFeatureIds
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request.
QgsGeometry * geometry() const
Get the geometry object associated with this feature.
Container of fields for a vector layer.
void setAttributes(const QgsAttributes &attrs)
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
void combineAttributeMaps(QgsAttributes &attributesA, const QgsAttributes &attributesB)
QString encoding() const
Get encoding which is used for accessing data.
void setGeometry(const QgsGeometry &geom)
Set this feature's geometry from another QgsGeometry object (deep copy)
void combineFieldLists(QgsFields &fieldListA, const QgsFields &fieldListB)
const QgsFeatureIds & selectedFeaturesIds() const
Return reference to identifiers of selected features.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
const QgsAttributes & attributes() const
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) ...
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.
QgsGeometry * intersection(QgsGeometry *geometry)
Returns a geometry representing the points shared by this geometry and other.
QgsRectangle boundingBox()
Returns the bounding box of this feature.
virtual long featureCount() const
Number of features in the layer.
bool insertFeature(const QgsFeature &f)
add feature to index
QVector< QVariant > QgsAttributes
Class for storing a coordinate reference system (CRS)
const QgsCoordinateReferenceSystem & crs() const
Returns layer's spatial reference system.
void intersectFeature(QgsFeature &f, QgsVectorFileWriter *vfw, QgsVectorLayer *dp, QgsSpatialIndex *index)
const QgsFields & pendingFields() const
returns field list in the to-be-committed state
QgsVectorDataProvider * dataProvider()
Returns the data provider.
bool nextFeature(QgsFeature &f)
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.
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.