Skip to content
Permalink
Browse files

Python bindings for QgsGeometryCheck and co

Adds

 - python bindings
 - geometry check factory
 - geometry check registry
 - QgsFeedback for geometry checks (lots of potential still)
 - An IsValid geometry check
 - Splits classes into their own files
 - Decouples feature pools from the configuration context
  • Loading branch information
m-kuhn committed Sep 28, 2018
1 parent 1a61885 commit bee5470e108d867e6287a2bcdabca2fd0c0b4f70
Showing with 3,534 additions and 1,388 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. +52 −0 python/analysis/auto_generated/qgsanalysis.sip.in
  5. +102 −0 python/analysis/auto_generated/vector/geometry_checker/qgsfeaturepool.sip.in
  6. +119 −0 python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheck.sip.in
  7. +31 −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. +63 −0 python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheckfactory.sip.in
  11. +57 −0 python/analysis/auto_generated/vector/geometry_checker/qgsgeometrycheckregistry.sip.in
  12. +37 −0 python/analysis/auto_generated/vector/geometry_checker/qgsisvalidgeometrycheck.sip.in
  13. +142 −0 python/analysis/auto_generated/vector/geometry_checker/qgssinglegeometrycheck.sip.in
  14. +25 −5 src/analysis/CMakeLists.txt
  15. +53 −0 src/analysis/qgsanalysis.cpp
  16. +68 −0 src/analysis/qgsanalysis.h
  17. +12 −7 src/analysis/vector/geometry_checker/qgsfeaturepool.h
  18. +8 −5 src/analysis/vector/geometry_checker/qgsgeometryanglecheck.cpp
  19. +12 −7 src/analysis/vector/geometry_checker/qgsgeometryanglecheck.h
  20. +19 −14 src/analysis/vector/geometry_checker/qgsgeometryareacheck.cpp
  21. +14 −11 src/analysis/vector/geometry_checker/qgsgeometryareacheck.h
  22. +36 −207 src/analysis/vector/geometry_checker/qgsgeometrycheck.cpp
  23. +70 −121 src/analysis/vector/geometry_checker/qgsgeometrycheck.h
  24. +27 −0 src/analysis/vector/geometry_checker/qgsgeometrycheckcontext.cpp
  25. +41 −0 src/analysis/vector/geometry_checker/qgsgeometrycheckcontext.h
  26. +24 −21 src/analysis/vector/geometry_checker/qgsgeometrychecker.cpp
  27. +12 −7 src/analysis/vector/geometry_checker/qgsgeometrychecker.h
  28. +190 −0 src/analysis/vector/geometry_checker/qgsgeometrycheckerror.cpp
  29. +116 −0 src/analysis/vector/geometry_checker/qgsgeometrycheckerror.h
  30. +258 −256 src/analysis/vector/geometry_checker/qgsgeometrycheckerutils.cpp
  31. +163 −150 src/analysis/vector/geometry_checker/qgsgeometrycheckerutils.h
  32. 0 src/analysis/vector/geometry_checker/qgsgeometrycheckfactory.cpp
  33. +92 −0 src/analysis/vector/geometry_checker/qgsgeometrycheckfactory.h
  34. +59 −0 src/analysis/vector/geometry_checker/qgsgeometrycheckregistry.cpp
  35. +72 −0 src/analysis/vector/geometry_checker/qgsgeometrycheckregistry.h
  36. +8 −7 src/analysis/vector/geometry_checker/qgsgeometrycontainedcheck.cpp
  37. +14 −7 src/analysis/vector/geometry_checker/qgsgeometrycontainedcheck.h
  38. +10 −5 src/analysis/vector/geometry_checker/qgsgeometrydanglecheck.cpp
  39. +11 −6 src/analysis/vector/geometry_checker/qgsgeometrydanglecheck.h
  40. +11 −6 src/analysis/vector/geometry_checker/qgsgeometrydegeneratepolygoncheck.cpp
  41. +11 −6 src/analysis/vector/geometry_checker/qgsgeometrydegeneratepolygoncheck.h
  42. +9 −8 src/analysis/vector/geometry_checker/qgsgeometryduplicatecheck.cpp
  43. +15 −7 src/analysis/vector/geometry_checker/qgsgeometryduplicatecheck.h
  44. +9 −5 src/analysis/vector/geometry_checker/qgsgeometryduplicatenodescheck.cpp
  45. +11 −6 src/analysis/vector/geometry_checker/qgsgeometryduplicatenodescheck.h
  46. +12 −6 src/analysis/vector/geometry_checker/qgsgeometryfollowboundariescheck.cpp
  47. +10 −5 src/analysis/vector/geometry_checker/qgsgeometryfollowboundariescheck.h
  48. +70 −15 src/analysis/vector/geometry_checker/qgsgeometrygapcheck.cpp
  49. +21 −11 src/analysis/vector/geometry_checker/qgsgeometrygapcheck.h
  50. +10 −6 src/analysis/vector/geometry_checker/qgsgeometryholecheck.cpp
  51. +11 −6 src/analysis/vector/geometry_checker/qgsgeometryholecheck.h
  52. +11 −5 src/analysis/vector/geometry_checker/qgsgeometrylineintersectioncheck.cpp
  53. +11 −6 src/analysis/vector/geometry_checker/qgsgeometrylineintersectioncheck.h
  54. +11 −5 src/analysis/vector/geometry_checker/qgsgeometrylinelayerintersectioncheck.cpp
  55. +12 −6 src/analysis/vector/geometry_checker/qgsgeometrylinelayerintersectioncheck.h
  56. +61 −9 src/analysis/vector/geometry_checker/qgsgeometrymissingvertexcheck.cpp
  57. +24 −9 src/analysis/vector/geometry_checker/qgsgeometrymissingvertexcheck.h
  58. +4 −4 src/analysis/vector/geometry_checker/qgsgeometrymultipartcheck.cpp
  59. +13 −6 src/analysis/vector/geometry_checker/qgsgeometrymultipartcheck.h
  60. +70 −11 src/analysis/vector/geometry_checker/qgsgeometryoverlapcheck.cpp
  61. +23 −15 src/analysis/vector/geometry_checker/qgsgeometryoverlapcheck.h
  62. +11 −5 src/analysis/vector/geometry_checker/qgsgeometrypointcoveredbylinecheck.cpp
  63. +11 −6 src/analysis/vector/geometry_checker/qgsgeometrypointcoveredbylinecheck.h
  64. +9 −5 src/analysis/vector/geometry_checker/qgsgeometrypointinpolygoncheck.cpp
  65. +11 −6 src/analysis/vector/geometry_checker/qgsgeometrypointinpolygoncheck.h
  66. +11 −7 src/analysis/vector/geometry_checker/qgsgeometrysegmentlengthcheck.cpp
  67. +12 −7 src/analysis/vector/geometry_checker/qgsgeometrysegmentlengthcheck.h
  68. +4 −3 src/analysis/vector/geometry_checker/qgsgeometryselfcontactcheck.cpp
  69. +11 −6 src/analysis/vector/geometry_checker/qgsgeometryselfcontactcheck.h
  70. +29 −5 src/analysis/vector/geometry_checker/qgsgeometryselfintersectioncheck.cpp
  71. +24 −7 src/analysis/vector/geometry_checker/qgsgeometryselfintersectioncheck.h
  72. +1 −1 src/analysis/vector/geometry_checker/qgsgeometrysliverpolygoncheck.cpp
  73. +14 −8 src/analysis/vector/geometry_checker/qgsgeometrysliverpolygoncheck.h
  74. +26 −5 src/analysis/vector/geometry_checker/qgsgeometrytypecheck.cpp
  75. +14 −7 src/analysis/vector/geometry_checker/qgsgeometrytypecheck.h
  76. +51 −0 src/analysis/vector/geometry_checker/qgsisvalidgeometrycheck.cpp
  77. +48 −0 src/analysis/vector/geometry_checker/qgsisvalidgeometrycheck.h
  78. +8 −9 src/analysis/vector/geometry_checker/qgssinglegeometrycheck.cpp
  79. +14 −7 src/analysis/vector/geometry_checker/qgssinglegeometrycheck.h
  80. +149 −0 src/analysis/vector/geometry_checker/qgsvectorlayerfeaturepool.cpp
  81. +41 −0 src/analysis/vector/geometry_checker/qgsvectorlayerfeaturepool.h
  82. +6 −2 src/plugins/geometry_checker/qgsgeometrycheckerfixsummarydialog.cpp
  83. +1 −0 src/plugins/geometry_checker/qgsgeometrycheckerfixsummarydialog.h
  84. +16 −14 src/plugins/geometry_checker/qgsgeometrycheckerresulttab.cpp
  85. +3 −2 src/plugins/geometry_checker/qgsgeometrycheckersetuptab.cpp
  86. +59 −42 src/plugins/geometry_checker/qgsgeometrycheckfactory.cpp
  87. +3 −3 src/plugins/geometry_checker/qgsgeometrycheckfactory.h
  88. +10 −10 src/plugins/geometry_checker/qgsgeometrycheckfixdialog.cpp
  89. +90 −66 src/ui/qgsvectorlayerpropertiesbase.ui
  90. +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,52 @@
