Skip to content

Commit

Permalink
[Geometry checker] Try harder to match old errors to those found afte…
Browse files Browse the repository at this point in the history
…r a recheck
  • Loading branch information
manisandro committed Oct 23, 2017
1 parent 8cefc65 commit ecd951d
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions src/analysis/vector/geometry_checker/qgsgeometrychecker.cpp
Expand Up @@ -199,46 +199,35 @@ bool QgsGeometryChecker::fixError( QgsGeometryCheckError *error, int method, boo

QgsGeometryCheckError::Status oldStatus = err->status();

// Update error, if this fails, mark the errors as obsolete
if ( !err->handleChanges( changes ) )
{
err->setObsolete();
emit errorUpdated( err, err->status() != oldStatus );
continue;
}
bool handled = err->handleChanges( changes );

// Check if this error now matches one found when rechecking the feature/area
QgsGeometryCheckError *matchErr = nullptr;
int nMatch = 0;
for ( QgsGeometryCheckError *recheckErr : recheckErrors )
{
if ( recheckErr->isEqual( err ) )
{
matchErr = recheckErr;
nMatch = 1;
break;
}
else if ( recheckErr->closeMatch( err ) )
if ( recheckErr->isEqual( err ) || recheckErr->closeMatch( err ) )
{
++nMatch;
matchErr = recheckErr;
}
}
// If just one close match was found, take it
if ( nMatch == 1 && matchErr )
{
err->update( matchErr );
emit errorUpdated( err, err->status() != oldStatus );
int nRemoved = recheckErrors.removeAll( matchErr );
Q_UNUSED( nRemoved );
Q_ASSERT( nRemoved == 1 );
recheckErrors.removeAll( matchErr );
delete matchErr;
continue;
}

// If no match is found and the error is not fixed or obsolete, set it to obsolete if...
if ( err->status() < QgsGeometryCheckError::StatusFixed &&
(
// it is a FeatureNodeCheck or FeatureCheck error whose feature was rechecked
// changes weren't handled
!handled ||
// or if it is a FeatureNodeCheck or FeatureCheck error whose feature was rechecked
( err->check()->getCheckType() <= QgsGeometryCheck::FeatureCheck && recheckFeatures[err->layerId()].contains( err->featureId() ) ) ||
// or if it is a LayerCheck error within the rechecked area
( err->check()->getCheckType() == QgsGeometryCheck::LayerCheck && recheckArea.contains( err->affectedAreaBBox() ) )
Expand Down

0 comments on commit ecd951d

Please sign in to comment.