Skip to content
Permalink
Browse files

Merge pull request #5512 from nyalldawson/interp

Cleanup and optimise interpolation code
  • Loading branch information
nyalldawson committed Nov 3, 2017
2 parents 151fb08 + b36dd12 commit 10c9bb6d6c65cd793b351c7d6376a4078342daa3
Showing with 969 additions and 1,588 deletions.
  1. +13 −1 doc/api_break.dox
  2. +0 −75 python/analysis/interpolation/Line3D.sip
  3. +0 −52 python/analysis/interpolation/Node.sip
  4. +29 −8 python/analysis/interpolation/qgsidwinterpolator.sip
  5. +73 −19 python/analysis/interpolation/qgsinterpolator.sip
  6. +10 −16 python/analysis/interpolation/qgstininterpolator.sip
  7. +6 −6 python/plugins/processing/algs/qgis/IdwInterpolation.py
  8. +12 −12 python/plugins/processing/algs/qgis/TinInterpolation.py
  9. +9 −9 python/plugins/processing/algs/qgis/ui/InterpolationDataWidget.py
  10. +4 −4 python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml
  11. +0 −4 src/analysis/CMakeLists.txt
  12. +59 −68 src/analysis/interpolation/CloughTocherInterpolator.cpp
  13. +1 −2 src/analysis/interpolation/CloughTocherInterpolator.h
  14. +298 −333 src/analysis/interpolation/DualEdgeTriangulation.cpp
  15. +5 −8 src/analysis/interpolation/DualEdgeTriangulation.h
  16. +5 −6 src/analysis/interpolation/LinTriangleInterpolator.cpp
  17. +1 −2 src/analysis/interpolation/LinTriangleInterpolator.h
  18. +0 −89 src/analysis/interpolation/Line3D.cpp
  19. +0 −94 src/analysis/interpolation/Line3D.h
  20. +9 −9 src/analysis/interpolation/MathUtils.cpp
  21. +1 −1 src/analysis/interpolation/MathUtils.h
  22. +0 −62 src/analysis/interpolation/Node.cpp
  23. +0 −86 src/analysis/interpolation/Node.h
  24. +2 −2 src/analysis/interpolation/NormVecDecorator.cpp
  25. +2 −4 src/analysis/interpolation/NormVecDecorator.h
  26. +4 −4 src/analysis/interpolation/TriDecorator.cpp
  27. +23 −23 src/analysis/interpolation/TriDecorator.h
  28. +1 −1 src/analysis/interpolation/TriangleInterpolator.h
  29. +9 −8 src/analysis/interpolation/Triangulation.h
  30. +3 −3 src/analysis/interpolation/qgsgridfilewriter.cpp
  31. +10 −20 src/analysis/interpolation/qgsidwinterpolator.cpp
  32. +28 −12 src/analysis/interpolation/qgsidwinterpolator.h
  33. +82 −248 src/analysis/interpolation/qgsinterpolator.cpp
  34. +85 −32 src/analysis/interpolation/qgsinterpolator.h
  35. +162 −242 src/analysis/interpolation/qgstininterpolator.cpp
  36. +23 −23 src/analysis/interpolation/qgstininterpolator.h
