28 #include <QProgressDialog>
31 const QString& shapefileName,
bool onlySelectedFeatures,
34 if ( !layerA || !layerB )
50 combineFieldLists( fieldsA, fieldsB );
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() )
93 intersectFeature( currentFeature, &vWriter, layerB, &index );
99 p->setValue( selectionA.size() );
114 p->setMaximum( featureCount );
116 int processedFeatures = 0;
125 p->setValue( processedFeatures );
127 if ( p && p->wasCanceled() )
131 intersectFeature( currentFeature, &vWriter, layerB, &index );
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 )
172 combineAttributeMaps( attributesA, attributesB );
184 void QgsOverlayAnalyzer::combineFieldLists(
QgsFields& fieldListA,
const QgsFields& fieldListB )
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;