mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-06 00:05:02 -05:00
260 lines
7.1 KiB
Plaintext
260 lines
7.1 KiB
Plaintext
/************************************************************************
|
|
* This file has been generated automatically from *
|
|
* *
|
|
* src/analysis/vector/geometry_checker/qgsgeometrycheck.h *
|
|
* *
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
class QgsGeometryCheck
|
|
{
|
|
%Docstring
|
|
This class implements a geometry check.
|
|
|
|
Geometry checks run over a set of features and can detect errors like topological
|
|
or other issues which are reported in the geometry validation panel in QGIS and
|
|
help a user to create valid geometries.
|
|
|
|
Implementing a custom geometry check consists of the following parts
|
|
|
|
### Writing the check
|
|
|
|
A new subclass of QgsGeometryCheck needs to be written and at least the following
|
|
abstract methods need to be implemented:
|
|
|
|
- `compatibleGeometryTypes()`
|
|
|
|
A list of geometry types to which this check applies
|
|
|
|
- `resolutionMethods()`
|
|
|
|
A list of names for (automated) resolution methods that can be used to fix errors of this type
|
|
|
|
- `description()`
|
|
|
|
A description for the geometry check.
|
|
|
|
- `id()`
|
|
|
|
A unique id for this check.
|
|
|
|
- `checkType()`
|
|
|
|
One of QgsGeometryCheck.LayerCheck, QgsGeometryCheck.FeatureCheck,QgsGeometryCheck.FeatureNodeCheck
|
|
|
|
- \link collectErrors() `collectErrors(featurePools, errors, messages, feedback, ids)`\endlink
|
|
|
|
This method will be called to validate geometries. All geometries which should be validated are passed
|
|
into this method with the parameter ids and should be retrieved from the available featurePools to make
|
|
use of caching. New errors should be appended to the error list and other message strings to messages.
|
|
The method needs to return a tuple (errors, messages).
|
|
|
|
### Creating a geometry check factory
|
|
|
|
A Geometry check factory manages meta information for checks. There will always be one single
|
|
geometry check factory created per check type, but it's possible that multiple QgsGeometryCheck
|
|
instances are created and used in parallel.
|
|
|
|
A new subclass of QgsGeometryCheckFactory needs to be written and at least the following
|
|
abstract methods need to be implemented:
|
|
|
|
- \link QgsGeometryCheckFactory.createGeometryCheck() `createGeometryCheck(context, configuration)`\endlink
|
|
|
|
Needs to return a new subclassed QgsGeometryCheck object that has been written in the previous step.
|
|
|
|
- \link QgsGeometryCheckFactory.id() `id()\endlink
|
|
|
|
A unique id for this geometry check.
|
|
|
|
- \link QgsGeometryCheckFactory.description() `description()\endlink
|
|
|
|
A description for this geometry check that can be presented to the user for more explanation.
|
|
|
|
- \link QgsGeometryCheckFactory.isCompatible() `QgsGeometryCheckFactory.isCompatible(layer)`\endlink
|
|
|
|
Returns a boolean that determines if this check is available for a given layer. This often
|
|
checks for the geometry type of the layer.
|
|
|
|
- \link QgsGeometryCheckFactory.flags() `flags()`\endlink
|
|
|
|
Returns additional flags for a geometry check. If unsure return QgsGeometryCheck.AvailableInValidation.
|
|
|
|
- \link QgsGeometryCheckFactory.checkType() `checkType()`\endlink
|
|
|
|
Returns the type of this geometry check.
|
|
|
|
### Registering the geometry check
|
|
|
|
Finally the geometry check factory needs to be registered in QGIS, so the system
|
|
is aware of the available geometry checks.
|
|
|
|
.. code-block:: python
|
|
|
|
# Make sure you always keep a
|
|
checkFactory = MyGeometryCheckFactory()
|
|
QgsAnalysis.geometryCheckRegistry().registerGeometryCheck(checkFactory)
|
|
|
|
.. note::
|
|
|
|
This class is a technology preview and unstable API.
|
|
|
|
.. versionadded:: 3.4
|
|
%End
|
|
|
|
%TypeHeaderCode
|
|
#include "qgsgeometrycheck.h"
|
|
%End
|
|
public:
|
|
static const QMetaObject staticMetaObject;
|
|
|
|
public:
|
|
|
|
struct LayerFeatureIds
|
|
{
|
|
LayerFeatureIds();
|
|
|
|
|
|
};
|
|
|
|
enum ChangeWhat
|
|
{
|
|
ChangeFeature,
|
|
ChangePart,
|
|
ChangeRing,
|
|
ChangeNode
|
|
};
|
|
|
|
enum ChangeType
|
|
{
|
|
ChangeAdded,
|
|
ChangeRemoved,
|
|
ChangeChanged
|
|
};
|
|
|
|
enum CheckType
|
|
{
|
|
FeatureNodeCheck,
|
|
FeatureCheck,
|
|
LayerCheck
|
|
};
|
|
|
|
enum Flag
|
|
{
|
|
AvailableInValidation
|
|
};
|
|
typedef QFlags<QgsGeometryCheck::Flag> Flags;
|
|
|
|
|
|
struct Change
|
|
{
|
|
Change();
|
|
|
|
Change( QgsGeometryCheck::ChangeWhat _what, QgsGeometryCheck::ChangeType _type, QgsVertexId _vidx = QgsVertexId() );
|
|
%Docstring
|
|
Create a new Change
|
|
%End
|
|
|
|
QgsGeometryCheck::ChangeWhat what;
|
|
|
|
QgsGeometryCheck::ChangeType type;
|
|
|
|
QgsVertexId vidx;
|
|
bool operator==( const QgsGeometryCheck::Change &other );
|
|
};
|
|
|
|
typedef QMap<QString, QMap<QgsFeatureId, QList<QgsGeometryCheck::Change> > > Changes;
|
|
|
|
QgsGeometryCheck( const QgsGeometryCheckContext *context, const QVariantMap &configuration );
|
|
%Docstring
|
|
Create a new geometry check.
|
|
%End
|
|
virtual ~QgsGeometryCheck();
|
|
|
|
|
|
virtual bool isCompatible( QgsVectorLayer *layer ) const;
|
|
%Docstring
|
|
Returns if this geometry check is compatible with ``layer``.
|
|
By default it checks for the geometry type in ``compatibleGeometryTypes``().
|
|
|
|
.. versionadded:: 3.4
|
|
%End
|
|
|
|
virtual QList<QgsWkbTypes::GeometryType> compatibleGeometryTypes() const = 0;
|
|
%Docstring
|
|
A list of geometry types for which this check can be performed.
|
|
|
|
.. versionadded:: 3.4
|
|
%End
|
|
|
|
virtual QgsGeometryCheck::Flags flags() const;
|
|
%Docstring
|
|
Flags for this geometry check.
|
|
%End
|
|
|
|
virtual void collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors /In,Out/, QStringList &messages /In,Out/, QgsFeedback *feedback, const LayerFeatureIds &ids = QgsGeometryCheck::LayerFeatureIds() ) const = 0;
|
|
%Docstring
|
|
The main worker method.
|
|
Check all features available from ``featurePools`` and write errors found to ``errors``.
|
|
Other status messages can be written to ``messages``.
|
|
Progress should be reported to ``feedback``. Only features and layers listed in ``ids`` should be checked.
|
|
|
|
.. versionadded:: 3.4
|
|
%End
|
|
|
|
|
|
virtual QStringList resolutionMethods() const = 0;
|
|
%Docstring
|
|
Returns a list of descriptions for available resolutions for errors. The index will be passed as ``method`` to :py:func:`fixError`.
|
|
|
|
.. versionadded:: 3.4
|
|
%End
|
|
|
|
virtual QString description() const = 0;
|
|
%Docstring
|
|
Returns a human readable description for this check.
|
|
|
|
.. versionadded:: 3.4
|
|
%End
|
|
|
|
virtual QString id() const = 0;
|
|
%Docstring
|
|
Returns an id for this check.
|
|
|
|
.. versionadded:: 3.4
|
|
%End
|
|
|
|
virtual CheckType checkType() const = 0;
|
|
%Docstring
|
|
Returns the check type.
|
|
|
|
.. versionadded:: 3.4
|
|
%End
|
|
|
|
const QgsGeometryCheckContext *context() const;
|
|
%Docstring
|
|
Returns the context
|
|
|
|
.. versionadded:: 3.4
|
|
%End
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
/************************************************************************
|
|
* This file has been generated automatically from *
|
|
* *
|
|
* src/analysis/vector/geometry_checker/qgsgeometrycheck.h *
|
|
* *
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
|
************************************************************************/
|