Skip to content
Permalink
Browse files

Merge pull request #8054 from m-kuhn/geometryCheckPyBindings

Python bindings for QgsGeometryCheck and co
  • Loading branch information
m-kuhn committed Oct 3, 2018
2 parents f4bc24c + 7a99fa2 commit 0319e36c63cc2b30347ec7f9ba382c0743e1d9de
Showing with 3,958 additions and 1,325 deletions.
  1. +9 −6 python/CMakeLists.txt
  2. +9 −0 python/analysis/analysis_auto.sip
  3. +3 −0 python/analysis/auto_additions/qgsgeometrycheck.py
  4. +50 −0 python/analysis/auto_generated/qgsanalysis.sip.in
  5. +102 −0 python/analysis/auto_generated/vector/geometry_checker/qgsfeaturepool.sip.in
  6. +180 −0 python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheck.sip.in
  7. +35 −0 python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheckcontext.sip.in
  8. +101 −0 python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheckerror.sip.in
  9. +96 −0 python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheckerutils.sip.in
  10. +84 −0 python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheckfactory.sip.in
  11. +69 −0 python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheckregistry.sip.in
  12. +141 −0 python/analysis/auto_generated/vector/geometry_checker/qgssinglegeometrycheck.sip.in
  13. +25 −5 src/analysis/CMakeLists.txt
  14. +50 −0 src/analysis/qgsanalysis.cpp
  15. +66 −0 src/analysis/qgsanalysis.h
  16. +18 −7 src/analysis/vector/geometry_checker/qgsfeaturepool.h
  17. +53 −5 src/analysis/vector/geometry_checker/qgsgeometryanglecheck.cpp
  18. +22 −8 src/analysis/vector/geometry_checker/qgsgeometryanglecheck.h
  19. +19 −14 src/analysis/vector/geometry_checker/qgsgeometryareacheck.cpp
  20. +19 −12 src/analysis/vector/geometry_checker/qgsgeometryareacheck.h
  21. +42 −203 src/analysis/vector/geometry_checker/qgsgeometrycheck.cpp
  22. +164 −119 src/analysis/vector/geometry_checker/qgsgeometrycheck.h
  23. +24 −0 src/analysis/vector/geometry_checker/qgsgeometrycheckcontext.cpp
  24. +67 −0 src/analysis/vector/geometry_checker/qgsgeometrycheckcontext.h
  25. +24 −20 src/analysis/vector/geometry_checker/qgsgeometrychecker.cpp
  26. +12 −7 src/analysis/vector/geometry_checker/qgsgeometrychecker.h
  27. +197 −0 src/analysis/vector/geometry_checker/qgsgeometrycheckerror.cpp
  28. +116 −0 src/analysis/vector/geometry_checker/qgsgeometrycheckerror.h
  29. +294 −252 src/analysis/vector/geometry_checker/qgsgeometrycheckerutils.cpp
  30. +164 −150 src/analysis/vector/geometry_checker/qgsgeometrycheckerutils.h
  31. 0 src/analysis/vector/geometry_checker/qgsgeometrycheckfactory.cpp
  32. +116 −0 src/analysis/vector/geometry_checker/qgsgeometrycheckfactory.h
  33. +49 −0 src/analysis/vector/geometry_checker/qgsgeometrycheckregistry.cpp
  34. +84 −0 src/analysis/vector/geometry_checker/qgsgeometrycheckregistry.h
  35. +8 −7 src/analysis/vector/geometry_checker/qgsgeometrycontainedcheck.cpp
  36. +18 −8 src/analysis/vector/geometry_checker/qgsgeometrycontainedcheck.h
  37. +15 −5 src/analysis/vector/geometry_checker/qgsgeometrydanglecheck.cpp
  38. +15 −6 src/analysis/vector/geometry_checker/qgsgeometrydanglecheck.h
  39. +16 −6 src/analysis/vector/geometry_checker/qgsgeometrydegeneratepolygoncheck.cpp
  40. +18 −7 src/analysis/vector/geometry_checker/qgsgeometrydegeneratepolygoncheck.h
  41. +19 −8 src/analysis/vector/geometry_checker/qgsgeometryduplicatecheck.cpp
  42. +19 −7 src/analysis/vector/geometry_checker/qgsgeometryduplicatecheck.h
  43. +14 −5 src/analysis/vector/geometry_checker/qgsgeometryduplicatenodescheck.cpp
  44. +13 −6 src/analysis/vector/geometry_checker/qgsgeometryduplicatenodescheck.h
  45. +17 −6 src/analysis/vector/geometry_checker/qgsgeometryfollowboundariescheck.cpp
  46. +12 −5 src/analysis/vector/geometry_checker/qgsgeometryfollowboundariescheck.h
  47. +77 −16 src/analysis/vector/geometry_checker/qgsgeometrygapcheck.cpp
  48. +23 −11 src/analysis/vector/geometry_checker/qgsgeometrygapcheck.h
  49. +10 −6 src/analysis/vector/geometry_checker/qgsgeometryholecheck.cpp
  50. +13 −6 src/analysis/vector/geometry_checker/qgsgeometryholecheck.h
  51. +91 −0 src/analysis/vector/geometry_checker/qgsgeometryisvalidcheck.cpp
  52. +51 −0 src/analysis/vector/geometry_checker/qgsgeometryisvalidcheck.h
  53. +16 −5 src/analysis/vector/geometry_checker/qgsgeometrylineintersectioncheck.cpp
  54. +13 −6 src/analysis/vector/geometry_checker/qgsgeometrylineintersectioncheck.h
  55. +16 −5 src/analysis/vector/geometry_checker/qgsgeometrylinelayerintersectioncheck.cpp
  56. +14 −6 src/analysis/vector/geometry_checker/qgsgeometrylinelayerintersectioncheck.h
  57. +73 −11 src/analysis/vector/geometry_checker/qgsgeometrymissingvertexcheck.cpp
  58. +26 −9 src/analysis/vector/geometry_checker/qgsgeometrymissingvertexcheck.h
  59. +4 −4 src/analysis/vector/geometry_checker/qgsgeometrymultipartcheck.cpp
  60. +14 −6 src/analysis/vector/geometry_checker/qgsgeometrymultipartcheck.h
  61. +80 −11 src/analysis/vector/geometry_checker/qgsgeometryoverlapcheck.cpp
  62. +24 −15 src/analysis/vector/geometry_checker/qgsgeometryoverlapcheck.h
  63. +16 −5 src/analysis/vector/geometry_checker/qgsgeometrypointcoveredbylinecheck.cpp
  64. +13 −6 src/analysis/vector/geometry_checker/qgsgeometrypointcoveredbylinecheck.h
  65. +14 −5 src/analysis/vector/geometry_checker/qgsgeometrypointinpolygoncheck.cpp
  66. +13 −6 src/analysis/vector/geometry_checker/qgsgeometrypointinpolygoncheck.h
  67. +16 −7 src/analysis/vector/geometry_checker/qgsgeometrysegmentlengthcheck.cpp
  68. +14 −7 src/analysis/vector/geometry_checker/qgsgeometrysegmentlengthcheck.h
  69. +9 −3 src/analysis/vector/geometry_checker/qgsgeometryselfcontactcheck.cpp
  70. +13 −6 src/analysis/vector/geometry_checker/qgsgeometryselfcontactcheck.h
  71. +34 −5 src/analysis/vector/geometry_checker/qgsgeometryselfintersectioncheck.cpp
  72. +27 −7 src/analysis/vector/geometry_checker/qgsgeometryselfintersectioncheck.h
  73. +1 −1 src/analysis/vector/geometry_checker/qgsgeometrysliverpolygoncheck.cpp
  74. +14 −8 src/analysis/vector/geometry_checker/qgsgeometrysliverpolygoncheck.h
  75. +36 −5 src/analysis/vector/geometry_checker/qgsgeometrytypecheck.cpp
  76. +16 −7 src/analysis/vector/geometry_checker/qgsgeometrytypecheck.h
  77. +8 −9 src/analysis/vector/geometry_checker/qgssinglegeometrycheck.cpp
  78. +13 −7 src/analysis/vector/geometry_checker/qgssinglegeometrycheck.h
  79. +149 −0 src/analysis/vector/geometry_checker/qgsvectorlayerfeaturepool.cpp
  80. +41 −0 src/analysis/vector/geometry_checker/qgsvectorlayerfeaturepool.h
  81. +6 −2 src/plugins/geometry_checker/qgsgeometrycheckerfixsummarydialog.cpp
  82. +1 −0 src/plugins/geometry_checker/qgsgeometrycheckerfixsummarydialog.h
  83. +24 −21 src/plugins/geometry_checker/qgsgeometrycheckerresulttab.cpp
  84. +3 −2 src/plugins/geometry_checker/qgsgeometrycheckersetuptab.cpp
  85. +59 −42 src/plugins/geometry_checker/qgsgeometrycheckfactory.cpp
  86. +3 −3 src/plugins/geometry_checker/qgsgeometrycheckfactory.h
  87. +10 −10 src/plugins/geometry_checker/qgsgeometrycheckfixdialog.cpp
  88. +172 −150 tests/src/geometry_checker/testqgsgeometrychecks.cpp
