Skip to content

Commit

Permalink
Doxymenation for gap checks
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Dec 22, 2018
1 parent 2ad870b commit 65f6e7b
Show file tree
Hide file tree
Showing 3 changed files with 224 additions and 11 deletions.
Expand Up @@ -27,34 +27,120 @@ This represents an error reported by a geometry check.
#include "qgsgeometrycheckerror.h"
%End
public:
enum Status { StatusPending, StatusFixFailed, StatusFixed, StatusObsolete };
enum ValueType { ValueLength, ValueArea, ValueOther };

enum Status
{
StatusPending,
StatusFixFailed,
StatusFixed,
StatusObsolete
};

enum ValueType
{
ValueLength,
ValueArea,
ValueOther
};

QgsGeometryCheckError( const QgsGeometryCheck *check,
const QgsGeometryCheckerUtils::LayerFeature &layerFeature,
const QgsPointXY &errorLocation,
QgsVertexId vidx = QgsVertexId(),
const QVariant &value = QVariant(),
ValueType valueType = ValueOther );
%Docstring
Create a new geometry check error with the parent ``check`` and for the
``layerFeature`` pair at the \errorLocation. Optionally the vertex can be
specified via ``vixd`` and a ``value`` with its ``value`` Type for
additional information.
%End

virtual ~QgsGeometryCheckError();


const QgsGeometryCheck *check() const;
%Docstring
The geometry check that created this error.
%End

const QString &layerId() const;
%Docstring
The id of the layer on which this error has been detected.
%End

QgsFeatureId featureId() const;
%Docstring
The id of the feature on which this error has been detected.
%End

QgsGeometry geometry() const;
%Docstring
The geometry of the error in map units.
%End

virtual QgsRectangle affectedAreaBBox() const;
%Docstring
The bounding box of the affected area of the error.
%End

virtual QString description() const;
%Docstring
The error description. By default the description of the parent check
will be returned.
%End

const QgsPointXY &location() const;
%Docstring
The location of the error in map units.
%End

QVariant value() const;
%Docstring
An additional value for the error.
Lenghts and areas are provided in map units.

.. seealso:: :py:func:`valueType`
%End

ValueType valueType() const;
%Docstring
The type of the value.

.. seealso:: :py:func:`value`
%End

const QgsVertexId &vidx() const;
%Docstring
The id of the affected vertex. May be valid or not, depending on the
check.
%End

Status status() const;
%Docstring
The status of the error.
%End

QString resolutionMessage() const;
%Docstring
A message with details, how the error has been resolved.
%End

void setFixed( int method );
%Docstring
Set the status to fixed and specify the ``method`` that has been used to
fix the error.
%End

void setFixFailed( const QString &reason );
%Docstring
Set the error status to failed and specify the ``reason`` for failure.
%End

void setObsolete();
%Docstring
Set the error status to obsolete.
%End

virtual bool isEqual( QgsGeometryCheckError *other ) const;
%Docstring
Expand All @@ -77,6 +163,7 @@ Will be used to update existing errors whenever they are re-checked.


protected:

QgsGeometryCheckError( const QgsGeometryCheck *check,
const QString &layerId,
QgsFeatureId featureId,
Expand All @@ -85,6 +172,14 @@ Will be used to update existing errors whenever they are re-checked.
QgsVertexId vidx = QgsVertexId(),
const QVariant &value = QVariant(),
ValueType valueType = ValueOther );
%Docstring
Create a new geometry check error with the parent ``check`` and for the
layer with ``layerId`` and ``featureId``.
The ``geometry`` of the error and the ``errorLocation`` need to be
specified in map coordiantes.
Optionally the vertex can be specified via ``vixd`` and a ``value`` with
its ``value`` Type for additional information.
%End


};
Expand Down
108 changes: 101 additions & 7 deletions src/analysis/vector/geometry_checker/qgsgeometrycheckerror.h
Expand Up @@ -35,9 +35,34 @@ class QgsPointXY;
class ANALYSIS_EXPORT QgsGeometryCheckError
{
public:
enum Status { StatusPending, StatusFixFailed, StatusFixed, StatusObsolete };
enum ValueType { ValueLength, ValueArea, ValueOther };

/**
* The status of an error.
*/
enum Status
{
StatusPending, //!< The error is detected and pending to be handled
StatusFixFailed, //!< A fix has been tried on the error but failed
StatusFixed, //!< The error is fixed
StatusObsolete //!< The error is obsolete because of other modifications
};

/**
* Describes the type of an error value.
*/
enum ValueType
{
ValueLength, //!< The value is a length
ValueArea, //!< The value is an area
ValueOther //!< The value if of another type
};

/**
* Create a new geometry check error with the parent \a check and for the
* \a layerFeature pair at the \errorLocation. Optionally the vertex can be
* specified via \a vixd and a \a value with its \a value Type for
* additional information.
*/
QgsGeometryCheckError( const QgsGeometryCheck *check,
const QgsGeometryCheckerUtils::LayerFeature &layerFeature,
const QgsPointXY &errorLocation,
Expand All @@ -49,24 +74,85 @@ class ANALYSIS_EXPORT QgsGeometryCheckError

const QgsGeometryCheckError &operator=( const QgsGeometryCheckError & ) = delete;

/**
* The geometry check that created this error.
*/
const QgsGeometryCheck *check() const { return mCheck; }

/**
* The id of the layer on which this error has been detected.
*/
const QString &layerId() const { return mLayerId; }

/**
* The id of the feature on which this error has been detected.
*/
QgsFeatureId featureId() const { return mFeatureId; }
// In map units

/**
* The geometry of the error in map units.
*/
QgsGeometry geometry() const;
// In map units

/**
* The bounding box of the affected area of the error.
*/
virtual QgsRectangle affectedAreaBBox() const;

/**
* The error description. By default the description of the parent check
* will be returned.
*/
virtual QString description() const { return mCheck->description(); }
// In map units

/**
* The location of the error in map units.
*/
const QgsPointXY &location() const { return mErrorLocation; }
// Lengths, areas in map units

/**
* An additional value for the error.
* Lenghts and areas are provided in map units.
* \see valueType()
*/
QVariant value() const { return mValue; }

/**
* The type of the value.
* \see value()
*/
ValueType valueType() const { return mValueType; }

/**
* The id of the affected vertex. May be valid or not, depending on the
* check.
*/
const QgsVertexId &vidx() const { return mVidx; }

/**
* The status of the error.
*/
Status status() const { return mStatus; }

/**
* A message with details, how the error has been resolved.
*/
QString resolutionMessage() const { return mResolutionMessage; }

/**
* Set the status to fixed and specify the \a method that has been used to
* fix the error.
*/
void setFixed( int method );

/**
* Set the error status to failed and specify the \a reason for failure.
*/
void setFixFailed( const QString &reason );

/**
* Set the error status to obsolete.
*/
void setObsolete() { mStatus = StatusObsolete; }

/**
Expand Down Expand Up @@ -94,7 +180,15 @@ class ANALYSIS_EXPORT QgsGeometryCheckError
virtual bool handleChanges( const QgsGeometryCheck::Changes &changes ) SIP_SKIP;

protected:
// Users of this constructor must ensure geometry and errorLocation are in map coordinates

/**
* Create a new geometry check error with the parent \a check and for the
* layer with \a layerId and \a featureId.
* The \a geometry of the error and the \a errorLocation need to be
* specified in map coordiantes.
* Optionally the vertex can be specified via \a vixd and a \a value with
* its \a value Type for additional information.
*/
QgsGeometryCheckError( const QgsGeometryCheck *check,
const QString &layerId,
QgsFeatureId featureId,
Expand Down
28 changes: 26 additions & 2 deletions src/analysis/vector/geometry_checker/qgsgeometrygapcheck.h
Expand Up @@ -22,9 +22,22 @@
#include "qgsgeometrycheckerror.h"
#include "qgsfeatureid.h"

/**
* \ingroup analysis
* An error produced by a QgsGeometryGapCheck.
*
* \since QGIS 3.4
*/
class ANALYSIS_EXPORT QgsGeometryGapCheckError : public QgsGeometryCheckError
{
public:

/**
* Create a new gap check error produced by \a check on the layer \a layerId.
* The \a geometry of the gap needs to be in map coordinates.
* The \a neighbors are a map of layer ids and feature ids.
* The \a area of the gap in map units and the bounding box of the gap in map units too.
*/
QgsGeometryGapCheckError( const QgsGeometryCheck *check,
const QString &layerId,
const QgsGeometry &geometry,
Expand All @@ -36,6 +49,10 @@ class ANALYSIS_EXPORT QgsGeometryGapCheckError : public QgsGeometryCheckError
, mGapAreaBBox( gapAreaBBox )
{
}

/**
* A map of layers and feature ids of the neighbors of the gap.
*/
const QMap<QString, QgsFeatureIds> &neighbors() const { return mNeighbors; }

bool isEqual( QgsGeometryCheckError *other ) const override
Expand Down Expand Up @@ -74,15 +91,22 @@ class ANALYSIS_EXPORT QgsGeometryGapCheckError : public QgsGeometryCheckError
QgsRectangle mGapAreaBBox;
};


/**
* \ingroup analysis
* Checks for gaps between neighbouring polygons.
*
* \since QGIS 3.4
*/
class ANALYSIS_EXPORT QgsGeometryGapCheck : public QgsGeometryCheck
{
Q_GADGET
public:
//! Resolution methods for geometry gap checks
enum ResolutionMethod
{
MergeLongestEdge,
NoChange
MergeLongestEdge, //!< Merge the gap with the polygon with the longest shared edge.
NoChange //!< Do not handle the error.
};
Q_ENUM( ResolutionMethod )

Expand Down

0 comments on commit 65f6e7b

Please sign in to comment.