QGIS API Documentation 3.99.0-Master (21b3aa880ba)
Loading...
Searching...
No Matches
qgsinterpolator.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsinterpolator.h
3 ------------------------
4 begin : March 10, 2008
5 copyright : (C) 2008 by Marco Hugentobler
6 email : marco dot hugentobler at karto dot baug dot ethz dot ch
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSINTERPOLATOR_H
19#define QGSINTERPOLATOR_H
20
21#include "qgis_analysis.h"
22#include "qgis_sip.h"
24
25#include <QList>
26#include <QVector>
27
29class QgsGeometry;
30class QgsFeedback;
31
32#ifdef SIP_RUN
33//%ModuleHeaderCode
34#include "qgsinterpolator.h"
35//%End
36#endif
37
41struct ANALYSIS_EXPORT QgsInterpolatorVertexData
42{
43
48 QgsInterpolatorVertexData( double x, double y, double z )
49 : x( x )
50 , y( y )
51 , z( z )
52 {}
53
55
57 double x = 0.0;
59 double y = 0.0;
61 double z = 0.0;
62};
63
72class ANALYSIS_EXPORT QgsInterpolator
73{
74 public:
77 {
79 StructureLines SIP_MONKEYPATCH_COMPAT_NAME( SourceStructureLines ),
80 BreakLines SIP_MONKEYPATCH_COMPAT_NAME( SourceBreakLines ),
81 };
82
90
92 enum class Result : int
93 {
94 Success = 0,
95 Canceled,
96 InvalidSource,
97 FeatureGeometryError,
98 };
99
119
120 QgsInterpolator( const QList<QgsInterpolator::LayerData> &layerData );
121
122 virtual ~QgsInterpolator() = default;
123
132 virtual int interpolatePoint( double x, double y, double &result SIP_OUT, QgsFeedback *feedback = nullptr ) = 0;
133
135 QList<LayerData> layerData() const SIP_SKIP { return mLayerData; }
136
137 protected:
138
148 Result cacheBaseData( QgsFeedback *feedback = nullptr );
149
151 QVector<QgsInterpolatorVertexData> mCachedBaseData;
152
154 bool mDataIsCached = false;
155
157 QList<LayerData> mLayerData;
158
159 private:
160 QgsInterpolator() = delete;
161
169 bool addVerticesToCache( const QgsGeometry &geom, ValueSource source, double attributeValue );
170};
171
172#endif
Contains information about the context in which a coordinate transform is executed.
An interface for objects which provide features via a getFeatures method.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
A geometry is the spatial representation of a feature.
QVector< QgsInterpolatorVertexData > mCachedBaseData
Cached vertex data for input sources.
virtual int interpolatePoint(double x, double y, double &result, QgsFeedback *feedback=nullptr)=0
Calculates interpolation value for map coordinates x, y.
QgsInterpolator(const QList< QgsInterpolator::LayerData > &layerData)
ValueSource
Source for interpolated values from features.
@ Attribute
Take value from feature's attribute.
SourceType
Describes the type of input data.
bool mDataIsCached
Flag that tells if the cache already has been filled.
QList< LayerData > layerData() const
QList< LayerData > mLayerData
Information about the input vector layers and the attributes (or z-values) that are used for interpol...
virtual ~QgsInterpolator()=default
Result
Result of an interpolation operation.
@ Points
Point based rendering, requires point data.
#define SIP_SKIP
Definition qgis_sip.h:134
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
Definition qgis_sip.h:268
#define SIP_OUT
Definition qgis_sip.h:58
#define SIP_MONKEYPATCH_COMPAT_NAME(FORMERNAME)
Definition qgis_sip.h:270
QgsInterpolatorVertexData()=default
double y
Y-coordinate.
QgsInterpolatorVertexData(double x, double y, double z)
Constructor for QgsInterpolatorVertexData with the specified x, y, and z coordinate.
double z
Z-coordinate.
double x
X-coordinate.
A source together with the information about interpolation attribute / z-coordinate interpolation and...
QgsFeatureSource * source
Feature source.
QgsInterpolator::ValueSource valueSource
Source for feature values to interpolate.
QgsInterpolator::SourceType sourceType
Source type.
QgsCoordinateTransformContext transformContext
Coordinate transform context.
int interpolationAttribute
Index of feature attribute to use for interpolation.