Skip to content

Commit

Permalink
QgsTINInterpolator->QgsTinInterpolator
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 3, 2017
1 parent e94733f commit 8631472
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 31 deletions.
3 changes: 2 additions & 1 deletion doc/api_break.dox
Expand Up @@ -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
Expand Down Expand Up @@ -2465,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.
Expand Down
16 changes: 9 additions & 7 deletions python/analysis/interpolation/qgstininterpolator.sip
Expand Up @@ -10,29 +10,31 @@



class QgsTINInterpolator: QgsInterpolator
class QgsTinInterpolator: QgsInterpolator
{
%Docstring
Interpolation in a triangular irregular network*
Interpolation in a triangular irregular network
.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgstininterpolator.h"
%End
public:
enum TINInterpolation

enum TinInterpolation
{
Linear,
CloughTocher
CloughTocher,
};

QgsTINInterpolator( const QList<QgsInterpolator::LayerData> &inputData, TINInterpolation interpolation = Linear, QgsFeedback *feedback = 0 );
QgsTinInterpolator( const QList<QgsInterpolator::LayerData> &inputData, TinInterpolation interpolation = Linear, QgsFeedback *feedback = 0 );
%Docstring
Constructor for QgsTINInterpolator.
Constructor for QgsTinInterpolator.
The ``feedback`` object specifies an optional QgsFeedback object for progress reports and cancelation support.
Ownership of ``feedback`` is not transferred and callers must ensure that it exists for the lifetime of this object.
%End
~QgsTINInterpolator();
~QgsTinInterpolator();

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

Expand Down
10 changes: 5 additions & 5 deletions python/plugins/processing/algs/qgis/TinInterpolation.py
Expand Up @@ -41,7 +41,7 @@
QgsProcessingException,
QgsCoordinateReferenceSystem)
from qgis.analysis import (QgsInterpolator,
QgsTINInterpolator,
QgsTinInterpolator,
QgsGridFileWriter)

from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
Expand Down Expand Up @@ -192,14 +192,14 @@ def processAlgorithm(self, parameters, context, feedback):
layerData.append(data)

if method == 0:
interpolationMethod = QgsTINInterpolator.Linear
interpolationMethod = QgsTinInterpolator.Linear
else:
interpolationMethod = QgsTINInterpolator.CloughTocher
interpolationMethod = QgsTinInterpolator.CloughTocher

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

interpolator = QgsTINInterpolator(layerData, interpolationMethod, feedback)
interpolator = QgsTinInterpolator(layerData, interpolationMethod, feedback)
if triangulation_sink is not None:
interpolator.setTriangulationSink(triangulation_sink)

Expand Down
16 changes: 8 additions & 8 deletions src/analysis/interpolation/qgstininterpolator.cpp
Expand Up @@ -32,21 +32,21 @@
#include "qgscurvepolygon.h"
#include "qgsmultisurface.h"

QgsTINInterpolator::QgsTINInterpolator( const QList<LayerData> &inputData, TINInterpolation interpolation, QgsFeedback *feedback )
QgsTinInterpolator::QgsTinInterpolator( const QList<LayerData> &inputData, TinInterpolation interpolation, QgsFeedback *feedback )
: QgsInterpolator( inputData )
, mIsInitialized( false )
, mFeedback( feedback )
, mInterpolation( interpolation )
{
}

QgsTINInterpolator::~QgsTINInterpolator()
QgsTinInterpolator::~QgsTinInterpolator()
{
delete mTriangulation;
delete mTriangleInterpolator;
}

int QgsTINInterpolator::interpolatePoint( double x, double y, double &result, QgsFeedback * )
int QgsTinInterpolator::interpolatePoint( double x, double y, double &result, QgsFeedback * )
{
if ( !mIsInitialized )
{
Expand All @@ -67,17 +67,17 @@ int QgsTINInterpolator::interpolatePoint( double x, double y, double &result, Qg
return 0;
}

QgsFields QgsTINInterpolator::triangulationFields()
QgsFields QgsTinInterpolator::triangulationFields()
{
return Triangulation::triangulationFields();
}

void QgsTINInterpolator::setTriangulationSink( QgsFeatureSink *sink )
void QgsTinInterpolator::setTriangulationSink( QgsFeatureSink *sink )
{
mTriangulationSink = sink;
}

void QgsTINInterpolator::initialize()
void QgsTinInterpolator::initialize()
{
DualEdgeTriangulation *dualEdgeTriangulation = new DualEdgeTriangulation( 100000, nullptr );
if ( mInterpolation == CloughTocher )
Expand Down Expand Up @@ -166,7 +166,7 @@ void QgsTINInterpolator::initialize()
}
}

int QgsTINInterpolator::insertData( const QgsFeature &f, QgsInterpolator::ValueSource source, int attr, SourceType type )
int QgsTinInterpolator::insertData( const QgsFeature &f, QgsInterpolator::ValueSource source, int attr, SourceType type )
{
QgsGeometry g = f.geometry();
if ( g.isNull() || g.isEmpty() )
Expand Down Expand Up @@ -323,7 +323,7 @@ int QgsTINInterpolator::insertData( const QgsFeature &f, QgsInterpolator::ValueS
}


int QgsTINInterpolator::addPointsFromGeometry( const QgsGeometry &g, ValueSource source, double attributeValue )
int QgsTinInterpolator::addPointsFromGeometry( const QgsGeometry &g, ValueSource source, double attributeValue )
{
// loop through all vertices and add to triangulation
for ( auto point = g.vertices_begin(); point != g.vertices_end(); ++point )
Expand Down
23 changes: 13 additions & 10 deletions src/analysis/interpolation/qgstininterpolator.h
Expand Up @@ -31,24 +31,27 @@ class QgsFields;

/**
* \ingroup analysis
* Interpolation in a triangular irregular network*/
class ANALYSIS_EXPORT QgsTINInterpolator: public QgsInterpolator
* Interpolation in a triangular irregular network
* \since QGIS 3.0
*/
class ANALYSIS_EXPORT QgsTinInterpolator: public QgsInterpolator
{
public:
//describes the type of interpolation
enum TINInterpolation

//! Indicates the type of interpolation to be performed
enum TinInterpolation
{
Linear,
CloughTocher
Linear, //!< Linear interpolation
CloughTocher, //!< Clough-Tocher interpolation
};

/**
* Constructor for QgsTINInterpolator.
* Constructor for QgsTinInterpolator.
* The \a feedback object specifies an optional QgsFeedback object for progress reports and cancelation support.
* Ownership of \a feedback is not transferred and callers must ensure that it exists for the lifetime of this object.
*/
QgsTINInterpolator( const QList<QgsInterpolator::LayerData> &inputData, TINInterpolation interpolation = Linear, QgsFeedback *feedback = nullptr );
~QgsTINInterpolator();
QgsTinInterpolator( const QList<QgsInterpolator::LayerData> &inputData, TinInterpolation interpolation = Linear, QgsFeedback *feedback = nullptr );
~QgsTinInterpolator();

int interpolatePoint( double x, double y, double &result, QgsFeedback *feedback ) override;

Expand Down Expand Up @@ -81,7 +84,7 @@ class ANALYSIS_EXPORT QgsTINInterpolator: public QgsInterpolator
//! Feature sink for triangulation
QgsFeatureSink *mTriangulationSink = nullptr;
//! Type of interpolation
TINInterpolation mInterpolation;
TinInterpolation mInterpolation;

//! Create dual edge triangulation
void initialize();
Expand Down

0 comments on commit 8631472

Please sign in to comment.