mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Merge pull request #4993 from nyalldawson/remove_analyzer
Remove QgsGeometryAnalyzer, QgsOverlayAnalyzer, QgsPointSample
This commit is contained in:
commit
5abbab1a11
@ -269,6 +269,7 @@ should now call QgsCoordinateReferenceSystem::invalidateCache() and QgsCoordinat
|
||||
- QgsFileNameWidgetWrapper was removed. Use QgsExternalResourceWidgetWrapper instead.
|
||||
- QgsFileDropEdit was removed. Use QgsFileWidget instead.
|
||||
- QgsFormAnnotationItem. Use QgsFormAnnotation instead.
|
||||
- QgsGeometryAnalyzer. Use the equivalent Processing algorithms instead.
|
||||
- QgsHtmlAnnotationItem. Use QgsHtmlAnnotation instead.
|
||||
- QgsHttpTransaction. This class was outdated and code should be ported to native Qt or Python implementations.
|
||||
- QgsGenericProjectionSelector. Use QgsProjectionSelectionTreeWidget instead.
|
||||
@ -287,6 +288,7 @@ should now call QgsCoordinateReferenceSystem::invalidateCache() and QgsCoordinat
|
||||
- QgsMapRenderer. It has been replaced by QgsMapRendererJob with subclasses and QgsMapSettings.
|
||||
- QgsMapToolTouch. The touch navigation functionality is now built into the standard QgsMapToolPan tool.
|
||||
- QgsPhotoWidgetWrapper was removed. Use QgsExternalResourceWidgetWrapper instead.
|
||||
- QgsPointSample. Use the Processing "Random Points in Polygon" algorithm instead.
|
||||
- QgsPseudoColorShader. This shader has been broken for some time and was replaced by QgsSingleBandPseudoColorRenderer.
|
||||
- QgsProjectBadLayerGuiHandler was removed. It was unused in QGIS code and barely useful. Implement your own QgsProjectBadLayerHandler subclass if needed.
|
||||
- QgsRendererV2DataDefinedMenus was removed. Use QgsPropertyOverrideButton instead.
|
||||
|
@ -12,9 +12,6 @@
|
||||
%Include raster/qgsrastermatrix.sip
|
||||
%Include raster/qgsrastercalcnode.sip
|
||||
%Include raster/qgstotalcurvaturefilter.sip
|
||||
%Include vector/qgsgeometryanalyzer.sip
|
||||
%Include vector/qgsoverlayanalyzer.sip
|
||||
%Include vector/qgspointsample.sip
|
||||
%Include vector/qgstransectsample.sip
|
||||
%Include vector/qgszonalstatistics.sip
|
||||
%Include interpolation/qgsinterpolator.sip
|
||||
|
@ -1,143 +0,0 @@
|
||||
/************************************************************************
|
||||
* 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
|
||||
{
|
||||
%Docstring
|
||||
The QGis class provides vector geometry analysis functions
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsgeometryanalyzer.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
QgsGeometry locateBetweenMeasures( double fromMeasure, double toMeasure, const QgsGeometry &lineGeom );
|
||||
%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 *
|
||||
************************************************************************/
|
@ -1,46 +0,0 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/analysis/vector/qgsoverlayanalyzer.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class QgsOverlayAnalyzer
|
||||
{
|
||||
%Docstring
|
||||
The QGis class provides vector overlay analysis functions
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsoverlayanalyzer.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
bool intersection( QgsVectorLayer *layerA, QgsVectorLayer *layerB,
|
||||
const QString &shapefileName, bool onlySelectedFeatures = false,
|
||||
QProgressDialog *p = 0 );
|
||||
%Docstring
|
||||
Perform an intersection on two input vector layers and write output to a new shape file
|
||||
\param layerA input vector layer
|
||||
\param layerB 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
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/analysis/vector/qgsoverlayanalyzer.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -1,38 +0,0 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/analysis/vector/qgspointsample.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
class QgsPointSample
|
||||
{
|
||||
%Docstring
|
||||
Creates random points in polygons / multipolygons*
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgspointsample.h"
|
||||
%End
|
||||
public:
|
||||
QgsPointSample( QgsVectorLayer *inputLayer, const QString &outputLayer, const QString &nPointsAttribute, const QString &minDistAttribute = QString() );
|
||||
|
||||
int createRandomPoints( QProgressDialog *pd );
|
||||
%Docstring
|
||||
Starts calculation of random points
|
||||
:return: 0 in case of success*
|
||||
:rtype: int
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/analysis/vector/qgspointsample.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -35,12 +35,9 @@ SET(QGIS_ANALYSIS_SRCS
|
||||
raster/qgsrastercalculator.cpp
|
||||
raster/qgsrastermatrix.cpp
|
||||
vector/mersenne-twister.cpp
|
||||
vector/qgsgeometryanalyzer.cpp
|
||||
vector/qgsgeometrysnapper.cpp
|
||||
vector/qgspointsample.cpp
|
||||
vector/qgstransectsample.cpp
|
||||
vector/qgszonalstatistics.cpp
|
||||
vector/qgsoverlayanalyzer.cpp
|
||||
|
||||
openstreetmap/qgsosmbase.cpp
|
||||
openstreetmap/qgsosmdatabase.cpp
|
||||
@ -116,9 +113,6 @@ SET(QGIS_ANALYSIS_HDRS
|
||||
raster/qgsrastercalcnode.h
|
||||
raster/qgstotalcurvaturefilter.h
|
||||
|
||||
vector/qgsgeometryanalyzer.h
|
||||
vector/qgsoverlayanalyzer.h
|
||||
vector/qgspointsample.h
|
||||
vector/qgstransectsample.h
|
||||
vector/qgszonalstatistics.h
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,161 +0,0 @@
|
||||
/***************************************************************************
|
||||
qgsgeometryanalyzer.h - QGIS Tools for vector geometry analysis
|
||||
-------------------
|
||||
begin : 19 March 2009
|
||||
copyright : (C) Carson Farmer
|
||||
email : carson.farmer@gmail.com
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* 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. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef QGSGEOMETRYANALYZERH
|
||||
#define QGSGEOMETRYANALYZERH
|
||||
|
||||
#include "qgsfeature.h"
|
||||
#include "qgsgeometry.h"
|
||||
#include "qgis_analysis.h"
|
||||
|
||||
class QgsVectorFileWriter;
|
||||
class QProgressDialog;
|
||||
class QgsVectorDataProvider;
|
||||
class QgsDistanceArea;
|
||||
|
||||
/** \ingroup analysis
|
||||
* The QGis class provides vector geometry analysis functions
|
||||
*/
|
||||
|
||||
class ANALYSIS_EXPORT QgsGeometryAnalyzer
|
||||
{
|
||||
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 onlySelectedFeatures = false, QProgressDialog *p = nullptr );
|
||||
|
||||
/** 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 onlySelectedFeatures = false, QProgressDialog *p = nullptr );
|
||||
|
||||
/** 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 );
|
||||
|
||||
/** 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 onlySelectedFeatures = false, bool dissolve = false, int bufferDistanceField = -1, QProgressDialog *p = nullptr );
|
||||
|
||||
/** 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,
|
||||
int uniqueIdField = -1, QProgressDialog *p = nullptr );
|
||||
|
||||
/** 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,
|
||||
int uniqueIdField = -1, QProgressDialog *p = nullptr );
|
||||
|
||||
/** 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, QgsFeatureIds &unlocatedFeatureIds SIP_OUT, const QString &outputLayer,
|
||||
const QString &outputFormat, int locationField1, int locationField2 = -1, int offsetField = -1, double offsetScale = 1.0,
|
||||
bool forceSingleGeometry = false, QgsVectorDataProvider *memoryProvider = nullptr, QProgressDialog *p = nullptr );
|
||||
|
||||
//! 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)
|
||||
*/
|
||||
QgsGeometry locateAlongMeasure( double measure, const QgsGeometry &lineGeom );
|
||||
|
||||
private:
|
||||
|
||||
QList<double> simpleMeasure( QgsGeometry &geometry );
|
||||
double perimeterMeasure( const QgsGeometry &geometry, QgsDistanceArea &measure );
|
||||
//! Helper function to simplify an individual feature
|
||||
void simplifyFeature( QgsFeature &f, QgsVectorFileWriter *vfw, double tolerance );
|
||||
//! Helper function to get the cetroid of an individual feature
|
||||
void centroidFeature( QgsFeature &f, QgsVectorFileWriter *vfw );
|
||||
//! Helper function to buffer an individual feature
|
||||
void bufferFeature( QgsFeature &f, int nProcessedFeatures, QgsVectorFileWriter *vfw, bool dissolve, QgsGeometry &dissolveGeometry,
|
||||
double bufferDistance, int bufferDistanceField );
|
||||
//! Helper function to get the convex hull of feature(s)
|
||||
void convexFeature( QgsFeature &f, int nProcessedFeatures, QgsGeometry &dissolveGeometry );
|
||||
//! Helper function to dissolve feature(s)
|
||||
QgsGeometry dissolveFeature( const QgsFeature &f, const QgsGeometry &dissolveInto );
|
||||
|
||||
//helper functions for event layer
|
||||
void addEventLayerFeature( QgsFeature &feature, const QgsGeometry &geom, const QgsGeometry &lineGeom, QgsVectorFileWriter *fileWriter, QgsFeatureList &memoryFeatures, int offsetField = -1, double offsetScale = 1.0,
|
||||
bool forceSingleType = false );
|
||||
|
||||
/** Create geometry offset relative to line geometry.
|
||||
\param geom the geometry to modify
|
||||
\param lineGeom the line geometry to which the feature is referenced
|
||||
\param offset the offset value in layer unit. Negative values mean offset towards left, positive values offset to the right side*/
|
||||
QgsGeometry createOffsetGeometry( const QgsGeometry &geom, const QgsGeometry &lineGeom, double offset );
|
||||
QgsPointXY createPointOffset( double x, double y, double dist, const QgsGeometry &lineGeom ) const;
|
||||
QgsConstWkbPtr locateBetweenWkbString( QgsConstWkbPtr ptr, QgsMultiPolyline &result, double fromMeasure, double toMeasure );
|
||||
QgsConstWkbPtr locateAlongWkbString( QgsConstWkbPtr ptr, QgsMultiPoint &result, double measure );
|
||||
static bool clipSegmentByRange( double x1, double y1, double m1, double x2, double y2, double m2, double range1, double range2, QgsPointXY &pt1, QgsPointXY &pt2, bool &secondPointClipped );
|
||||
static void locateAlongSegment( double x1, double y1, double m1, double x2, double y2, double m2, double measure, bool &pt1Ok, QgsPointXY &pt1, bool &pt2Ok, QgsPointXY &pt2 );
|
||||
};
|
||||
#endif //QGSVECTORANALYZER
|
@ -1,195 +0,0 @@
|
||||
/***************************************************************************
|
||||
qgsoverlayanalyzer.cpp - QGIS Tools for vector geometry analysis
|
||||
-------------------
|
||||
begin : 8 Nov 2009
|
||||
copyright : (C) Carson J. Q. Farmer
|
||||
email : carson.farmer@gmail.com
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* 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. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "qgsoverlayanalyzer.h"
|
||||
|
||||
#include "qgsapplication.h"
|
||||
#include "qgsfeatureiterator.h"
|
||||
#include "qgsfields.h"
|
||||
#include "qgsfeature.h"
|
||||
#include "qgsgeometry.h"
|
||||
#include "qgslogger.h"
|
||||
#include "qgscoordinatereferencesystem.h"
|
||||
#include "qgsspatialindex.h"
|
||||
#include "qgsvectorfilewriter.h"
|
||||
#include "qgsvectordataprovider.h"
|
||||
#include "qgsdistancearea.h"
|
||||
#include <QProgressDialog>
|
||||
|
||||
bool QgsOverlayAnalyzer::intersection( QgsVectorLayer *layerA, QgsVectorLayer *layerB,
|
||||
const QString &shapefileName, bool onlySelectedFeatures,
|
||||
QProgressDialog *p )
|
||||
{
|
||||
if ( !layerA || !layerB )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QgsVectorDataProvider *dpA = layerA->dataProvider();
|
||||
QgsVectorDataProvider *dpB = layerB->dataProvider();
|
||||
if ( !dpA || !dpB )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QgsWkbTypes::Type outputType = dpA->wkbType();
|
||||
QgsCoordinateReferenceSystem crs = layerA->crs();
|
||||
QgsFields fieldsA = layerA->fields();
|
||||
QgsFields fieldsB = layerB->fields();
|
||||
combineFieldLists( fieldsA, fieldsB );
|
||||
|
||||
QgsVectorFileWriter vWriter( shapefileName, dpA->encoding(), fieldsA, outputType, crs );
|
||||
QgsFeature currentFeature;
|
||||
|
||||
//take only selection
|
||||
if ( onlySelectedFeatures )
|
||||
{
|
||||
QgsFeatureIds selectionB = layerB->selectedFeatureIds();
|
||||
QgsFeatureRequest req = QgsFeatureRequest().setFilterFids( selectionB ).setSubsetOfAttributes( QgsAttributeList() );
|
||||
QgsSpatialIndex index = QgsSpatialIndex( layerB->getFeatures( req ) );
|
||||
|
||||
//use QgsVectorLayer::featureAtId
|
||||
const QgsFeatureIds selectionA = layerA->selectedFeatureIds();
|
||||
if ( p )
|
||||
{
|
||||
p->setMaximum( selectionA.size() );
|
||||
}
|
||||
req = QgsFeatureRequest().setFilterFids( selectionA );
|
||||
QgsFeatureIterator selectionAIt = layerA->getFeatures( req );
|
||||
QgsFeature currentFeature;
|
||||
int processedFeatures = 0;
|
||||
while ( selectionAIt.nextFeature( currentFeature ) )
|
||||
{
|
||||
if ( p )
|
||||
{
|
||||
p->setValue( processedFeatures );
|
||||
}
|
||||
|
||||
if ( p && p->wasCanceled() )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
intersectFeature( currentFeature, &vWriter, layerB, &index );
|
||||
++processedFeatures;
|
||||
}
|
||||
|
||||
if ( p )
|
||||
{
|
||||
p->setValue( selectionA.size() );
|
||||
}
|
||||
}
|
||||
//take all features
|
||||
else
|
||||
{
|
||||
QgsFeatureRequest req = QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList() );
|
||||
QgsSpatialIndex index = QgsSpatialIndex( layerB->getFeatures( req ) );
|
||||
|
||||
int featureCount = layerA->featureCount();
|
||||
if ( p )
|
||||
{
|
||||
p->setMaximum( featureCount );
|
||||
}
|
||||
int processedFeatures = 0;
|
||||
|
||||
QgsFeatureIterator fit = layerA->getFeatures();
|
||||
|
||||
QgsFeature currentFeature;
|
||||
while ( fit.nextFeature( currentFeature ) )
|
||||
{
|
||||
if ( p )
|
||||
{
|
||||
p->setValue( processedFeatures );
|
||||
}
|
||||
if ( p && p->wasCanceled() )
|
||||
{
|
||||
break;
|
||||
}
|
||||
intersectFeature( currentFeature, &vWriter, layerB, &index );
|
||||
++processedFeatures;
|
||||
}
|
||||
if ( p )
|
||||
{
|
||||
p->setValue( featureCount );
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void QgsOverlayAnalyzer::intersectFeature( QgsFeature &f, QgsVectorFileWriter *vfw,
|
||||
QgsVectorLayer *vl, QgsSpatialIndex *index )
|
||||
{
|
||||
if ( !f.hasGeometry() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QgsGeometry featureGeometry = f.geometry();
|
||||
QgsGeometry intersectGeometry;
|
||||
QgsFeature overlayFeature;
|
||||
|
||||
QList<QgsFeatureId> intersects = index->intersects( featureGeometry.boundingBox() );
|
||||
QgsFeatureRequest req = QgsFeatureRequest().setFilterFids( intersects.toSet() );
|
||||
QgsFeatureIterator intersectIt = vl->getFeatures( req );
|
||||
QgsFeature outFeature;
|
||||
while ( intersectIt.nextFeature( overlayFeature ) )
|
||||
{
|
||||
if ( featureGeometry.intersects( overlayFeature.geometry() ) )
|
||||
{
|
||||
intersectGeometry = featureGeometry.intersection( overlayFeature.geometry() );
|
||||
|
||||
outFeature.setGeometry( intersectGeometry );
|
||||
QgsAttributes attributesA = f.attributes();
|
||||
QgsAttributes attributesB = overlayFeature.attributes();
|
||||
combineAttributeMaps( attributesA, attributesB );
|
||||
outFeature.setAttributes( attributesA );
|
||||
|
||||
//add it to vector file writer
|
||||
if ( vfw )
|
||||
{
|
||||
vfw->addFeature( outFeature );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QgsOverlayAnalyzer::combineFieldLists( QgsFields &fieldListA, const QgsFields &fieldListB )
|
||||
{
|
||||
QList<QString> names;
|
||||
Q_FOREACH ( const QgsField &field, fieldListA )
|
||||
names.append( field.name() );
|
||||
|
||||
for ( int idx = 0; idx < fieldListB.count(); ++idx )
|
||||
{
|
||||
QgsField field = fieldListB.at( idx );
|
||||
int count = 0;
|
||||
while ( names.contains( field.name() ) )
|
||||
{
|
||||
QString name = QStringLiteral( "%1_%2" ).arg( field.name() ).arg( count );
|
||||
field = QgsField( name, field.type() );
|
||||
++count;
|
||||
}
|
||||
fieldListA.append( field );
|
||||
names.append( field.name() );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsOverlayAnalyzer::combineAttributeMaps( QgsAttributes &attributesA, const QgsAttributes &attributesB )
|
||||
{
|
||||
attributesA += attributesB;
|
||||
}
|
||||
|
@ -1,54 +0,0 @@
|
||||
/***************************************************************************
|
||||
qgsoverlayanalyzer.h - QGIS Tools for vector geometry analysis
|
||||
-------------------
|
||||
begin : 19 March 2009
|
||||
copyright : (C) Carson Farmer
|
||||
email : carson.farmer@gmail.com
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* 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. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef QGSOVERLAYANALYZERH
|
||||
#define QGSOVERLAYANALYZERH
|
||||
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgis_analysis.h"
|
||||
|
||||
class QgsVectorFileWriter;
|
||||
class QProgressDialog;
|
||||
class QgsSpatialIndex;
|
||||
|
||||
/** \ingroup analysis
|
||||
* The QGis class provides vector overlay analysis functions
|
||||
*/
|
||||
|
||||
class ANALYSIS_EXPORT QgsOverlayAnalyzer
|
||||
{
|
||||
public:
|
||||
|
||||
/** Perform an intersection on two input vector layers and write output to a new shape file
|
||||
\param layerA input vector layer
|
||||
\param layerB 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 intersection( QgsVectorLayer *layerA, QgsVectorLayer *layerB,
|
||||
const QString &shapefileName, bool onlySelectedFeatures = false,
|
||||
QProgressDialog *p = nullptr );
|
||||
|
||||
private:
|
||||
|
||||
void combineFieldLists( QgsFields &fieldListA, const QgsFields &fieldListB );
|
||||
void intersectFeature( QgsFeature &f, QgsVectorFileWriter *vfw, QgsVectorLayer *dp, QgsSpatialIndex *index );
|
||||
void combineAttributeMaps( QgsAttributes &attributesA, const QgsAttributes &attributesB );
|
||||
};
|
||||
|
||||
#endif //QGSVECTORANALYZER
|
@ -1,170 +0,0 @@
|
||||
/***************************************************************************
|
||||
qgspointsample.cpp
|
||||
---------------------
|
||||
begin : July 2013
|
||||
copyright : (C) 2013 by Marco Hugentobler
|
||||
email : marco dot hugentobler 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. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#include "qgspointsample.h"
|
||||
#include "qgsfeatureiterator.h"
|
||||
#include "qgsgeometry.h"
|
||||
#include "qgsspatialindex.h"
|
||||
#include "qgsvectorfilewriter.h"
|
||||
#include "qgsvectorlayer.h"
|
||||
#include <QFile>
|
||||
#include "mersenne-twister.h"
|
||||
|
||||
|
||||
QgsPointSample::QgsPointSample( QgsVectorLayer *inputLayer, const QString &outputLayer, const QString &nPointsAttribute, const QString &minDistAttribute ): mInputLayer( inputLayer ),
|
||||
mOutputLayer( outputLayer ), mNumberOfPointsAttribute( nPointsAttribute ), mMinDistanceAttribute( minDistAttribute ), mNCreatedPoints( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
QgsPointSample::QgsPointSample()
|
||||
: mInputLayer( nullptr )
|
||||
, mNCreatedPoints( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
int QgsPointSample::createRandomPoints( QProgressDialog *pd )
|
||||
{
|
||||
Q_UNUSED( pd );
|
||||
|
||||
//create input layer from id (test if polygon, valid)
|
||||
if ( !mInputLayer )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( mInputLayer->geometryType() != QgsWkbTypes::PolygonGeometry )
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
//delete output file if it already exists
|
||||
if ( QFile::exists( mOutputLayer ) )
|
||||
{
|
||||
QgsVectorFileWriter::deleteShapeFile( mOutputLayer );
|
||||
}
|
||||
|
||||
//create vector file writer
|
||||
QgsFields outputFields;
|
||||
outputFields.append( QgsField( QStringLiteral( "id" ), QVariant::Int ) );
|
||||
outputFields.append( QgsField( QStringLiteral( "station_id" ), QVariant::Int ) );
|
||||
outputFields.append( QgsField( QStringLiteral( "stratum_id" ), QVariant::Int ) );
|
||||
QgsVectorFileWriter writer( mOutputLayer, QStringLiteral( "UTF-8" ),
|
||||
outputFields,
|
||||
QgsWkbTypes::Point,
|
||||
mInputLayer->crs() );
|
||||
|
||||
//check if creation of output layer successful
|
||||
if ( writer.hasError() != QgsVectorFileWriter::NoError )
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
//init random number generator
|
||||
mt_srand( QTime::currentTime().msec() );
|
||||
QgsFeature fet;
|
||||
int nPoints = 0;
|
||||
double minDistance = 0;
|
||||
mNCreatedPoints = 0;
|
||||
|
||||
QgsFeatureIterator fIt = mInputLayer->getFeatures( QgsFeatureRequest().setSubsetOfAttributes(
|
||||
QStringList() << mNumberOfPointsAttribute << mMinDistanceAttribute, mInputLayer->fields() ) );
|
||||
while ( fIt.nextFeature( fet ) )
|
||||
{
|
||||
nPoints = fet.attribute( mNumberOfPointsAttribute ).toInt();
|
||||
if ( !mMinDistanceAttribute.isEmpty() )
|
||||
{
|
||||
minDistance = fet.attribute( mMinDistanceAttribute ).toDouble();
|
||||
}
|
||||
addSamplePoints( fet, writer, nPoints, minDistance );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void QgsPointSample::addSamplePoints( QgsFeature &inputFeature, QgsVectorFileWriter &writer, int nPoints, double minDistance )
|
||||
{
|
||||
if ( !inputFeature.hasGeometry() )
|
||||
return;
|
||||
|
||||
QgsGeometry geom = inputFeature.geometry();
|
||||
QgsRectangle geomRect = geom.boundingBox();
|
||||
if ( geomRect.isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QgsSpatialIndex sIndex; //to check minimum distance
|
||||
QMap< QgsFeatureId, QgsPointXY > pointMapForFeature;
|
||||
|
||||
int nIterations = 0;
|
||||
int maxIterations = nPoints * 200;
|
||||
int points = 0;
|
||||
|
||||
double randX = 0;
|
||||
double randY = 0;
|
||||
|
||||
while ( nIterations < maxIterations && points < nPoints )
|
||||
{
|
||||
randX = ( ( double )mt_rand() / MD_RAND_MAX ) * geomRect.width() + geomRect.xMinimum();
|
||||
randY = ( ( double )mt_rand() / MD_RAND_MAX ) * geomRect.height() + geomRect.yMinimum();
|
||||
QgsPointXY randPoint( randX, randY );
|
||||
QgsGeometry ptGeom = QgsGeometry::fromPoint( randPoint );
|
||||
if ( ptGeom.within( geom ) && checkMinDistance( randPoint, sIndex, minDistance, pointMapForFeature ) )
|
||||
{
|
||||
//add feature to writer
|
||||
QgsFeature f( mNCreatedPoints );
|
||||
f.setAttribute( QStringLiteral( "id" ), mNCreatedPoints + 1 );
|
||||
f.setAttribute( QStringLiteral( "station_id" ), points + 1 );
|
||||
f.setAttribute( QStringLiteral( "stratum_id" ), inputFeature.id() );
|
||||
f.setGeometry( ptGeom );
|
||||
writer.addFeature( f );
|
||||
sIndex.insertFeature( f );
|
||||
pointMapForFeature.insert( mNCreatedPoints, randPoint );
|
||||
++points;
|
||||
++mNCreatedPoints;
|
||||
}
|
||||
++nIterations;
|
||||
}
|
||||
}
|
||||
|
||||
bool QgsPointSample::checkMinDistance( QgsPointXY &pt, QgsSpatialIndex &index, double minDistance, QMap< QgsFeatureId, QgsPointXY > &pointMap )
|
||||
{
|
||||
if ( minDistance <= 0 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
QList<QgsFeatureId> neighborList = index.nearestNeighbor( pt, 1 );
|
||||
if ( neighborList.isEmpty() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
QMap< QgsFeatureId, QgsPointXY >::const_iterator it = pointMap.find( neighborList[0] );
|
||||
if ( it == pointMap.constEnd() ) //should not happen
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
QgsPointXY neighborPt = it.value();
|
||||
if ( neighborPt.sqrDist( pt ) < ( minDistance * minDistance ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,57 +0,0 @@
|
||||
/***************************************************************************
|
||||
qgspointsample.h
|
||||
---------------------
|
||||
begin : July 2013
|
||||
copyright : (C) 2013 by Marco Hugentobler
|
||||
email : marco dot hugentobler 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. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#ifndef QGSPOINTSAMPLE_H
|
||||
#define QGSPOINTSAMPLE_H
|
||||
|
||||
#include "qgsfeature.h"
|
||||
#include <QString>
|
||||
#include "qgis_analysis.h"
|
||||
|
||||
class QgsFeature;
|
||||
class QgsPointXY;
|
||||
class QgsSpatialIndex;
|
||||
class QgsVectorFileWriter;
|
||||
class QgsVectorLayer;
|
||||
class QProgressDialog;
|
||||
|
||||
/** \ingroup analysis
|
||||
* Creates random points in polygons / multipolygons*/
|
||||
class ANALYSIS_EXPORT QgsPointSample
|
||||
{
|
||||
public:
|
||||
QgsPointSample( QgsVectorLayer *inputLayer, const QString &outputLayer, const QString &nPointsAttribute, const QString &minDistAttribute = QString() );
|
||||
|
||||
/** Starts calculation of random points
|
||||
\returns 0 in case of success*/
|
||||
int createRandomPoints( QProgressDialog *pd );
|
||||
|
||||
private:
|
||||
|
||||
QgsPointSample(); //default constructor is forbidden
|
||||
void addSamplePoints( QgsFeature &inputFeature, QgsVectorFileWriter &writer, int nPoints, double minDistance );
|
||||
bool checkMinDistance( QgsPointXY &pt, QgsSpatialIndex &index, double minDistance, QMap< QgsFeatureId, QgsPointXY > &pointMap );
|
||||
|
||||
//! Layer id of input polygon/multipolygon layer
|
||||
QgsVectorLayer *mInputLayer = nullptr;
|
||||
//! Output path of result layer
|
||||
QString mOutputLayer;
|
||||
//! Attribute containing number of points per feature
|
||||
QString mNumberOfPointsAttribute;
|
||||
//! Attribute containing minimum distance between sample points (or -1 if no min. distance constraint)
|
||||
QString mMinDistanceAttribute;
|
||||
QgsFeatureId mNCreatedPoints; //helper to find free ids
|
||||
};
|
||||
|
||||
#endif // QGSPOINTSAMPLE_H
|
@ -63,7 +63,6 @@ ENDMACRO (ADD_QGIS_TEST)
|
||||
#############################################################
|
||||
# Tests:
|
||||
SET(TESTS
|
||||
testqgsvectoranalyzer.cpp
|
||||
testqgsgeometrysnapper.cpp
|
||||
testopenstreetmap.cpp
|
||||
testqgszonalstatistics.cpp
|
||||
|
@ -1,145 +0,0 @@
|
||||
/***************************************************************************
|
||||
testqgsvectoranalyzer.cpp
|
||||
--------------------------------------
|
||||
Date : Sun Sep 16 12:22:49 AKDT 2007
|
||||
Copyright : (C) 2007 by Gary E. Sherman
|
||||
Email : sherman at mrcc dot com
|
||||
***************************************************************************
|
||||
* *
|
||||
* 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. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#include "qgstest.h"
|
||||
|
||||
//header for class being tested
|
||||
#include <qgsgeometryanalyzer.h>
|
||||
#include <qgsapplication.h>
|
||||
#include <qgsproviderregistry.h>
|
||||
#include "qgsvectorlayer.h"
|
||||
|
||||
class TestQgsVectorAnalyzer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TestQgsVectorAnalyzer()
|
||||
: mpLineLayer( 0 )
|
||||
, mpPolyLayer( 0 )
|
||||
, mpPointLayer( 0 )
|
||||
{}
|
||||
|
||||
private slots:
|
||||
void initTestCase();// will be called before the first testfunction is executed.
|
||||
void cleanupTestCase();// will be called after the last testfunction was executed.
|
||||
void init() ;// will be called before each testfunction is executed.
|
||||
void cleanup() ;// will be called after every testfunction.
|
||||
//! Our tests proper begin here
|
||||
void singleToMulti();
|
||||
void multiToSingle();
|
||||
void extractNodes();
|
||||
void polygonsToLines();
|
||||
void exportGeometryInfo();
|
||||
void simplifyGeometry();
|
||||
void polygonCentroids();
|
||||
void layerExtent();
|
||||
private:
|
||||
QgsGeometryAnalyzer mAnalyzer;
|
||||
QgsVectorLayer *mpLineLayer = nullptr;
|
||||
QgsVectorLayer *mpPolyLayer = nullptr;
|
||||
QgsVectorLayer *mpPointLayer = nullptr;
|
||||
|
||||
};
|
||||
|
||||
void TestQgsVectorAnalyzer::initTestCase()
|
||||
{
|
||||
//
|
||||
// Runs once before any tests are run
|
||||
//
|
||||
// init QGIS's paths - true means that all path will be inited from prefix
|
||||
QgsApplication::init();
|
||||
QgsApplication::initQgis();
|
||||
QgsApplication::showSettings();
|
||||
|
||||
//create some objects that will be used in all tests...
|
||||
//create a map layer that will be used in all tests...
|
||||
QString myBaseFileName( TEST_DATA_DIR ); //defined in CmakeLists.txt
|
||||
QString myEndName = QStringLiteral( "lines.shp" );
|
||||
QString myFileName = myBaseFileName + '/' + myEndName;
|
||||
qDebug() << myFileName;
|
||||
QFileInfo myLineInfo( myFileName );
|
||||
mpLineLayer = new QgsVectorLayer( myLineInfo.filePath(),
|
||||
myLineInfo.completeBaseName(), QStringLiteral( "ogr" ) );
|
||||
|
||||
myEndName = QStringLiteral( "polys.shp" );
|
||||
myFileName = myBaseFileName + '/' + myEndName;
|
||||
QFileInfo myPolyInfo( myFileName );
|
||||
mpPolyLayer = new QgsVectorLayer( myPolyInfo.filePath(),
|
||||
myPolyInfo.completeBaseName(), QStringLiteral( "ogr" ) );
|
||||
|
||||
myEndName = QStringLiteral( "points.shp" );
|
||||
myFileName = myBaseFileName + '/' + myEndName;
|
||||
QFileInfo myPointInfo( myFileName );
|
||||
mpPointLayer = new QgsVectorLayer( myPointInfo.filePath(),
|
||||
myPointInfo.completeBaseName(), QStringLiteral( "ogr" ) );
|
||||
}
|
||||
void TestQgsVectorAnalyzer::cleanupTestCase()
|
||||
{
|
||||
delete mpLineLayer;
|
||||
delete mpPolyLayer;
|
||||
delete mpPointLayer;
|
||||
QgsApplication::exitQgis();
|
||||
}
|
||||
void TestQgsVectorAnalyzer::init()
|
||||
{
|
||||
|
||||
}
|
||||
void TestQgsVectorAnalyzer::cleanup()
|
||||
{
|
||||
|
||||
}
|
||||
void TestQgsVectorAnalyzer::singleToMulti()
|
||||
{
|
||||
|
||||
}
|
||||
void TestQgsVectorAnalyzer::multiToSingle()
|
||||
{
|
||||
|
||||
}
|
||||
void TestQgsVectorAnalyzer::extractNodes()
|
||||
{
|
||||
|
||||
}
|
||||
void TestQgsVectorAnalyzer::polygonsToLines()
|
||||
{
|
||||
|
||||
}
|
||||
void TestQgsVectorAnalyzer::exportGeometryInfo()
|
||||
{
|
||||
}
|
||||
|
||||
void TestQgsVectorAnalyzer::simplifyGeometry()
|
||||
{
|
||||
QString myTmpDir = QDir::tempPath() + '/';
|
||||
QString myFileName = myTmpDir + "simplify_layer.shp";
|
||||
QVERIFY( mAnalyzer.simplify( mpLineLayer, myFileName, 1.0 ) );
|
||||
}
|
||||
|
||||
void TestQgsVectorAnalyzer::polygonCentroids()
|
||||
{
|
||||
QString myTmpDir = QDir::tempPath() + '/';
|
||||
QString myFileName = myTmpDir + "centroid_layer.shp";
|
||||
QVERIFY( mAnalyzer.centroids( mpPolyLayer, myFileName ) );
|
||||
}
|
||||
|
||||
void TestQgsVectorAnalyzer::layerExtent()
|
||||
{
|
||||
QString myTmpDir = QDir::tempPath() + '/';
|
||||
QString myFileName = myTmpDir + "extent_layer.shp";
|
||||
QVERIFY( mAnalyzer.extent( mpPointLayer, myFileName ) );
|
||||
}
|
||||
|
||||
QGSTEST_MAIN( TestQgsVectorAnalyzer )
|
||||
#include "testqgsvectoranalyzer.moc"
|
Loading…
x
Reference in New Issue
Block a user