Skip to content

Commit

Permalink
[Geometry checker] Drop feature id update logic now handled by freezi…
Browse files Browse the repository at this point in the history
…ng repacking
  • Loading branch information
manisandro committed Oct 23, 2017
1 parent 767538b commit 816273e
Show file tree
Hide file tree
Showing 14 changed files with 0 additions and 132 deletions.
29 changes: 0 additions & 29 deletions src/analysis/vector/geometry_checker/qgsfeaturepool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ QgsFeaturePool::QgsFeaturePool( QgsVectorLayer *layer, double layerToMapUnits, c
mFeatureIds.remove( feature.id() );
}
}
connect( mLayer->dataProvider(), SIGNAL( featureIdsChanged( QMap<QgsFeatureId, QgsFeatureId> ) ), this, SLOT( updateFeatureIds( QMap<QgsFeatureId, QgsFeatureId> ) ) );
}

bool QgsFeaturePool::get( QgsFeatureId id, QgsFeature &feature )
Expand Down Expand Up @@ -142,31 +141,3 @@ QgsFeatureIds QgsFeaturePool::getIntersects( const QgsRectangle &rect ) const
QMutexLocker lock( &mIndexMutex );
return QgsFeatureIds::fromList( mIndex.intersects( rect ) );
}

void QgsFeaturePool::updateFeatureIds( const QMap<QgsFeatureId, QgsFeatureId> &oldNewFid )
{
QList<QgsFeature *> changedFeatures;
QgsFeatureIds newIds;
for ( const QgsFeatureId &oldId : oldNewFid.keys() )
{
auto it = mFeatureIds.find( oldId );
if ( it != mFeatureIds.end() )
{
mFeatureIds.erase( it );
}
newIds.insert( oldNewFid[oldId] );
QgsFeature *feature = mFeatureCache.take( oldId );
if ( feature )
{
feature->setId( oldNewFid[oldId] );
changedFeatures.append( feature );
}
}
for ( QgsFeature *feature : changedFeatures )
{
Q_ASSERT( !mFeatureCache.contains( feature->id() ) );
mFeatureCache.insert( feature->id(), feature );
}
mFeatureIds.unite( newIds );
emit featureIdsChanged( mLayer->id(), oldNewFid );
}
5 changes: 0 additions & 5 deletions src/analysis/vector/geometry_checker/qgsfeaturepool.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ class ANALYSIS_EXPORT QgsFeaturePool : public QObject
bool getSelectedOnly() const { return mSelectedOnly; }
void clearLayer() { mLayer = nullptr; }

signals:
void featureIdsChanged( const QString &layerId, const QMap<QgsFeatureId, QgsFeatureId> &oldNewFid );
private:
struct MapEntry
{
Expand All @@ -71,9 +69,6 @@ class ANALYSIS_EXPORT QgsFeaturePool : public QObject
bool mSelectedOnly;

bool getTouchingWithSharedEdge( QgsFeature &feature, QgsFeatureId &touchingId, const double & ( *comparator )( const double &, const double & ), double init );

private slots:
void updateFeatureIds( const QMap<QgsFeatureId, QgsFeatureId> &oldNewFid );
};

#endif // QGS_FEATUREPOOL_H
11 changes: 0 additions & 11 deletions src/analysis/vector/geometry_checker/qgsgeometrycheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,6 @@ bool QgsGeometryCheckError::handleChanges( const QgsGeometryCheck::Changes &chan
return true;
}

bool QgsGeometryCheckError::handleFidChanges( const QString &layerId, const QMap<QgsFeatureId, QgsFeatureId> &oldNewFidMap )
{
if ( layerId == mLayerId )
{
QgsFeatureId oldId = mFeatureId;
mFeatureId = oldNewFidMap.value( mFeatureId, mFeatureId );
return oldId != mFeatureId;
}
return false;
}

QMap<QString, QgsFeatureIds> QgsGeometryCheck::allLayerFeatureIds() const
{
QMap<QString, QgsFeatureIds> featureIds;
Expand Down
1 change: 0 additions & 1 deletion src/analysis/vector/geometry_checker/qgsgeometrycheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ class ANALYSIS_EXPORT QgsGeometryCheckError
}

