Skip to content

Commit

Permalink
Thread safety in duplicates check
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Aug 8, 2019
1 parent 19ee6f5 commit 6fbe622
Showing 1 changed file with 7 additions and 5 deletions.
Expand Up @@ -49,16 +49,17 @@ void QgsGeometryDuplicateCheck::collectErrors( const QMap<QString, QgsFeaturePoo
// Ensure each pair of layers only gets compared once: remove the current layer from the layerIds, but add it to the layerList for layerFeaturesB
layerIds.removeOne( layerFeatureA.layer()->id() );

QgsRectangle bboxA = layerFeatureA.geometry().boundingBox();
std::unique_ptr< QgsGeometryEngine > geomEngineA = QgsGeometryCheckerUtils::createGeomEngine( layerFeatureA.geometry().constGet(), mContext->tolerance );
QgsGeometry geomA = layerFeatureA.geometry();
QgsRectangle bboxA = geomA.boundingBox();
std::unique_ptr< QgsGeometryEngine > geomEngineA = QgsGeometryCheckerUtils::createGeomEngine( geomA.constGet(), mContext->tolerance );
if ( !geomEngineA->isValid() )
{
messages.append( tr( "Duplicate check failed for (%1): the geometry is invalid" ).arg( layerFeatureA.id() ) );
continue;
}
QMap<QString, QList<QgsFeatureId>> duplicates;

QgsWkbTypes::GeometryType geomType = layerFeatureA.feature().geometry().type();
QgsWkbTypes::GeometryType geomType = geomA.type();
QgsGeometryCheckerUtils::LayerFeatures layerFeaturesB( featurePools, QList<QString>() << layerFeatureA.layer()->id() << layerIds, bboxA, {geomType}, mContext );
for ( const QgsGeometryCheckerUtils::LayerFeature &layerFeatureB : layerFeaturesB )
{
Expand All @@ -68,7 +69,8 @@ void QgsGeometryDuplicateCheck::collectErrors( const QMap<QString, QgsFeaturePoo
continue;
}
QString errMsg;
QgsAbstractGeometry *diffGeom = geomEngineA->symDifference( layerFeatureB.geometry().constGet(), &errMsg );
QgsGeometry geomB = layerFeatureB.geometry();
QgsAbstractGeometry *diffGeom = geomEngineA->symDifference( geomB.constGet(), &errMsg );
if ( errMsg.isEmpty() && diffGeom && diffGeom->isEmpty() )
{
duplicates[layerFeatureB.layer()->id()].append( layerFeatureB.feature().id() );
Expand All @@ -81,7 +83,7 @@ void QgsGeometryDuplicateCheck::collectErrors( const QMap<QString, QgsFeaturePoo
}
if ( !duplicates.isEmpty() )
{
errors.append( new QgsGeometryDuplicateCheckError( this, layerFeatureA, layerFeatureA.geometry().constGet()->centroid(), featurePools, duplicates ) );
errors.append( new QgsGeometryDuplicateCheckError( this, layerFeatureA, geomA.constGet()->centroid(), featurePools, duplicates ) );
}
}
}
Expand Down

0 comments on commit 6fbe622

Please sign in to comment.