Skip to content
Permalink
Browse files

[Geometry checker] Don't self-compare features in contained check

  • Loading branch information
manisandro committed Jun 29, 2017
1 parent 2b01ccf commit 5c8484056e386c9412632a09413c8a7ae8dd7df0
@@ -28,10 +28,14 @@ void QgsGeometryContainedCheck::collectErrors( QList<QgsGeometryCheckError *> &e
QgsGeometryCheckerUtils::LayerFeatures layerFeaturesB( mContext->featurePools, featureIds.keys(), bboxA, mCompatibleGeometryTypes );
for ( const QgsGeometryCheckerUtils::LayerFeature &layerFeatureB : layerFeaturesB )
{
if ( layerFeatureA == layerFeatureB )
{
continue;
}
QString errMsg;
if ( geomEngineA->within( *layerFeatureB.geometry(), &errMsg ) )
{
errors.append( new QgsGeometryContainedCheckError( this, layerFeatureA, layerFeatureA.geometry()->centroid(), qMakePair( layerFeatureB.layer().id(), layerFeatureB.feature().id() ) ) );
errors.append( new QgsGeometryContainedCheckError( this, layerFeatureA, layerFeatureA.geometry()->centroid(), layerFeatureB ) );
}
else if ( !errMsg.isEmpty() )
{
@@ -24,10 +24,10 @@ class QgsGeometryContainedCheckError : public QgsGeometryCheckError
QgsGeometryContainedCheckError( const QgsGeometryCheck *check,
const QgsGeometryCheckerUtils::LayerFeature &layerFeature,
const QgsPointXY &errorLocation,
const QPair<QString, QgsFeatureId> &containingFeature
const QgsGeometryCheckerUtils::LayerFeature &containingFeature
)
: QgsGeometryCheckError( check, layerFeature, errorLocation, QgsVertexId(), QString( "%1:%2" ).arg( containingFeature.first ).arg( containingFeature.second ), ValueOther )
, mContainingFeature( containingFeature )
: QgsGeometryCheckError( check, layerFeature, errorLocation, QgsVertexId(), containingFeature.id(), ValueOther )
, mContainingFeature( qMakePair( containingFeature.layer().id(), containingFeature.feature().id() ) )
{ }
const QPair<QString, QgsFeatureId> &containingFeature() const { return mContainingFeature; }

@@ -38,7 +38,7 @@ class QgsGeometryContainedCheckError : public QgsGeometryCheckError
static_cast<QgsGeometryContainedCheckError *>( other )->containingFeature() == containingFeature();
}

virtual QString description() const override { return QApplication::translate( "QgsGeometryContainedCheckError", "Within %1:%2" ).arg( mContainingFeature.first ).arg( mContainingFeature.second ); }
virtual QString description() const override { return QApplication::translate( "QgsGeometryContainedCheckError", "Within feature" ); }

private:
QPair<QString, QgsFeatureId> mContainingFeature;
@@ -61,6 +61,8 @@ namespace QgsGeometryCheckerUtils
const QgsAbstractGeometry *geometry() const { return mGeometry; }
QString geometryCrs() const { return mMapCrs ? mLayerToMapTransform.destinationCrs().authid() : mLayerToMapTransform.sourceCrs().authid(); }
QString id() const { return QString( "%1:%2" ).arg( mLayer->id() ).arg( mFeature.id() ); }
bool operator==( const LayerFeature &other ) const { return layer().id() == other.layer().id() && feature().id() == other.feature().id(); }
bool operator!=( const LayerFeature &other ) const { return layer().id() != other.layer().id() || feature().id() != other.feature().id(); }

private:
const QgsVectorLayer *mLayer = nullptr;

0 comments on commit 5c84840

Please sign in to comment.
You can’t perform that action at this time.