Skip to content

Commit

Permalink
Rename QgsGeometryCheckFix to QgsGeometryCheckResolutionMethod
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jan 14, 2020
1 parent d5cc24c commit 952d704
Show file tree
Hide file tree
Showing 14 changed files with 154 additions and 101 deletions.
2 changes: 1 addition & 1 deletion python/analysis/analysis_auto.sip
Expand Up @@ -32,7 +32,7 @@
%Include auto_generated/raster/qgstotalcurvaturefilter.sip
%Include auto_generated/vector/geometry_checker/qgsfeaturepool.sip
%Include auto_generated/vector/geometry_checker/qgsgeometrycheck.sip
%Include auto_generated/vector/geometry_checker/qgsgeometrycheckfix.sip
%Include auto_generated/vector/geometry_checker/qgsgeometrycheckresolutionmethod.sip
%Include auto_generated/vector/geometry_checker/qgsgeometrycheckcontext.sip
%Include auto_generated/vector/geometry_checker/qgsgeometrycheckerror.sip
%Include auto_generated/vector/geometry_checker/qgsgeometrycheckerutils.sip
Expand Down
Expand Up @@ -213,11 +213,20 @@ Progress should be reported to ``feedback``. Only features and layers listed in
%End


virtual QList<QgsGeometryCheckFix> availableResolutionMethods() const;
virtual QList<QgsGeometryCheckResolutionMethod> availableResolutionMethods() const;
%Docstring
Returns a list of available resolution methods.

.. versionadded:: 3.12
%End

virtual QStringList resolutionMethods() const = 0;
virtual QStringList resolutionMethods() const;
%Docstring
Returns a list of descriptions for available resolutions for errors. The index will be passed as ``method`` to :py:func:`fixError`.
Returns a list of descriptions for available resolutions for errors.
The index will be passed as ``method`` to :py:func:`fixError`.

.. deprecated:: QGIS 3.12
use availableResolutionMethods() instead

.. versionadded:: 3.4
%End
Expand Down
@@ -1,13 +1,14 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/analysis/vector/geometry_checker/qgsgeometrycheckfix.h *
* src/analysis/vector/geometry_checker/qgsgeometrycheckresolutionmethod.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/


class QgsGeometryCheckFix

