Skip to content

Commit

Permalink
Merge pull request #5078 from nyalldawson/rename
Browse files Browse the repository at this point in the history
Some more analysis lib cleanups
  • Loading branch information
nyalldawson committed Aug 29, 2017
2 parents e5b11d4 + e620384 commit c16ce92
Show file tree
Hide file tree
Showing 45 changed files with 297 additions and 174 deletions.
24 changes: 22 additions & 2 deletions doc/api_break.dox
Expand Up @@ -249,6 +249,8 @@ Removed Classes {#qgis_api_break_3_0_removed_classes}
- QgsAnnotationItem was removed. This was replaced by QgsAnnotation and QgsMapCanvasAnnotationItem.
- QgsAttributeAction was removed, and replaced by QgsActionManager.
- QgsAttributeEditor was removed. Use QgsEditorWidgetRegistry::create() instead.
- Bezier3D.
- CloughTocherInterpolator.
- QgsColorbutton was removed. QgsColorButtonV2 has now been renamed to QgsColorButton. Hence, QgsColorButtonV2 does not exist anymore.
- QgsColorDialog was removed, and QgsColorDialogV2 was renamed to QgsColorDialog. Hence, QgsColorButtonV2 does not exist anymore.
All the functionality from the old QgsColorDialog has been moved to the new class.
Expand All @@ -266,10 +268,12 @@ should now call QgsCoordinateReferenceSystem::invalidateCache() and QgsCoordinat
- QgsDataDefinedButton was removed. Use QgsPropertyOverrideButton instead.
- QgsDataDefinedSymbolDialog was removed. Code using this dialog should be reworked to use QgsPropertyOverrideButton
- QgsDefaultPluginLayerLegend was removed. Use QgsMapLayer::setLegend() to provide legend nodes for plugin layers.
- DualEdgeTriangulation
- QgsFileNameWidgetWrapper was removed. Use QgsExternalResourceWidgetWrapper instead.
- QgsFileDropEdit was removed. Use QgsFileWidget instead.
- QgsFormAnnotationItem. Use QgsFormAnnotation instead.
- QgsGeometryAnalyzer. Use the equivalent Processing algorithms instead.
- HalfEdge.
- QgsHtmlAnnotationItem. Use QgsHtmlAnnotation instead.
- QgsHttpTransaction. This class was outdated and code should be ported to native Qt or Python implementations.
- QgsGenericProjectionSelector. Use QgsProjectionSelectionTreeWidget instead.
Expand All @@ -282,11 +286,16 @@ should now call QgsCoordinateReferenceSystem::invalidateCache() and QgsCoordinat
- addLegendLayerActionForLayer() moved to QgisInterface::addCustomActionForLayer()
- removeLegendLayerAction() moved to QgisInterface::removeCustomActionForLayerType()
- QgsLegendModel was removed.
- Line3D.
- LinTriangleInterpolator.
- QgsMapCanvasLayer. Map canvas and overview canvas are updated separately with their own setLayers() calls.
- QgsMapCanvasMap. It is an internal class used by map canvas.
- QgsMapLayerRegistry. Its functionality has been moved to QgsProject.
- QgsMapRenderer. It has been replaced by QgsMapRendererJob with subclasses and QgsMapSettings.
- QgsMapToolTouch. The touch navigation functionality is now built into the standard QgsMapToolPan tool.
- Node.
- NormVecDecorator.
- ParametericLine.
- 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.
Expand All @@ -302,10 +311,13 @@ should now call QgsCoordinateReferenceSystem::invalidateCache() and QgsCoordinat
- QgsSvgAnnotationItem. Use QgsSvgAnnotation instead.
- QgsSymbologyV2Conversion was removed. Reading of renderers from pre-1.0 versions is not supported anymore.
- QgsTextAnnotationItem. Use QgsTextAnnotation instead.
- TriangleInterpolator.
- Triangulation.
- TriDecorator.
- QgsSnapper. Use QgsSnappingUtils instead.
- QgsSnappingResult. Use QgsSnappingUtils instead.
- QgsMapCanvasSnapper. Use QgsMapCanvas::snappingUtils() instead.

- Vector3D

General changes {#qgis_api_break_3_0_global}
---------------
Expand Down Expand Up @@ -1896,7 +1908,8 @@ QgsRasterCalculator {#qgis_api_break_3_0_QgsRasterCalculator}
-------------------

- Cancelled (Result enum value) has been renamed to Canceled <!--#spellok-->

- processCalculation() now uses an optional QgsFeedback instead of QProgressDialog
for progress reports and cancelation.

QgsRasterDataProvider {#qgis_api_break_3_0_QgsRasterDataProvider}
---------------------
Expand Down Expand Up @@ -2325,6 +2338,7 @@ QgsTINInterpolator {#qgis_api_break_3_0_QgsTINInterpolator}
------------------

- The constructor takes a QgsFeedback argument instead of using a QProgressDialog.
- setExportTriangulationToFile() and setTriangulationFilePath() were removed. Use setTriangulationSink() instead.

QgsTolerance {#qgis_api_break_3_0_QgsTolerance}
------------
Expand All @@ -2338,6 +2352,12 @@ QgsTracer {#qgis_api_break_3_0_QgsTracer}

- hasCrsTransformEnabled() and setCrsTransformEnabled() were removed. CRS transformation is now always enabled when required.

QgsTransectSample {#qgis_api_break_3_0_QgsTransectSample}
-----------------

- createSample() now uses an optional QgsFeedback instead of QProgressDialog
for progress reports and cancelation.


QgsTreeWidgetItem {#qgis_api_break_3_0_QgsTreeWidgetItem}
-----------------
Expand Down
21 changes: 4 additions & 17 deletions python/analysis/analysis_auto.sip
Expand Up @@ -12,36 +12,23 @@
%Include raster/qgsrastermatrix.sip
%Include raster/qgsrastercalcnode.sip
%Include raster/qgstotalcurvaturefilter.sip
%Include vector/qgsgeometrysnapper.sip
%Include vector/qgstransectsample.sip
%Include vector/qgszonalstatistics.sip
%Include interpolation/qgsinterpolator.sip
%Include interpolation/qgsgridfilewriter.sip
%Include interpolation/qgsidwinterpolator.sip
%Include interpolation/qgstininterpolator.sip
%Include interpolation/Bezier3D.sip
%Include interpolation/ParametricLine.sip
%Include interpolation/CloughTocherInterpolator.sip
%Include interpolation/TriangleInterpolator.sip
%Include interpolation/Vector3D.sip
%Include interpolation/DualEdgeTriangulation.sip
%Include interpolation/Node.sip
%Include interpolation/TriDecorator.sip
%Include interpolation/Triangulation.sip
%Include interpolation/HalfEdge.sip
%Include interpolation/LinTriangleInterpolator.sip
%Include interpolation/NormVecDecorator.sip
%Include interpolation/Line3D.sip
%Include openstreetmap/qgsosmbase.sip
%Include openstreetmap/qgsosmdatabase.sip
%Include openstreetmap/qgsosmdownload.sip
%Include openstreetmap/qgsosmimport.sip
%Include network/qgsgraph.sip
%Include network/qgsgraphbuilderinterface.sip
%Include network/qgsgraphbuilder.sip
%Include network/qgsnetworkstrategy.sip
%Include network/qgsnetworkspeedstrategy.sip
%Include network/qgsnetworkdistancestrategy.sip
%Include network/qgsgraphanalyzer.sip
%Include openstreetmap/qgsosmdownload.sip
%Include openstreetmap/qgsosmimport.sip
%Include vector/qgsgeometrysnapper.sip
%Include network/qgsgraphdirector.sip
%Include network/qgsvectorlayerdirector.sip
%Include network/qgsgraphdirector.sip
22 changes: 20 additions & 2 deletions python/analysis/interpolation/qgstininterpolator.sip
Expand Up @@ -45,8 +45,26 @@ class QgsTINInterpolator: QgsInterpolator
:rtype: int
%End

void setExportTriangulationToFile( bool e );
void setTriangulationFilePath( const QString &filepath );
static QgsFields triangulationFields();
%Docstring
Returns the fields output by features when saving the triangulation.
These fields should be used when creating
a suitable feature sink for setTriangulationSink()
.. seealso:: setTriangulationSink()
.. versionadded:: 3.0
:rtype: QgsFields
%End

void setTriangulationSink( QgsFeatureSink *sink );
%Docstring
Sets the optional ``sink`` for saving the triangulation features.

The sink must be setup to accept LineString features, with fields matching
those returned by triangulationFields().

.. seealso:: triangulationFields()
.. versionadded:: 3.0
%End

};

Expand Down
2 changes: 1 addition & 1 deletion python/analysis/raster/qgsrastercalculator.sip
Expand Up @@ -71,7 +71,7 @@ class QgsRasterCalculator
.. versionadded:: 2.10
%End

int processCalculation( QProgressDialog *p = 0 );
int processCalculation( QgsFeedback *feedback = 0 );
%Docstring
:rtype: int
%End
Expand Down
5 changes: 4 additions & 1 deletion python/analysis/vector/qgstransectsample.sip
Expand Up @@ -30,8 +30,11 @@ class QgsTransectSample
const QString &baselineStrataId, const QString &outputPointLayer, const QString &outputLineLayer, const QString &usedBaselineLayer, double minTransectLength = 0.0,
double baselineBufferDistance = -1.0, double baselineSimplificationTolerance = -1.0 );

int createSample( QProgressDialog *pd );
int createSample( QgsFeedback *feedback = 0 );
%Docstring
Creates the sample.

The optional ``feedback`` argument can be used for progress reporting and cancelation support.
:rtype: int
%End

Expand Down
32 changes: 19 additions & 13 deletions python/plugins/processing/algs/qgis/TinInterpolation.py
Expand Up @@ -30,13 +30,16 @@
from qgis.PyQt.QtGui import QIcon

from qgis.core import (QgsProcessingUtils,
QgsProcessing,
QgsProcessingParameterDefinition,
QgsProcessingParameterEnum,
QgsProcessingParameterNumber,
QgsProcessingParameterExtent,
QgsProcessingParameterRasterDestination,
QgsProcessingParameterFileDestination,
QgsProcessingException)
QgsWkbTypes,
QgsProcessingParameterFeatureSink,
QgsProcessingException,
QgsCoordinateReferenceSystem)
from qgis.analysis import (QgsInterpolator,
QgsTINInterpolator,
QgsGridFileWriter)
Expand Down Expand Up @@ -85,7 +88,6 @@ def dataToString(data):


class TinInterpolation(QgisAlgorithm):

INTERPOLATION_DATA = 'INTERPOLATION_DATA'
METHOD = 'METHOD'
COLUMNS = 'COLUMNS'
Expand All @@ -94,7 +96,7 @@ class TinInterpolation(QgisAlgorithm):
CELLSIZE_Y = 'CELLSIZE_Y'
EXTENT = 'EXTENT'
OUTPUT = 'OUTPUT'
TRIANGULATION_FILE = 'TRIANGULATION_FILE'
TRIANGULATION = 'TRIANGULATION'

def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'interpolation.png'))
Expand Down Expand Up @@ -134,10 +136,10 @@ def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterRasterDestination(self.OUTPUT,
self.tr('Interpolated')))

triangulation_file_param = QgsProcessingParameterFileDestination(self.TRIANGULATION_FILE,
self.tr('Triangulation'),
self.tr('SHP files (*.shp)'),
optional=True)
triangulation_file_param = QgsProcessingParameterFeatureSink(self.TRIANGULATION,
self.tr('Triangulation'),
type=QgsProcessing.TypeVectorLine,
optional=True)
triangulation_file_param.setCreateByDefault(False)
self.addParameter(triangulation_file_param)

Expand All @@ -156,7 +158,6 @@ def processAlgorithm(self, parameters, context, feedback):
cellsizeY = self.parameterAsDouble(parameters, self.CELLSIZE_Y, context)
bbox = self.parameterAsExtent(parameters, self.EXTENT, context)
output = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)
triangulation = self.parameterAsFileOutput(parameters, self.TRIANGULATION_FILE, context)

if interpolationData is None:
raise QgsProcessingException(
Expand All @@ -168,6 +169,7 @@ def processAlgorithm(self, parameters, context, feedback):

layerData = []
layers = []
crs = QgsCoordinateReferenceSystem()
for row in interpolationData.split(';'):
v = row.split(',')
data = QgsInterpolator.LayerData()
Expand All @@ -176,6 +178,8 @@ def processAlgorithm(self, parameters, context, feedback):
layer = QgsProcessingUtils.mapLayerFromString(v[0], context)
data.vectorLayer = layer
layers.append(layer)
if not crs.isValid():
crs = layer.crs()

data.zCoordInterpolation = bool(v[1])
data.interpolationAttribute = int(v[2])
Expand All @@ -192,10 +196,12 @@ def processAlgorithm(self, parameters, context, feedback):
else:
interpolationMethod = QgsTINInterpolator.CloughTocher

(triangulation_sink, triangulation_dest_id) = self.parameterAsSink(parameters, self.TRIANGULATION, context,
QgsTINInterpolator.triangulationFields(), QgsWkbTypes.LineString, crs)

interpolator = QgsTINInterpolator(layerData, interpolationMethod, feedback)
if triangulation is not None and triangulation != '':
interpolator.setExportTriangulationToFile(True)
interpolator.setTriangulationFilePath(triangulation)
if triangulation_sink is not None:
interpolator.setTriangulationSink(triangulation_sink)

writer = QgsGridFileWriter(interpolator,
output,
Expand All @@ -206,4 +212,4 @@ def processAlgorithm(self, parameters, context, feedback):
cellsizeY)

writer.writeFile(feedback)
return {self.OUTPUT: output}
return {self.OUTPUT: output, self.TRIANGULATION: triangulation_dest_id}
38 changes: 22 additions & 16 deletions src/analysis/CMakeLists.txt
Expand Up @@ -6,20 +6,20 @@ SET(QGIS_ANALYSIS_SRCS
interpolation/qgsidwinterpolator.cpp
interpolation/qgsinterpolator.cpp
interpolation/qgstininterpolator.cpp
interpolation/Bezier3D.cc
interpolation/CloughTocherInterpolator.cc
interpolation/DualEdgeTriangulation.cc
interpolation/HalfEdge.cc
interpolation/Line3D.cc
interpolation/LinTriangleInterpolator.cc
interpolation/MathUtils.cc
interpolation/NormVecDecorator.cc
interpolation/Node.cc
interpolation/ParametricLine.cc
interpolation/TriangleInterpolator.cc
interpolation/Triangulation.cc
interpolation/TriDecorator.cc
interpolation/Vector3D.cc
interpolation/Bezier3D.cpp
interpolation/CloughTocherInterpolator.cpp
interpolation/DualEdgeTriangulation.cpp
interpolation/HalfEdge.cpp
interpolation/Line3D.cpp
interpolation/LinTriangleInterpolator.cpp
interpolation/MathUtils.cpp
interpolation/NormVecDecorator.cpp
interpolation/Node.cpp
interpolation/ParametricLine.cpp
interpolation/TriangleInterpolator.cpp
interpolation/Triangulation.cpp
interpolation/TriDecorator.cpp
interpolation/Vector3D.cpp

raster/qgsalignraster.cpp
raster/qgsninecellfilter.cpp
Expand Down Expand Up @@ -88,8 +88,8 @@ ENDIF(NOT MSVC)
IF (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
SET_SOURCE_FILES_PROPERTIES(
interpolation/qgstininterpolator.cpp
interpolation/NormVecDecorator.cc
interpolation/CloughTocherInterpolator.cc
interpolation/NormVecDecorator.cpp
interpolation/CloughTocherInterpolator.cpp
PROPERTIES COMPILE_FLAGS "-Wno-overloaded-virtual"
)
ENDIF (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
Expand All @@ -113,6 +113,8 @@ SET(QGIS_ANALYSIS_HDRS
raster/qgsrastercalcnode.h
raster/qgstotalcurvaturefilter.h

vector/mersenne-twister.h
vector/qgsgeometrysnapper.h
vector/qgstransectsample.h
vector/qgszonalstatistics.h

Expand All @@ -126,6 +128,7 @@ SET(QGIS_ANALYSIS_HDRS
interpolation/TriangleInterpolator.h
interpolation/Vector3D.h
interpolation/DualEdgeTriangulation.h
interpolation/MathUtils.h
interpolation/Node.h
interpolation/TriDecorator.h
interpolation/Triangulation.h
Expand All @@ -136,6 +139,8 @@ SET(QGIS_ANALYSIS_HDRS

openstreetmap/qgsosmbase.h
openstreetmap/qgsosmdatabase.h
openstreetmap/qgsosmdownload.h
openstreetmap/qgsosmimport.h

network/qgsgraph.h
network/qgsgraphbuilderinterface.h
Expand All @@ -144,6 +149,7 @@ SET(QGIS_ANALYSIS_HDRS
network/qgsnetworkspeedstrategy.h
network/qgsnetworkdistancestrategy.h
network/qgsgraphanalyzer.h
network/qgsvectorlayerdirector.h
)

INCLUDE_DIRECTORIES(
Expand Down
@@ -1,6 +1,6 @@
/***************************************************************************
Bezier3D.cc - description
-------------------
Bezier3D.cpp
------------
copyright : (C) 2004 by Marco Hugentobler
email : mhugent@geo.unizh.ch
***************************************************************************/
Expand Down
6 changes: 5 additions & 1 deletion src/analysis/interpolation/Bezier3D.h
Expand Up @@ -21,8 +21,12 @@
#include "qgslogger.h"
#include "qgis_analysis.h"

#define SIP_NO_FILE

/** \ingroup analysis
* Class Bezier3D represents a bezier curve, represented by control points. Parameter t is running from 0 to 1. The class is capable to calculate the curve point and the first two derivatives belonging to t.*/
* Class Bezier3D represents a bezier curve, represented by control points. Parameter t is running from 0 to 1. The class is capable to calculate the curve point and the first two derivatives belonging to it.
* \note Not available in Python bindings
*/
class ANALYSIS_EXPORT Bezier3D: public ParametricLine
{
protected:
Expand Down
@@ -1,6 +1,6 @@
/***************************************************************************
CloughTocherInterpolator.cc - description
-------------------
CloughTocherInterpolator.cpp
----------------------------
copyright : (C) 2004 by Marco Hugentobler
email : mhugent@geo.unizh.ch
***************************************************************************/
Expand Down

0 comments on commit c16ce92

Please sign in to comment.