34 double sumCounter = 0;
35 double sumDenominator = 0;
39 double distance = std::sqrt( ( vertex.x - x ) * ( vertex.x - x ) + ( vertex.y - y ) * ( vertex.y - y ) );
45 double currentWeight = 1 / ( std::pow( distance, mDistanceCoefficient ) );
46 sumCounter += ( currentWeight * vertex.z );
47 sumDenominator += currentWeight;
50 if ( sumDenominator == 0.0 )
55 result = sumCounter / sumDenominator;
Interface class for interpolations.
int interpolatePoint(double x, double y, double &result, QgsFeedback *feedback=nullptr) override
Calculates interpolation value for map coordinates x, y.
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Compare two doubles (but allow some difference)
Interpolation data for an individual source vertex.
Base class for feedback objects to be used for cancelation of something running in a worker thread...
QVector< QgsInterpolatorVertexData > mCachedBaseData
Cached vertex data for input sources.
QgsIDWInterpolator(const QList< QgsInterpolator::LayerData > &layerData)
Constructor for QgsIDWInterpolator, with the specified layerData sources.
bool mDataIsCached
Flag that tells if the cache already has been filled.
Result cacheBaseData(QgsFeedback *feedback=nullptr)
Caches the vertex and value data from the provider.