37 double sumCounter = 0;
38 double sumDenominator = 0;
48 double currentWeight = 1 / ( std::pow( distance, mDistanceCoefficient ) );
49 sumCounter += ( currentWeight * vertex.z );
50 sumDenominator += currentWeight;
53 if ( sumDenominator == 0.0 )
58 result = sumCounter / sumDenominator;
Base class for feedback objects to be used for cancellation of something running in a worker thread.
static double distance2D(double x1, double y1, double x2, double y2)
Returns the 2D distance between (x1, y1) and (x2, y2).
int interpolatePoint(double x, double y, double &result, QgsFeedback *feedback=nullptr) override
Calculates interpolation value for map coordinates x, y.
QgsIDWInterpolator(const QList< QgsInterpolator::LayerData > &layerData)
Constructor for QgsIDWInterpolator, with the specified layerData sources.
QVector< QgsInterpolatorVertexData > mCachedBaseData
Cached vertex data for input sources.
QgsInterpolator(const QList< QgsInterpolator::LayerData > &layerData)
bool mDataIsCached
Flag that tells if the cache already has been filled.
QList< LayerData > layerData() const
Result cacheBaseData(QgsFeedback *feedback=nullptr)
Caches the vertex and value data from the provider.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
Interpolation data for an individual source vertex.