class QgsGeometryCheckResolutionMethod
{
%Docstring
This class implements a fix for problems detected in geometry checks.
Expand All @@ -16,10 +17,10 @@ This class implements a fix for problems detected in geometry checks.
%End

%TypeHeaderCode
#include "qgsgeometrycheckfix.h"
#include "qgsgeometrycheckresolutionmethod.h"
%End
public:
QgsGeometryCheckFix( int id, const QString &name, const QString &description, bool isStable = true );
QgsGeometryCheckResolutionMethod( int id, const QString &name, const QString &description, bool isStable = true );

int id() const;

Expand All @@ -43,7 +44,7 @@ A human readable and translated description for this fix.
/************************************************************************
* This file has been generated automatically from *
* *
* src/analysis/vector/geometry_checker/qgsgeometrycheckfix.h *
* src/analysis/vector/geometry_checker/qgsgeometrycheckresolutionmethod.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
4 changes: 2 additions & 2 deletions src/analysis/CMakeLists.txt
Expand Up @@ -205,7 +205,7 @@ SET(QGIS_ANALYSIS_SRCS
vector/geometry_checker/qgsgeometryanglecheck.cpp
vector/geometry_checker/qgsgeometryareacheck.cpp
vector/geometry_checker/qgsgeometrycheck.cpp
vector/geometry_checker/qgsgeometrycheckfix.cpp
vector/geometry_checker/qgsgeometrycheckresolutionmethod.cpp
vector/geometry_checker/qgsgeometrycheckcontext.cpp
vector/geometry_checker/qgsgeometrychecker.cpp
vector/geometry_checker/qgsgeometrycheckerror.cpp
Expand Down Expand Up @@ -298,7 +298,7 @@ SET(QGIS_ANALYSIS_HDRS
vector/geometry_checker/qgsgeometryanglecheck.h
vector/geometry_checker/qgsgeometryareacheck.h
vector/geometry_checker/qgsgeometrycheck.h
vector/geometry_checker/qgsgeometrycheckfix.h
vector/geometry_checker/qgsgeometrycheckresolutionmethod.h
vector/geometry_checker/qgsgeometrycheckcontext.h
vector/geometry_checker/qgsgeometrychecker.h
vector/geometry_checker/qgsgeometrycheckerror.h
Expand Down
13 changes: 10 additions & 3 deletions src/analysis/vector/geometry_checker/qgsgeometrycheck.cpp
Expand Up @@ -56,20 +56,27 @@ void QgsGeometryCheck::fixError( const QMap<QString, QgsFeaturePool *> &featureP
Q_UNUSED( changes )
}

QList<QgsGeometryCheckFix> QgsGeometryCheck::availableResolutionMethods() const
QList<QgsGeometryCheckResolutionMethod> QgsGeometryCheck::availableResolutionMethods() const
{
QList<QgsGeometryCheckFix> fixes;
QList<QgsGeometryCheckResolutionMethod> fixes;
Q_NOWARN_DEPRECATED_PUSH
const QStringList methods = resolutionMethods();
Q_NOWARN_DEPRECATED_POP

int i = 0;
for ( const QString &method : methods )
{
fixes.append( QgsGeometryCheckFix( i, method, QString(), false ) );
fixes.append( QgsGeometryCheckResolutionMethod( i, method, QString(), false ) );
}

return fixes;
}

QStringList QgsGeometryCheck::resolutionMethods() const
{
return QStringList();
}

QMap<QString, QgsFeatureIds> QgsGeometryCheck::allLayerFeatureIds( const QMap<QString, QgsFeaturePool *> &featurePools ) const
{
QMap<QString, QgsFeatureIds> featureIds;
Expand Down
15 changes: 11 additions & 4 deletions src/analysis/vector/geometry_checker/qgsgeometrycheck.h
Expand Up @@ -26,7 +26,7 @@
#include "qgsvectorlayer.h"
#include "qgsgeometry.h"
#include "qgsgeometrycheckerutils.h"
#include "qgsgeometrycheckfix.h"
#include "qgsgeometrycheckresolutionmethod.h"
#include "qgssettings.h"

class QgsGeometryCheckError;
Expand Down Expand Up @@ -312,14 +312,21 @@ class ANALYSIS_EXPORT QgsGeometryCheck
*/
virtual void fixError( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap<QString, int> &mergeAttributeIndices, Changes &changes SIP_INOUT ) const SIP_SKIP;

virtual QList<QgsGeometryCheckFix> availableResolutionMethods() const;
/**
* Returns a list of available resolution methods.
*
* \since QGIS 3.12
*/
virtual QList<QgsGeometryCheckResolutionMethod> availableResolutionMethods() const;

/**
* Returns a list of descriptions for available resolutions for errors. The index will be passed as ``method`` to \see fixError().
* Returns a list of descriptions for available resolutions for errors.
* The index will be passed as ``method`` to \see fixError().
*
* \deprecated since QGIS 3.12, use availableResolutionMethods() instead
* \since QGIS 3.4
*/
virtual QStringList resolutionMethods() const = 0;
Q_DECL_DEPRECATED virtual QStringList resolutionMethods() const;

/**
* Returns a human readable description for this check.
Expand Down
Expand Up @@ -98,8 +98,8 @@ QgsRectangle QgsGeometryCheckError::affectedAreaBBox() const
void QgsGeometryCheckError::setFixed( int method )
{
mStatus = StatusFixed;
const QList<QgsGeometryCheckFix> methods = mCheck->availableResolutionMethods();
for ( const QgsGeometryCheckFix &fix : methods )
const QList<QgsGeometryCheckResolutionMethod> methods = mCheck->availableResolutionMethods();
for ( const QgsGeometryCheckResolutionMethod &fix : methods )
{
if ( fix.id() == method )
mResolutionMessage = fix.name();
Expand Down
29 changes: 0 additions & 29 deletions src/analysis/vector/geometry_checker/qgsgeometrycheckfix.cpp

This file was deleted.

42 changes: 0 additions & 42 deletions src/analysis/vector/geometry_checker/qgsgeometrycheckfix.h

This file was deleted.

@@ -0,0 +1,44 @@
/***************************************************************************
qgsgeometrycheckresolutionmethod.cpp
--------------------------------------
Date : January 2020
Copyright : (C) 2020 Matthias Kuhn
Email : matthias@opengis.ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgsgeometrycheckresolutionmethod.h"

QgsGeometryCheckResolutionMethod::QgsGeometryCheckResolutionMethod( int id, const QString &name, const QString &description, bool isStable )
{
mId = id;
mName = name;
mDescription = description;
mIsStable = isStable;
}

int QgsGeometryCheckResolutionMethod::id() const
{
return mId;
}

bool QgsGeometryCheckResolutionMethod::isStable() const
{
return mIsStable;
}

QString QgsGeometryCheckResolutionMethod::name() const
{
return mName;
}

QString QgsGeometryCheckResolutionMethod::description() const
{
return mDescription;
}
@@ -0,0 +1,56 @@
/***************************************************************************
qgsgeometrycheckresolutionmethod.h
--------------------------------------
Date : January 2020
Copyright : (C) 2020 Matthias Kuhn
Email : matthias@opengis.ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSGEOMETRYCHECKRESOLUTIONMETHOD_H
#define QGSGEOMETRYCHECKRESOLUTIONMETHOD_H

#include <QString>
#include "qgis_analysis.h"

/**
* This class implements a fix for problems detected in geometry checks.
*
* \since QGIS 3.12
*/
class ANALYSIS_EXPORT QgsGeometryCheckResolutionMethod
{
public:
QgsGeometryCheckResolutionMethod( int id, const QString &name, const QString &description, bool isStable = true );

int id() const;

/**
* If this fix is stable enough to be listed by default.
*/
bool isStable() const;

/**
* A human readable and translated name for this fix.
*/
QString name() const;

/**
* A human readable and translated description for this fix.
*/
QString description() const;

private:
int mId = -1;
bool mIsStable = false;
QString mName;
QString mDescription;
};

#endif // QGSGEOMETRYCHECKRESOLUTIONMETHOD_H
14 changes: 7 additions & 7 deletions src/analysis/vector/geometry_checker/qgsgeometrygapcheck.cpp
Expand Up @@ -419,19 +419,19 @@ QStringList QgsGeometryGapCheck::resolutionMethods() const
return methods;
}