@@ -195,6 +195,7 @@ Renamed Classes {#qgis_api_break_3_0_renamed_classes}
<tr><td>QgsSymbolV2SelectorDialog<td>QgsSymbolSelectorDialog
<tr><td>QgsSymbolV2SelectorWidget<td>QgsSymbolSelectorWidget
<tr><td>QgsTicksScaleBarStyle<td>QgsTicksScaleBarRenderer
<tr><td>QgsTINInterpolator<td>QgsTinInterpolator
<tr><td>QgsVectorColorBrewerColorRampV2<td>QgsColorBrewerColorRamp
<tr><td>QgsVectorColorBrewerColorRampV2Dialog<td>QgsColorBrewerColorRampDialog
<tr><td>QgsVectorColorBrewerColorRampV2DialogBase<td>QgsColorBrewerColorRampDialogBase
@@ -210,6 +211,7 @@ Renamed Classes {#qgis_api_break_3_0_renamed_classes}
<tr><td>QgsVectorRandomColorRampV2<td>QgsLimitedRandomColorRamp
<tr><td>QgsVectorRandomColorRampV2Dialog<td>QgsLimitedRandomColorRampDialog
<tr><td>QgsVectorRandomColorRampV2DialogBase<td>QgsLimitedRandomColorRampDialogBase
<tr><td>vertexData<td>QgsInterpolatorVertexData
</table>

<table>
@@ -1484,6 +1486,16 @@ QgsIFeatureSelectionManager {#qgis_api_break_3_0_QgsIFeatureSelectionMana
- selectedFeaturesIds() has been renamed to selectedFeatureIds()


QgsInterpolator {#qgis_api_break_3_0_QgsInterpolator}
---------------

- The InputType enum was renamed to SourceType and the enum values were renamed.
- LayerData.vectorLayer was renamed to LayerData.source
- LayerData.zCoordInterpolation was renamed to LayerData.valueSource and now takes a QgsInterpolator.ValueSource enum value.
- LayerData.mInputType was renamed to LayerData.sourceType



QgsJSONExporter {#qgis_api_break_3_0_QgsJSONExporter}
---------------

@@ -2454,7 +2466,7 @@ QgsSymbolsListWidget {#qgis_api_break_3_0_QgsSymbolsListWidget}
- expressionContext(), setExpressionContext(), setMapCanvas() and mapCanvas() have been removed in favor of setContext()/context()


QgsTINInterpolator {#qgis_api_break_3_0_QgsTINInterpolator}
QgsTinInterpolator {#qgis_api_break_3_0_QgsTinInterpolator}
------------------

- The constructor takes a QgsFeedback argument instead of using a QProgressDialog.

This file was deleted.

This file was deleted.

@@ -11,25 +11,46 @@

class QgsIDWInterpolator: QgsInterpolator
{
%Docstring
Inverse distance weight interpolator.
%End

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

QgsIDWInterpolator( const QList<QgsInterpolator::LayerData> &layerData );
%Docstring
Constructor for QgsIDWInterpolator, with the specified ``layerData`` sources.
%End

virtual int interpolatePoint( double x, double y, double &result, QgsFeedback *feedback = 0 );

virtual int interpolatePoint( double x, double y, double &result );

void setDistanceCoefficient( double coefficient );
%Docstring
Calculates interpolation value for map coordinates x, y
\param x x-coordinate (in map units)
\param y y-coordinate (in map units)
\param result out: interpolation result
:return: 0 in case of success*
:rtype: int
Sets the distance ``coefficient``, the parameter that sets how the values are
weighted with distance. Smaller values mean sharper peaks at the data points.

Point values are weighted by 1 / ( distance ^ coefficient ).

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

void setDistanceCoefficient( double p );
double distanceCoefficient() const;
%Docstring
Returns the distance coefficient, the parameter that sets how the values are
weighted with distance. Smaller values mean sharper peaks at the data points.
The default is a coefficient of 2.

Point values are weighted by 1 / ( distance ^ coefficient ).

.. seealso:: setDistanceCoefficient()
.. versionadded:: 3.0
:rtype: float
%End

};

@@ -10,63 +10,117 @@



struct vertexData
struct QgsInterpolatorVertexData
{

QgsInterpolatorVertexData( double x, double y, double z );
%Docstring
Constructor for QgsInterpolatorVertexData with the specified
``x``, ``y``, and ``z`` coordinate.
%End

QgsInterpolatorVertexData();
%Docstring
Constructor for QgsInterpolatorVertexData
%End

double x;
%Docstring
X-coordinate
%End
double y;
%Docstring
Y-coordinate
%End
double z;
%Docstring
Z-coordinate
%End
};

class QgsInterpolator
{
%Docstring
Interface class for interpolations. Interpolators take
the vertices of a vector layer as base data. The z-Value
can be an attribute or the z-coordinates in case of 25D types*
the vertices of a vector layer as base data. The z-Value
can be an attribute or the z-coordinates in case of 3D types.
%End

%TypeHeaderCode
#include "qgsinterpolator.h"
%End
public:
enum InputType

enum SourceType
{
POINTS,
STRUCTURE_LINES,
BREAK_LINES
SourcePoints,
SourceStructureLines,
SourceBreakLines,
};

enum ValueSource
{
ValueAttribute,
ValueZ,
ValueM,
};

enum Result
{
Success,
Canceled,
InvalidSource,
FeatureGeometryError,
};

struct LayerData
{
QgsVectorLayer *vectorLayer;
bool zCoordInterpolation;
QgsFeatureSource *source;
%Docstring
Feature source
%End
QgsInterpolator::ValueSource valueSource;
%Docstring
Source for feature values to interpolate
%End
int interpolationAttribute;
QgsInterpolator::InputType mInputType;
%Docstring
Index of feature attribute to use for interpolation
%End
QgsInterpolator::SourceType sourceType;
%Docstring
Source type
%End
};

QgsInterpolator( const QList<QgsInterpolator::LayerData> &layerData );

virtual ~QgsInterpolator();

virtual int interpolatePoint( double x, double y, double &result ) = 0;
virtual int interpolatePoint( double x, double y, double &result, QgsFeedback *feedback = 0 ) = 0;
%Docstring
Calculates interpolation value for map coordinates x, y
\param x x-coordinate (in map units)
\param y y-coordinate (in map units)
\param result out: interpolation result
:return: 0 in case of success*
\param x x-coordinate (in map units)
\param y y-coordinate (in map units)
\param result out: interpolation result
\param feedback optional feedback object for progress and cancelation support
:return: 0 in case of success*
:rtype: int
%End


protected:

int cacheBaseData();
Result cacheBaseData( QgsFeedback *feedback = 0 );
%Docstring
Caches the vertex and value data from the provider. All the vertex data
will be held in virtual memory
:return: 0 in case of success*
:rtype: int
will be held in virtual memory.

An optional ``feedback`` argument may be specified to allow cancelation and
progress reports from the cache operation.

:return: Success in case of success
:rtype: Result
%End


0 comments on commit 10c9bb6

Please sign in to comment.
You can’t perform that action at this time.