Skip to content

Commit

Permalink
sipify analysis vector
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Jun 21, 2017
1 parent 009e47e commit 537ef07
Show file tree
Hide file tree
Showing 7 changed files with 269 additions and 128 deletions.
197 changes: 118 additions & 79 deletions python/analysis/vector/qgsgeometryanalyzer.sip
@@ -1,104 +1,143 @@
/** \ingroup analysis
* The Qgis class provides vector geometry analysis functions
*/
/************************************************************************
* This file has been generated automatically from *
* *
* src/analysis/vector/qgsgeometryanalyzer.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/






class QgsGeometryAnalyzer
{
%TypeHeaderCode
#include <qgsgeometryanalyzer.h>
%Docstring
The QGis class provides vector geometry analysis functions
%End

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

/** Simplify vector layer using (a modified) Douglas-Peucker algorithm
* and write it to a new shape file
* @param layer input vector layer
* @param shapefileName path to the output shp
* @param tolerance (level of simplification)
* @param onlySelectedFeatures if true, only selected features are considered, else all the features
* @param p progress dialog (or 0 if no progress dialog is to be shown)
*/
bool simplify( QgsVectorLayer* layer, const QString& shapefileName, double tolerance,
bool simplify( QgsVectorLayer *layer, const QString &shapefileName, double tolerance,
bool onlySelectedFeatures = false, QProgressDialog *p = 0 );
%Docstring
Simplify vector layer using (a modified) Douglas-Peucker algorithm
and write it to a new shape file
\param layer input vector layer
\param shapefileName path to the output shp
\param tolerance (level of simplification)
\param onlySelectedFeatures if true, only selected features are considered, else all the features
\param p progress dialog (or 0 if no progress dialog is to be shown)
:rtype: bool
%End

/** Calculate the true centroids, or 'center of mass' for a vector layer and
* write it to a new shape file
* @param layer input vector layer
* @param shapefileName path to the output shp
* @param onlySelectedFeatures if true, only selected features are considered, else all the features
* @param p progress dialog (or 0 if no progress dialog is to be shown)
*/
bool centroids( QgsVectorLayer* layer, const QString& shapefileName,
bool centroids( QgsVectorLayer *layer, const QString &shapefileName,
bool onlySelectedFeatures = false, QProgressDialog *p = 0 );
%Docstring
Calculate the true centroids, or 'center of mass' for a vector layer and
write it to a new shape file
\param layer input vector layer
\param shapefileName path to the output shp
\param onlySelectedFeatures if true, only selected features are considered, else all the features
\param p progress dialog (or 0 if no progress dialog is to be shown)
:rtype: bool
%End

/** Create a polygon based on the extent of all (selected) features and write it to a new shape file
* @param layer input vector layer
* @param shapefileName path to the output shp
* @param onlySelectedFeatures if true, only selected features are considered, else all the features
* @param p progress dialog (or 0 if no progress dialog is to be shown)
*/
bool extent( QgsVectorLayer *layer, const QString &shapefileName, bool onlySelectedFeatures = false, QProgressDialog *p = 0 );
%Docstring
Create a polygon based on the extent of all (selected) features and write it to a new shape file
\param layer input vector layer
\param shapefileName path to the output shp
\param onlySelectedFeatures if true, only selected features are considered, else all the features
\param p progress dialog (or 0 if no progress dialog is to be shown)
:rtype: bool
%End

/** Create buffers for a vector layer and write it to a new shape file
* @param layer input vector layer
* @param shapefileName path to the output shp
* @param bufferDistance distance for buffering (if no buffer field is specified)
* @param onlySelectedFeatures if true, only selected features are considered, else all the features
* @param dissolve if true, merge all the buffers to a big multipolygon
* @param bufferDistanceField index of the attribute field that contains the buffer distance (or -1 if all features have the same buffer distance)
* @param p progress dialog (or 0 if no progress dialog is to be shown)
*/
bool buffer( QgsVectorLayer* layer, const QString& shapefileName, double bufferDistance,
bool buffer( QgsVectorLayer *layer, const QString &shapefileName, double bufferDistance,
bool onlySelectedFeatures = false, bool dissolve = false, int bufferDistanceField = -1, QProgressDialog *p = 0 );
%Docstring
Create buffers for a vector layer and write it to a new shape file
\param layer input vector layer
\param shapefileName path to the output shp
\param bufferDistance distance for buffering (if no buffer field is specified)
\param onlySelectedFeatures if true, only selected features are considered, else all the features
\param dissolve if true, merge all the buffers to a big multipolygon
\param bufferDistanceField index of the attribute field that contains the buffer distance (or -1 if all features have the same buffer distance)
\param p progress dialog (or 0 if no progress dialog is to be shown)
:rtype: bool
%End

/** Create convex hull(s) of a vector layer and write it to a new shape file
* @param layer input vector layer
* @param shapefileName path to the output shp
* @param onlySelectedFeatures if true, only selected features are considered, else all the features
* @param uniqueIdField index of the attribute field that contains the unique convex hull id (or -1 if
* all features have the same buffer distance)
* @param p progress dialog (or 0 if no progress dialog is to be shown)
*/
bool convexHull( QgsVectorLayer* layer, const QString& shapefileName, bool onlySelectedFeatures = false,
bool convexHull( QgsVectorLayer *layer, const QString &shapefileName, bool onlySelectedFeatures = false,
int uniqueIdField = -1, QProgressDialog *p = 0 );
%Docstring
Create convex hull(s) of a vector layer and write it to a new shape file
\param layer input vector layer
\param shapefileName path to the output shp
\param onlySelectedFeatures if true, only selected features are considered, else all the features
\param uniqueIdField index of the attribute field that contains the unique convex hull id (or -1 if
all features have the same buffer distance)
\param p progress dialog (or 0 if no progress dialog is to be shown)
:rtype: bool
%End

/** Dissolve a vector layer and write it to a new shape file
* @param layer input vector layer
* @param shapefileName path to the output shp
* @param onlySelectedFeatures if true, only selected features are considered, else all the features
* @param uniqueIdField index of the attribute field that contains the unique id to dissolve on (or -1 if
* all features should be dissolved together)
* @param p progress dialog (or 0 if no progress dialog is to be shown)
*/
bool dissolve( QgsVectorLayer* layer, const QString& shapefileName, bool onlySelectedFeatures = false,
bool dissolve( QgsVectorLayer *layer, const QString &shapefileName, bool onlySelectedFeatures = false,
int uniqueIdField = -1, QProgressDialog *p = 0 );
%Docstring
Dissolve a vector layer and write it to a new shape file
\param layer input vector layer
\param shapefileName path to the output shp
\param onlySelectedFeatures if true, only selected features are considered, else all the features
\param uniqueIdField index of the attribute field that contains the unique id to dissolve on (or -1 if
all features should be dissolved together)
\param p progress dialog (or 0 if no progress dialog is to be shown)
:rtype: bool
%End

/** Creates an event layer (multipoint or multiline) by locating features from a (non-spatial) event table along the features of a line layer.
* Note that currently (until QgsGeometry supports m-values) the z-coordinate of the line layer is used for linear referencing
* @param lineLayer layer with the line geometry
* @param eventLayer layer with features and location field
* @param lineField join index in line layer
* @param eventField join index in event layer
* @param outputLayer name of output file (can be empty if a memory layer is used)
* @param outputFormat name of output format (can be empty if a memory provider is used to store the results)
* @param unlocatedFeatureIds out: ids of event features where linear referencing was not successful
* @param locationField1 attribute index of location field in event layer
* @param locationField2 attribute index of location end field (or -1 for point layer)
* @param offsetField attribute index for offset field. Negative offset value = offset to left side, positive value = offset to right side
* @param offsetScale factor to scale offset
* @param forceSingleGeometry force layer to single point/line type. Feature attributes are copied in case of multiple matches
* @param memoryProvider memory provider to write output to (can be 0 if output is written to a file)
* @param p progress dialog or 0 if no progress dialog should be shown
*/
bool eventLayer( QgsVectorLayer* lineLayer, QgsVectorLayer* eventLayer, int lineField, int eventField, QSet<qint64> &unlocatedFeatureIds /Out/, const QString& outputLayer,
const QString& outputFormat, int locationField1, int locationField2 = -1, int offsetField = -1, double offsetScale = 1.0,
bool eventLayer( QgsVectorLayer *lineLayer, QgsVectorLayer *eventLayer, int lineField, int eventField, QgsFeatureIds &unlocatedFeatureIds /Out/, const QString &outputLayer,
const QString &outputFormat, int locationField1, int locationField2 = -1, int offsetField = -1, double offsetScale = 1.0,
bool forceSingleGeometry = false, QgsVectorDataProvider *memoryProvider = 0, QProgressDialog *p = 0 );
%Docstring
Creates an event layer (multipoint or multiline) by locating features from a (non-spatial) event table along the features of a line layer.
Note that currently (until QgsGeometry supports m-values) the z-coordinate of the line layer is used for linear referencing
\param lineLayer layer with the line geometry
\param eventLayer layer with features and location field
\param lineField join index in line layer
\param eventField join index in event layer
\param outputLayer name of output file (can be empty if a memory layer is used)
\param outputFormat name of output format (can be empty if a memory provider is used to store the results)
\param unlocatedFeatureIds out: ids of event features where linear referencing was not successful
\param locationField1 attribute index of location field in event layer
\param locationField2 attribute index of location end field (or -1 for point layer)
\param offsetField attribute index for offset field. Negative offset value = offset to left side, positive value = offset to right side
\param offsetScale factor to scale offset
\param forceSingleGeometry force layer to single point/line type. Feature attributes are copied in case of multiple matches
\param memoryProvider memory provider to write output to (can be 0 if output is written to a file)
\param p progress dialog or 0 if no progress dialog should be shown
:rtype: bool
%End

/** Returns linear reference geometry as a multiline (or 0 if no match). Currently, the z-coordinates are considered to be the measures (no support for m-values in QGIS)*/
QgsGeometry locateBetweenMeasures( double fromMeasure, double toMeasure, const QgsGeometry &lineGeom );
/** Returns linear reference geometry. Unlike the PostGIS function, this method always returns multipoint or 0 if no match (not geometry collection).
* Currently, the z-coordinates are considered to be the measures (no support for m-values in QGIS)
*/
%Docstring
Returns linear reference geometry as a multiline (or 0 if no match). Currently, the z-coordinates are considered to be the measures (no support for m-values in QGIS)
:rtype: QgsGeometry
%End

QgsGeometry locateAlongMeasure( double measure, const QgsGeometry &lineGeom );
%Docstring
Returns linear reference geometry. Unlike the PostGIS function, this method always returns multipoint or 0 if no match (not geometry collection).
Currently, the z-coordinates are considered to be the measures (no support for m-values in QGIS)
:rtype: QgsGeometry
%End

};
/************************************************************************
* This file has been generated automatically from *
* *
* src/analysis/vector/qgsgeometryanalyzer.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
116 changes: 87 additions & 29 deletions python/analysis/vector/qgsgeometrysnapper.sip
@@ -1,21 +1,29 @@
/**
* \class QgsGeometrySnapper
* \ingroup analysis
* QgsGeometrySnapper allows a geometry to be snapped to the geometries within a
* different reference layer. Vertices in the geometries will be modified to
* match the reference layer features within a specified snap tolerance.
* \note added in QGIS 3.0
*/
/************************************************************************
* This file has been generated automatically from *
* *
* src/analysis/vector/qgsgeometrysnapper.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/





class QgsGeometrySnapper : QObject
{
%TypeHeaderCode
#include <qgsgeometrysnapper.h>
%Docstring
QgsGeometrySnapper allows a geometry to be snapped to the geometries within a
different reference layer. Vertices in the geometries will be modified to
match the reference layer features within a specified snap tolerance.
.. versionadded:: 3.0
%End

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

//! Snapping modes
enum SnapMode
{
PreferNodes,
Expand All @@ -25,42 +33,92 @@ class QgsGeometrySnapper : QObject
EndPointToEndPoint,
};

/**
* Constructor for QgsGeometrySnapper. A reference layer which contains geometries to snap to must be
* set. It is assumed that all geometries snapped using this object will have the
* same CRS as the reference layer (ie, no reprojection is performed).
*/
QgsGeometrySnapper( QgsVectorLayer *referenceLayer );
%Docstring
Constructor for QgsGeometrySnapper. A reference layer which contains geometries to snap to must be
set. It is assumed that all geometries snapped using this object will have the
same CRS as the reference layer (ie, no reprojection is performed).
%End

/**
* Snaps a geometry to the reference layer and returns the result. The geometry must be in the same
* CRS as the reference layer, and must have the same type as the reference layer geometry. The snap tolerance
* is specified in the layer units for the reference layer.
*/
QgsGeometry snapGeometry( const QgsGeometry &geometry, double snapTolerance, SnapMode mode = PreferNodes ) const;
%Docstring
Snaps a geometry to the reference layer and returns the result. The geometry must be in the same
CRS as the reference layer, and must have the same type as the reference layer geometry. The snap tolerance
is specified in the layer units for the reference layer.
:rtype: QgsGeometry
%End

/**
* Snaps a set of features to the reference layer and returns the result. This operation is
* multithreaded for performance. The featureSnapped() signal will be emitted each time a feature
* is processed. The snap tolerance is specified in the layer units for the reference layer.
*/
QgsFeatureList snapFeatures( const QgsFeatureList &features, double snapTolerance, SnapMode mode = PreferNodes );
%Docstring
Snaps a set of features to the reference layer and returns the result. This operation is
multithreaded for performance. The featureSnapped() signal will be emitted each time a feature
is processed. The snap tolerance is specified in the layer units for the reference layer.
:rtype: QgsFeatureList
%End

static QgsGeometry snapGeometry( const QgsGeometry &geometry, double snapTolerance, const QList<QgsGeometry> &referenceGeometries, SnapMode mode = PreferNodes );
%Docstring
Snaps a single geometry against a list of reference geometries.
:rtype: QgsGeometry
%End

signals:

//! Emitted each time a feature has been processed when calling snapFeatures()
void featureSnapped();
%Docstring
Emitted each time a feature has been processed when calling snapFeatures()
%End

};


class QgsInternalGeometrySnapper
{
%TypeHeaderCode
#include <qgsgeometrysnapper.h>
%Docstring
QgsInternalGeometrySnapper allows a set of geometries to be snapped to each other. It can be used to close gaps in layers.

To use QgsInternalGeometrySnapper, first construct the snapper using the desired snap parameters. Then,
features are fed to to the snapper one-by-one by calling snapFeature(). Each feature passed by calling
snapFeature() will be snapped to any features which have already been processed by the snapper.

After processing all desired features, the results can be fetched by calling snappedGeometries().
The returned QgsGeometryMap can be passed to QgsVectorDataProvider.changeGeometryValues() to save
the snapped geometries back to the source layer.

.. versionadded:: 3.0
%End

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

QgsInternalGeometrySnapper( double snapTolerance, QgsGeometrySnapper::SnapMode mode = QgsGeometrySnapper::PreferNodes );
%Docstring
Constructor for QgsInternalGeometrySnapper. The ``snapTolerance`` and ``mode`` parameters dictate
how geometries will be snapped by the snapper.
%End

QgsGeometry snapFeature( const QgsFeature &feature );
%Docstring
Snaps a single feature's geometry against all feature geometries already processed by
calls to snapFeature() in this object, and returns the snapped geometry.
:rtype: QgsGeometry
%End

QgsGeometryMap snappedGeometries() const;
%Docstring
Returns a QgsGeometryMap of all feature geometries snapped by this object.
:rtype: QgsGeometryMap
%End

};


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

0 comments on commit 537ef07

Please sign in to comment.