QList<QgsGeometryCheckFix> QgsGeometryGapCheck::availableResolutionMethods() const
QList<QgsGeometryCheckResolutionMethod> QgsGeometryGapCheck::availableResolutionMethods() const
{
QList<QgsGeometryCheckFix> fixes
QList<QgsGeometryCheckResolutionMethod> fixes
{
QgsGeometryCheckFix( MergeLongestEdge, tr( "Add to longest shared edge" ), tr( "Add the gap area to the neighbouring polygon with the longest shared edge." ), false ),
QgsGeometryCheckFix( CreateNewFeature, tr( "Create new feature" ), tr( "Create a new feature from the gap area." ), false ),
QgsGeometryCheckFix( MergeLargestArea, tr( "Add to largest neighbouring area" ), tr( "Add the gap area to the neighbouring polygon with the largest area." ), false )
QgsGeometryCheckResolutionMethod( MergeLongestEdge, tr( "Add to longest shared edge" ), tr( "Add the gap area to the neighbouring polygon with the longest shared edge." ), false ),
QgsGeometryCheckResolutionMethod( CreateNewFeature, tr( "Create new feature" ), tr( "Create a new feature from the gap area." ), false ),
QgsGeometryCheckResolutionMethod( MergeLargestArea, tr( "Add to largest neighbouring area" ), tr( "Add the gap area to the neighbouring polygon with the largest area." ), false )
};

if ( mAllowedGapsSource )
fixes << QgsGeometryCheckFix( AddToAllowedGaps, tr( "Add gap to allowed exceptions" ), tr( "Create a new feature from the gap geometry on the allowed exceptions layer." ), false );
fixes << QgsGeometryCheckResolutionMethod( AddToAllowedGaps, tr( "Add gap to allowed exceptions" ), tr( "Create a new feature from the gap geometry on the allowed exceptions layer." ), false );

fixes << QgsGeometryCheckFix( NoChange, tr( "No action" ), tr( "Do not perform any action and mark this error as fixed." ), false );
fixes << QgsGeometryCheckResolutionMethod( NoChange, tr( "No action" ), tr( "Do not perform any action and mark this error as fixed." ), false );

return fixes;
}
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/vector/geometry_checker/qgsgeometrygapcheck.h
Expand Up @@ -116,7 +116,7 @@ class ANALYSIS_EXPORT QgsGeometryGapCheck : public QgsGeometryCheck
void fixError( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap<QString, int> &mergeAttributeIndices, Changes &changes ) const override;
QStringList resolutionMethods() const override;

QList<QgsGeometryCheckFix> availableResolutionMethods() const override;
QList<QgsGeometryCheckResolutionMethod> availableResolutionMethods() const override;

QString description() const override;
QString id() const override;
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsgeometryvalidationdock.cpp
Expand Up @@ -218,10 +218,10 @@ void QgsGeometryValidationDock::onCurrentErrorChanged( const QModelIndex &curren

if ( error->status() != QgsGeometryCheckError::StatusFixed )
{
const QList<QgsGeometryCheckFix> resolutionMethods = error->check()->availableResolutionMethods();
const QList<QgsGeometryCheckResolutionMethod> resolutionMethods = error->check()->availableResolutionMethods();
QGridLayout *layout = new QGridLayout( mResolutionWidget );
int resolutionIndex = 0;
for ( const QgsGeometryCheckFix &resolutionMethod : resolutionMethods )
for ( const QgsGeometryCheckResolutionMethod &resolutionMethod : resolutionMethods )
{
QToolButton *resolveBtn = new QToolButton( mResolutionWidget );
resolveBtn->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmCheckGeometry.svg" ) ) );
Expand Down

0 comments on commit 952d704

Please sign in to comment.