@@ -243,12 +243,15 @@ ENDIF (WITH_SERVER AND WITH_SERVER_PLUGINS)

# additional analysis includes
INCLUDE_DIRECTORIES(BEFORE
../src/analysis/processing
../src/analysis/vector
../src/analysis/raster
../src/analysis/network
../src/analysis/interpolation
../src/analysis/openstreetmap
${CMAKE_SOURCE_DIR}/src/analysis
${CMAKE_SOURCE_DIR}/src/analysis/processing
${CMAKE_SOURCE_DIR}/src/analysis/vector
${CMAKE_SOURCE_DIR}/src/analysis/vector/geometry_checker
${CMAKE_SOURCE_DIR}/src/analysis/raster
${CMAKE_SOURCE_DIR}/src/analysis/network
${CMAKE_SOURCE_DIR}/src/analysis/interpolation
${CMAKE_SOURCE_DIR}/src/analysis/openstreetmap

${CMAKE_BINARY_DIR}/src/analysis/processing
${CMAKE_BINARY_DIR}/src/analysis/vector
${CMAKE_BINARY_DIR}/src/analysis/raster
@@ -1,4 +1,5 @@
// Include auto-generated SIP files
%Include auto_generated/qgsanalysis.sip
%Include auto_generated/raster/qgsalignraster.sip
%Include auto_generated/raster/qgsaspectfilter.sip
%Include auto_generated/raster/qgsderivativefilter.sip
@@ -15,6 +16,8 @@
%Include auto_generated/vector/qgsgeometrysnapper.sip
%Include auto_generated/vector/qgsgeometrysnappersinglesource.sip
%Include auto_generated/vector/qgszonalstatistics.sip
%Include auto_generated/vector/geometry_checker/qgsgeometrycheckerutils.sip
%Include auto_generated/vector/geometry_checker/qgsfeaturepool.sip
%Include auto_generated/interpolation/qgsinterpolator.sip
%Include auto_generated/interpolation/qgsgridfilewriter.sip
%Include auto_generated/interpolation/qgsidwinterpolator.sip
@@ -27,5 +30,11 @@
%Include auto_generated/network/qgsnetworkdistancestrategy.sip
%Include auto_generated/network/qgsgraphanalyzer.sip
%Include auto_generated/network/qgsvectorlayerdirector.sip
%Include auto_generated/vector/geometry_checker/qgsgeometrycheckerror.sip
%Include auto_generated/vector/geometry_checker/qgsgeometrycheckcontext.sip
%Include auto_generated/vector/geometry_checker/qgssinglegeometrycheck.sip
%Include auto_generated/vector/geometry_checker/qgsgeometrycheckregistry.sip
%Include auto_generated/vector/geometry_checker/qgsgeometrycheckfactory.sip
%Include auto_generated/processing/qgsnativealgorithms.sip
%Include auto_generated/network/qgsgraphdirector.sip
%Include auto_generated/vector/geometry_checker/qgsgeometrycheck.sip
@@ -0,0 +1,3 @@
# The following has been generated automatically from src/analysis/vector/geometry_checker/qgsgeometrycheck.h
QgsGeometryCheck.Flags.baseClass = QgsGeometryCheck
Flags = QgsGeometryCheck # dirty hack since SIP seems to introduce the flags in module
@@ -0,0 +1,50 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/analysis/qgsanalysis.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/






class QgsAnalysis
{
%Docstring
QgsAnalysis is a singleton class containing various registry and other global members
related to analysis classes.

.. versionadded:: 3.4
%End

%TypeHeaderCode
#include "qgsanalysis.h"
%End
public:



static QgsAnalysis *instance();
%Docstring
Returns a pointer to the singleton instance.
%End

static QgsGeometryCheckRegistry *geometryCheckRegistry();
%Docstring
Returns the global geometry checker registry, used for managing all geometry check factories.
%End

private:
QgsAnalysis( const QgsAnalysis &other );
};

/************************************************************************
* This file has been generated automatically from *
* *
* src/analysis/qgsanalysis.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -0,0 +1,102 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/analysis/vector/geometry_checker/qgsfeaturepool.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/






class QgsFeaturePool : QgsFeatureSink /Abstract/
{
%Docstring
A feature pool is based on a vector layer and caches features.
%End

%TypeHeaderCode
#include "qgsfeaturepool.h"
%End
public:
QgsFeaturePool( QgsVectorLayer *layer );
virtual ~QgsFeaturePool();

bool getFeature( QgsFeatureId id, QgsFeature &feature );
%Docstring
Retrieve the feature with the specified ``id`` into ``feature``.
It will be retrieved from the cache or from the underlying layer if unavailable.
If the feature is neither available from the cache nor from the layer it will return false.
%End

virtual void updateFeature( QgsFeature &feature ) = 0;
%Docstring
Updates a feature in this pool.
Implementations will update the feature on the layer or on the data provider.
%End

virtual void deleteFeature( QgsFeatureId fid ) = 0;
%Docstring
Removes a feature from this pool.
Implementations will remove the feature from the layer or from the data provider.
%End



QgsVectorLayer *layer() const;
%Docstring
Get a pointer to the underlying layer.
May return a ``None`` if the layer has been deleted.
This must only be called from the main thread.
%End


QString layerId() const;
%Docstring
The layer id of the layer.
%End

QgsWkbTypes::GeometryType geometryType() const;
%Docstring
The geometry type of this layer.
%End

QgsCoordinateReferenceSystem crs() const;
%Docstring
The coordinate reference system of this layer.
%End

protected:

void insertFeature( const QgsFeature &feature );
%Docstring
Inserts a feature into the cache and the spatial index.
To be used by implementations of ``addFeature``.
%End

void refreshCache( const QgsFeature &feature );
%Docstring
Changes a feature in the cache and the spatial index.
To be used by implementations of ``updateFeature``.
%End

void removeFeature( const QgsFeatureId featureId );
%Docstring
Removes a feature from the cache and the spatial index.
To be used by implementations of ``deleteFeature``.
%End


private:
QgsFeaturePool( const QgsFeaturePool &other );
};

/************************************************************************
* This file has been generated automatically from *
* *
* src/analysis/vector/geometry_checker/qgsfeaturepool.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -0,0 +1,180 @@
/************************************************************************
* 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
*************************************************************************
qgsgeometrycheck.h
---------------------
begin : September 2014
copyright : (C) 2014 by Sandro Mani / Sourcepole AG
email : smani at sourcepole dot 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. *

**************************************************************************
%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( ChangeWhat _what, ChangeType _type, QgsVertexId _vidx = QgsVertexId() );
%Docstring
Create a new Change
%End

ChangeWhat what;

ChangeType type;

QgsVertexId vidx;
bool operator==( const Change &other );
};

typedef QMap<QString, QMap<QgsFeatureId, QList<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 = 0, 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 *
************************************************************************/

0 comments on commit 0319e36

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