Skip to content

Commit

Permalink
Python bindings for QgsGeometryCheck and co
Browse files Browse the repository at this point in the history
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 bee5470
Show file tree
Hide file tree
Showing 90 changed files with 3,534 additions and 1,388 deletions.
15 changes: 9 additions & 6 deletions python/CMakeLists.txt
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
@@ -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
@@ -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
52 changes: 52 additions & 0 deletions python/analysis/auto_generated/qgsanalysis.sip.in
@@ -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.