QgsInterpolator class

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 3D types.

Derived classes

class QgsIDWInterpolator
Inverse distance weight interpolator.
class QgsTinInterpolator
Interpolation in a triangular irregular network.

Public types

struct LayerData
A source together with the information about interpolation attribute / z-coordinate interpolation and the type (point, structure line, breakline)
enum Result { Success = 0, Canceled, InvalidSource, FeatureGeometryError }
Result of an interpolation operation.
enum SourceType { SourcePoints, SourceStructureLines, SourceBreakLines }
Describes the type of input data.
enum ValueSource { ValueAttribute, ValueZ, ValueM }
Source for interpolated values from features.

Public functions

auto interpolatePoint(double x, double y, double& result, QgsFeedback* feedback = nullptr) -> int pure virtual
Calculates interpolation value for map coordinates x, y.
auto layerData() const -> QList<LayerData>

Protected functions

auto cacheBaseData(QgsFeedback* feedback = nullptr) -> Result
Caches the vertex and value data from the provider.

Protected variables

QVector<QgsInterpolatorVertexData> mCachedBaseData
Cached vertex data for input sources.
bool mDataIsCached
Flag that tells if the cache already has been filled.
QList<LayerData> mLayerData
Information about the input vector layers and the attributes (or z-values) that are used for interpolation.

Enum documentation

enum QgsInterpolator::Result

Result of an interpolation operation.

Enumerators
Success

Operation was successful.

Canceled

Operation was manually canceled.

InvalidSource

Operation failed due to invalid source.

FeatureGeometryError

Operation failed due to invalid feature geometry.

enum QgsInterpolator::SourceType

Describes the type of input data.

Enumerators
SourcePoints

Point source.

SourceStructureLines

Structure lines.

SourceBreakLines

Break lines.

enum QgsInterpolator::ValueSource

Source for interpolated values from features.

Enumerators
ValueAttribute

Take value from feature's attribute.

ValueZ

Use feature's geometry Z values for interpolation.

ValueM

Use feature's geometry M values for interpolation.

Function documentation

int QgsInterpolator::interpolatePoint(double x, double y, double& result, QgsFeedback* feedback = nullptr) pure virtual

Calculates interpolation value for map coordinates x, y.

Parameters
x x-coordinate (in map units)
y y-coordinate (in map units)
result interpolation result
feedback optional feedback object for progress and cancelation support
Returns 0 in case of success

QList<LayerData> QgsInterpolator::layerData() const

Result QgsInterpolator::cacheBaseData(QgsFeedback* feedback = nullptr) protected

Caches the vertex and value data from the provider.

Returns Success in case of success

All the vertex data will be held in virtual memory.

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