/************************************************************************
* 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:



~QgsAnalysis();

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,119 @@
/************************************************************************
* 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
{
SingleGeometryCheck,
SingleLayerTopologyCheck,
AvailableInValidation
};
typedef QFlags<QgsGeometryCheck::Flag> Flags;


struct Change
{
Change();
Change( ChangeWhat _what, ChangeType _type, QgsVertexId _vidx = QgsVertexId() );
ChangeWhat what;
ChangeType type;
QgsVertexId vidx;
bool operator==( const Change &other );
};

typedef QMap<QString, QMap<QgsFeatureId, QList<Change> > > Changes;

QgsGeometryCheck( CheckType checkType,
const QgsGeometryCheckContext *context,
const QVariantMap &configuration );
virtual ~QgsGeometryCheck();


virtual bool isCompatible( QgsVectorLayer *layer ) const;
virtual QList<QgsWkbTypes::GeometryType> compatibleGeometryTypes() const = 0;
virtual QgsGeometryCheck::Flags flags() const;

virtual void collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback = 0, const LayerFeatureIds &ids = QgsGeometryCheck::LayerFeatureIds() ) const = 0;
virtual QStringList resolutionMethods() const = 0;
virtual QString description() const = 0;
virtual QString id() const = 0;
CheckType checkType() const;
const QgsGeometryCheckContext *context() const;

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,0 +1,31 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/analysis/vector/geometry_checker/qgsgeometrycheckcontext.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/



struct QgsGeometryCheckContext
{
QgsGeometryCheckContext( int precision,
const QgsCoordinateReferenceSystem &mapCrs,
const QgsCoordinateTransformContext &transformContext );
const double tolerance;
const double reducedTolerance;
const QgsCoordinateReferenceSystem mapCrs;
const QgsCoordinateTransformContext transformContext;

private:
QgsGeometryCheckContext( const QgsGeometryCheckContext &rh );
};

/************************************************************************
* This file has been generated automatically from *
* *
* src/analysis/vector/geometry_checker/qgsgeometrycheckcontext.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/

0 comments on commit bee5470

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