Skip to content
Permalink
Browse files

fix dox and use metaEnum + switch to handle resolution method

  • Loading branch information
3nids authored and m-kuhn committed Oct 12, 2018
1 parent fc6f55b commit 1f1ec0f634b37376879703fae2a5dbe5322ff840
@@ -187,6 +187,7 @@ SET(QGIS_ANALYSIS_MOC_HDRS
vector/geometry_checker/qgsgeometrychecker.h
vector/geometry_checker/qgsgeometrycheck.h
vector/geometry_checker/qgsvectorlayerfeaturepool.h
vector/geometry_checker/qgsgeometrygapcheck.h
)

INCLUDE_DIRECTORIES(SYSTEM ${SPATIALITE_INCLUDE_DIR})
@@ -292,7 +293,6 @@ SET(QGIS_ANALYSIS_HDRS
vector/geometry_checker/qgsgeometryduplicatecheck.h
vector/geometry_checker/qgsgeometryduplicatenodescheck.h
vector/geometry_checker/qgsgeometryfollowboundariescheck.h
vector/geometry_checker/qgsgeometrygapcheck.h
vector/geometry_checker/qgsgeometrymissingvertexcheck.h
vector/geometry_checker/qgsgeometryholecheck.h
vector/geometry_checker/qgsgeometrylineintersectioncheck.h
@@ -136,26 +136,32 @@ void QgsGeometryGapCheck::collectErrors( const QMap<QString, QgsFeaturePool *> &

void QgsGeometryGapCheck::fixError( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap<QString, int> & /*mergeAttributeIndices*/, Changes &changes ) const
{
if ( method == NoChange )
QMetaEnum metaEnum = QMetaEnum::fromType<QgsGeometryGapCheck::ResolutionMethod>();
if ( !metaEnum.isValid() || !metaEnum.valueToKey( method ) )
{
error->setFixed( method );
error->setFixFailed( tr( "Unknown method" ) );
}
else if ( method == MergeLongestEdge )
else
{
QString errMsg;
if ( mergeWithNeighbor( featurePools, static_cast<QgsGeometryGapCheckError *>( error ), changes, errMsg ) )
{
error->setFixed( method );
}
else
ResolutionMethod methodValue = static_cast<ResolutionMethod>( method );
switch ( methodValue )
{
error->setFixFailed( tr( "Failed to merge with neighbor: %1" ).arg( errMsg ) );
case NoChange:
error->setFixed( method );
break;
case MergeLongestEdge:
QString errMsg;
if ( mergeWithNeighbor( featurePools, static_cast<QgsGeometryGapCheckError *>( error ), changes, errMsg ) )
{
error->setFixed( method );
}
else
{
error->setFixFailed( tr( "Failed to merge with neighbor: %1" ).arg( errMsg ) );
}
break;
}
}
else
{
error->setFixFailed( tr( "Unknown method" ) );
}
}

bool QgsGeometryGapCheck::mergeWithNeighbor( const QMap<QString, QgsFeaturePool *> &featurePools,
@@ -76,8 +76,15 @@ class ANALYSIS_EXPORT QgsGeometryGapCheckError : public QgsGeometryCheckError

class ANALYSIS_EXPORT QgsGeometryGapCheck : public QgsGeometryCheck
{
Q_GADGET
public:
enum ResolutionMethod { MergeLongestEdge, NoChange };
//! Resolution methods for geometry gap checks
enum ResolutionMethod
{
MergeLongestEdge,
NoChange
};
Q_ENUM( ResolutionMethod )

/**
* The \a configuration accepts a "gapThreshold" key which specifies

0 comments on commit 1f1ec0f

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