Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
nicer error reporting for overlap check
replace overlap feature QPair by a struct
this allows using the layer name rather than its ID in the error description
- Loading branch information
|
@@ -92,11 +92,11 @@ void QgsGeometryOverlapCheck::fixError( const QMap<QString, QgsFeaturePool *> &f |
|
|
QgsGeometryOverlapCheckError *overlapError = static_cast<QgsGeometryOverlapCheckError *>( error ); |
|
|
|
|
|
QgsFeaturePool *featurePoolA = featurePools[ overlapError->layerId() ]; |
|
|
QgsFeaturePool *featurePoolB = featurePools[ overlapError->overlappedFeature().first ]; |
|
|
QgsFeaturePool *featurePoolB = featurePools[ overlapError->overlappedFeature().layerId() ]; |
|
|
QgsFeature featureA; |
|
|
QgsFeature featureB; |
|
|
if ( !featurePoolA->getFeature( overlapError->featureId(), featureA ) || |
|
|
!featurePoolB->getFeature( overlapError->overlappedFeature().second, featureB ) ) |
|
|
!featurePoolB->getFeature( overlapError->overlappedFeature().featureId(), featureB ) ) |
|
|
{ |
|
|
error->setObsolete(); |
|
|
return; |
|
@@ -186,7 +186,7 @@ void QgsGeometryOverlapCheck::fixError( const QMap<QString, QgsFeaturePool *> &f |
|
|
diff2->transform( ct, QgsCoordinateTransform::ReverseTransform ); |
|
|
featureB.setGeometry( QgsGeometry( std::move( diff2 ) ) ); |
|
|
|
|
|
changes[overlapError->overlappedFeature().first][featureB.id()].append( Change( ChangeFeature, ChangeChanged ) ); |
|
|
changes[overlapError->overlappedFeature().layerId()][featureB.id()].append( Change( ChangeFeature, ChangeChanged ) ); |
|
|
featurePoolB->updateFeature( featureB ); |
|
|
} |
|
|
|
|
@@ -249,15 +249,14 @@ bool QgsGeometryOverlapCheck::factoryIsCompatible( QgsVectorLayer *layer ) SIP_S |
|
|
|
|
|
QgsGeometryOverlapCheckError::QgsGeometryOverlapCheckError( const QgsGeometryCheck *check, const QgsGeometryCheckerUtils::LayerFeature &layerFeature, const QgsGeometry &geometry, const QgsPointXY &errorLocation, const QVariant &value, const QgsGeometryCheckerUtils::LayerFeature &overlappedFeature ) |
|
|
: QgsGeometryCheckError( check, layerFeature.layer()->id(), layerFeature.feature().id(), geometry, errorLocation, QgsVertexId(), value, ValueArea ) |
|
|
, mOverlappedFeature( qMakePair( overlappedFeature.layer()->id(), overlappedFeature.feature().id() ) ) |
|
|
|
|
|
, mOverlappedFeature( OverLappedFeature( overlappedFeature.layer(), overlappedFeature.feature().id() ) ) |
|
|
{ |
|
|
|
|
|
} |
|
|
|
|
|
QString QgsGeometryOverlapCheckError::description() const |
|
|
{ |
|
|
return QCoreApplication::translate( "QgsGeometryTypeCheckError", "Overlap with %1:%2" ).arg( mOverlappedFeature.first, QString::number( mOverlappedFeature.second ) ); |
|
|
return QCoreApplication::translate( "QgsGeometryTypeCheckError", "Overlap with %1 at feature %2" ).arg( mOverlappedFeature.layerName(), QString::number( mOverlappedFeature.featureId() ) ); |
|
|
} |
|
|
|
|
|
QgsGeometryCheck::CheckType QgsGeometryOverlapCheck::factoryCheckType() |
|
|
|
@@ -25,13 +25,34 @@ |
|
|
class ANALYSIS_EXPORT QgsGeometryOverlapCheckError : public QgsGeometryCheckError |
|
|
{ |
|
|
public: |
|
|
|
|
|
struct OverLappedFeature |
|
|
{ |
|
|
public: |
|
|
OverLappedFeature( QgsVectorLayer *vl, QgsFeatureId fid ) |
|
|
: mLayerId( vl->id() ) |
|
|
, mLayerName( vl->name() ) |
|
|
, mFeatureId( fid ) |
|
|
{} |
|
|
|
|
|
QString layerId() const {return mLayerId;} |
|
|
QString layerName() const {return mLayerName;} |
|
|
QgsFeatureId featureId() const {return mFeatureId;} |
|
|
bool operator==( const OverLappedFeature &other ) const {return mLayerId == other.layerId() && mFeatureId == other.featureId();} |
|
|
|
|
|
private: |
|
|
QString mLayerId; |
|
|
QString mLayerName; |
|
|
QgsFeatureId mFeatureId; |
|
|
}; |
|
|
|
|
|
QgsGeometryOverlapCheckError( const QgsGeometryCheck *check, |
|
|
const QgsGeometryCheckerUtils::LayerFeature &layerFeature, |
|
|
const QgsGeometry &geometry, |
|
|
const QgsPointXY &errorLocation, |
|
|
const QVariant &value, |
|
|
const QgsGeometryCheckerUtils::LayerFeature &overlappedFeature ); |
|
|
const QPair<QString, QgsFeatureId> &overlappedFeature() const { return mOverlappedFeature; } |
|
|
const OverLappedFeature &overlappedFeature() const { return mOverlappedFeature; } |
|
|
|
|
|
bool isEqual( QgsGeometryCheckError *other ) const override |
|
|
{ |
|
@@ -56,7 +77,7 @@ class ANALYSIS_EXPORT QgsGeometryOverlapCheckError : public QgsGeometryCheckErro |
|
|
{ |
|
|
return false; |
|
|
} |
|
|
if ( changes.value( mOverlappedFeature.first ).keys().contains( mOverlappedFeature.second ) ) |
|
|
if ( changes.value( mOverlappedFeature.layerId() ).keys().contains( mOverlappedFeature.featureId() ) ) |
|
|
{ |
|
|
return false; |
|
|
} |
|
@@ -66,7 +87,7 @@ class ANALYSIS_EXPORT QgsGeometryOverlapCheckError : public QgsGeometryCheckErro |
|
|
QString description() const override; |
|
|
|
|
|
private: |
|
|
QPair<QString, QgsFeatureId> mOverlappedFeature; |
|
|
OverLappedFeature mOverlappedFeature; |
|
|
}; |
|
|
|
|
|
class ANALYSIS_EXPORT QgsGeometryOverlapCheck : public QgsGeometryCheck |
|
|