virtual bool handleChanges( const QgsGeometryCheck::Changes &changes );
virtual bool handleFidChanges( const QString &layerId, const QMap<QgsFeatureId, QgsFeatureId> &oldNewFidMap );

protected:
// Users of this constructor must ensure geometry and errorLocation are in map coordinates
Expand Down
15 changes: 0 additions & 15 deletions src/analysis/vector/geometry_checker/qgsgeometrychecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ QgsGeometryChecker::QgsGeometryChecker( const QList<QgsGeometryCheck *> &checks,
: mChecks( checks )
, mContext( context )
{
for ( const QString &layerId : mContext->featurePools.keys() )
{
connect( mContext->featurePools[layerId], SIGNAL( featureIdsChanged( QString, QMap<QgsFeatureId, QgsFeatureId> ) ), this, SLOT( updateFeatureIds( QString, QMap<QgsFeatureId, QgsFeatureId> ) ) );
}
for ( const QgsFeaturePool *featurePool : mContext->featurePools.values() )
{
if ( featurePool->getLayer() )
Expand Down Expand Up @@ -299,14 +295,3 @@ void QgsGeometryChecker::runCheck( const QgsGeometryCheck *check )
emit errorAdded( error );
}
}

void QgsGeometryChecker::updateFeatureIds( const QString &layerId, const QMap<QgsFeatureId, QgsFeatureId> &oldNewFid )
{
for ( QgsGeometryCheckError *error : mCheckErrors )
{
if ( error->handleFidChanges( layerId, oldNewFid ) )
{
emit errorUpdated( error, false );
}
}
}
1 change: 0 additions & 1 deletion src/analysis/vector/geometry_checker/qgsgeometrychecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ class ANALYSIS_EXPORT QgsGeometryChecker : public QObject

private slots:
void emitProgressValue();
void updateFeatureIds( const QString &layerId, const QMap<QgsFeatureId, QgsFeatureId> &oldNewFid );
};

#endif // QGS_GEOMETRY_CHECKER_H
12 changes: 0 additions & 12 deletions src/analysis/vector/geometry_checker/qgsgeometrycontainedcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,6 @@
#include "qgsfeaturepool.h"


bool QgsGeometryContainedCheckError::handleFidChanges( const QString &layerId, const QMap<QgsFeatureId, QgsFeatureId> &oldNewFidMap )
{
bool changed = QgsGeometryCheckError::handleFidChanges( layerId, oldNewFidMap );
if ( mContainingFeature.first == layerId )
{
QgsFeatureId oldId = mContainingFeature.second;
mContainingFeature.second = oldNewFidMap.value( mContainingFeature.second, mContainingFeature.second );
changed |= ( oldId != mContainingFeature.second );
}
return changed;
}

void QgsGeometryContainedCheck::collectErrors( QList<QgsGeometryCheckError *> &errors, QStringList &messages, QAtomicInt *progressCounter, const QMap<QString, QgsFeatureIds> &ids ) const
{
QMap<QString, QgsFeatureIds> featureIds = ids.isEmpty() ? allLayerFeatureIds() : ids;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class ANALYSIS_EXPORT QgsGeometryContainedCheckError : public QgsGeometryCheckEr
}

virtual QString description() const override { return QApplication::translate( "QgsGeometryContainedCheckError", "Within feature" ); }
bool handleFidChanges( const QString& layerId, const QMap<QgsFeatureId, QgsFeatureId>& oldNewFidMap) override;

private:
QPair<QString, QgsFeatureId> mContainingFeature;
Expand Down
17 changes: 0 additions & 17 deletions src/analysis/vector/geometry_checker/qgsgeometryduplicatecheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,6 @@
#include "qgsgeometry.h"
#include "qgsfeaturepool.h"


bool QgsGeometryDuplicateCheckError::handleFidChanges( const QString &layerId, const QMap<QgsFeatureId, QgsFeatureId> &oldNewFidMap )
{
bool changed = QgsGeometryCheckError::handleFidChanges( layerId, oldNewFidMap );
if ( mDuplicates.contains( layerId ) )
{
QList<QgsFeatureId> &fids = mDuplicates[layerId];
for ( int i = 0, n = fids.size(); i < n; ++i )
{
QgsFeatureId oldId = fids[i];
fids[i] = oldNewFidMap.value( fids[i], fids[i] );
changed |= ( oldId != fids[i] );
}
}
return changed;
}

