Skip to content

Commit

Permalink
Merge pull request #8054 from m-kuhn/geometryCheckPyBindings
Browse files Browse the repository at this point in the history
Python bindings for QgsGeometryCheck and co
  • Loading branch information
m-kuhn authored Oct 3, 2018
2 parents f4bc24c + 7a99fa2 commit 0319e36
Show file tree
Hide file tree
Showing 88 changed files with 3,958 additions and 1,325 deletions.
15 changes: 9 additions & 6 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions python/analysis/analysis_auto.sip
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
3 changes: 3 additions & 0 deletions python/analysis/auto_additions/qgsgeometrycheck.py
Original file line number Diff line number Diff line change
@@ -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
50 changes: 50 additions & 0 deletions python/analysis/auto_generated/qgsanalysis.sip.in
Original file line number Diff line number Diff line change
@@ -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 *
************************************************************************/
Original file line number Diff line number Diff line change
@@ -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 *
************************************************************************/
Original file line number Diff line number Diff line change
@@ -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 *
************************************************************************/
Loading

0 comments on commit 0319e36

Please sign in to comment.