QString QgsGeometryDuplicateCheckError::duplicatesString( const QMap<QString, QgsFeaturePool *> &featurePools, const QMap<QString, QList<QgsFeatureId>> &duplicates )
{
QStringList str;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class ANALYSIS_EXPORT QgsGeometryDuplicateCheckError : public QgsGeometryCheckEr
// static_cast: since other->checker() == checker is only true if the types are actually the same
static_cast<QgsGeometryDuplicateCheckError *>( other )->duplicates() == duplicates();
}
bool handleFidChanges( const QString &layerId, const QMap<QgsFeatureId, QgsFeatureId> &oldNewFidMap ) override;

private:
QMap<QString, QList<QgsFeatureId>> mDuplicates;
Expand Down
24 changes: 0 additions & 24 deletions src/analysis/vector/geometry_checker/qgsgeometrygapcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,6 @@
#include "qgsgeometrycollection.h"
#include "qgsfeaturepool.h"

bool QgsGeometryGapCheckError::handleFidChanges( const QString &layerId, const QMap<QgsFeatureId, QgsFeatureId> &oldNewFidMap )
{
bool changed = false;
if ( mNeighbors.contains( layerId ) )
{
QgsFeatureIds &fids = mNeighbors[layerId];
QgsFeatureIds newIds;
for ( auto it = fids.begin(), itEnd = fids.end(); it != itEnd; ++it )
{
const QgsFeatureId &fid = *it;
QgsFeatureId newId = oldNewFidMap.value( fid, fid );
if ( fid != newId )
{
it = fids.erase( it );
newIds.insert( newId );
changed = true;
}
}
fids.unite( newIds );
}
return changed;
}


void QgsGeometryGapCheck::collectErrors( QList<QgsGeometryCheckError *> &errors, QStringList &messages, QAtomicInt *progressCounter, const QMap<QString, QgsFeatureIds> &ids ) const
{
if ( progressCounter ) progressCounter->fetchAndAddRelaxed( 1 );
Expand Down
2 changes: 0 additions & 2 deletions src/analysis/vector/geometry_checker/qgsgeometrygapcheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ class ANALYSIS_EXPORT QgsGeometryGapCheckError : public QgsGeometryCheckError
return mGapAreaBBox;
}

bool handleFidChanges( const QString &layerId, const QMap<QgsFeatureId, QgsFeatureId> &oldNewFidMap ) override;

private:
QMap<QString, QgsFeatureIds> mNeighbors;
QgsRectangle mGapAreaBBox;
Expand Down
12 changes: 0 additions & 12 deletions src/analysis/vector/geometry_checker/qgsgeometryoverlapcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,6 @@
#include "qgsfeaturepool.h"


bool QgsGeometryOverlapCheckError::handleFidChanges( const QString &layerId, const QMap<QgsFeatureId, QgsFeatureId> &oldNewFidMap )
{
bool changed = QgsGeometryCheckError::handleFidChanges( layerId, oldNewFidMap );
if ( mOverlappedFeature.first == layerId )
{
QgsFeatureId oldId = mOverlappedFeature.second;
mOverlappedFeature.second = oldNewFidMap.value( mOverlappedFeature.second, mOverlappedFeature.second );
changed |= ( oldId != mOverlappedFeature.second );
}
return changed;
}

void QgsGeometryOverlapCheck::collectErrors( QList<QgsGeometryCheckError *> &errors, QStringList &messages, QAtomicInt *progressCounter, const QMap<QString, QgsFeatureIds> &ids ) const
{
double overlapThreshold = mThresholdMapUnits;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class ANALYSIS_EXPORT QgsGeometryOverlapCheckError : public QgsGeometryCheckErro
}

virtual QString description() const override { return QApplication::translate( "QgsGeometryTypeCheckError", "Overlap with %1:%2" ).arg( mOverlappedFeature.first ).arg( mOverlappedFeature.second ); }
bool handleFidChanges( const QString& layerId, const QMap<QgsFeatureId, QgsFeatureId>& oldNewFidMap) override;

private:
QPair<QString, QgsFeatureId> mOverlappedFeature;
Expand Down

0 comments on commit 816273e

Please sign in to comment.