QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 <QVector>
22 #include <QList>
23 
24 #include "qgis_sip.h"
25 #include "qgis_analysis.h"
27 
28 class QgsFeatureSource;
29 class QgsGeometry;
30 class QgsFeedback;
31 
32 #ifdef SIP_RUN
33 % ModuleHeaderCode
34 #include "qgsinterpolator.h"
35 % End
36 #endif
37 
42 struct ANALYSIS_EXPORT QgsInterpolatorVertexData
43 {
44 
49  QgsInterpolatorVertexData( double x, double y, double z )
50  : x( x )
51  , y( y )
52  , z( z )
53  {}
54 
56  QgsInterpolatorVertexData() = default;
57 
59  double x = 0.0;
61  double y = 0.0;
63  double z = 0.0;
64 };
65 
74 class ANALYSIS_EXPORT QgsInterpolator
75 {
76  public:
77 
80  {
84  };
85 
88  {
92  };
93 
95  enum Result
96  {
97  Success = 0,
101  };
102 
104  struct LayerData
105  {
107  QgsFeatureSource *source = nullptr;
111  int interpolationAttribute = -1;
113  QgsInterpolator::SourceType sourceType = SourcePoints;
114 
121  };
122 
123  QgsInterpolator( const QList<QgsInterpolator::LayerData> &layerData );
124 
125  virtual ~QgsInterpolator() = default;
126 
135  virtual int interpolatePoint( double x, double y, double &result SIP_OUT, QgsFeedback *feedback = nullptr ) = 0;
136 
138  QList<LayerData> layerData() const { return mLayerData; } SIP_SKIP
139 
140  protected:
141 
151  Result cacheBaseData( QgsFeedback *feedback = nullptr );
152 
154  QVector<QgsInterpolatorVertexData> mCachedBaseData;
155 
157  bool mDataIsCached = false;
158 
160  QList<LayerData> mLayerData;
161 
162  private:
163  QgsInterpolator() = delete;
164 
172  bool addVerticesToCache( const QgsGeometry &geom, ValueSource source, double attributeValue );
173 };
174 
175 #endif
QgsInterpolator::FeatureGeometryError
@ FeatureGeometryError
Operation failed due to invalid feature geometry.
Definition: qgsinterpolator.h:100
QgsCoordinateTransformContext
Contains information about the context in which a coordinate transform is executed.
Definition: qgscoordinatetransformcontext.h:57
QgsInterpolator::SourceStructureLines
@ SourceStructureLines
Structure lines.
Definition: qgsinterpolator.h:82
QgsInterpolator::ValueAttribute
@ ValueAttribute
Take value from feature's attribute.
Definition: qgsinterpolator.h:89
QgsInterpolatorVertexData
Interpolation data for an individual source vertex.
Definition: qgsinterpolator.h:42
qgsinterpolator.h
SIP_OUT
#define SIP_OUT
Definition: qgis_sip.h:58
QgsInterpolator::SourcePoints
@ SourcePoints
Point source.
Definition: qgsinterpolator.h:81
qgscoordinatetransformcontext.h
QgsInterpolator::LayerData
A source together with the information about interpolation attribute / z-coordinate interpolation and...
Definition: qgsinterpolator.h:104
QgsInterpolator::ValueZ
@ ValueZ
Use feature's geometry Z values for interpolation.
Definition: qgsinterpolator.h:90
QgsInterpolatorVertexData::QgsInterpolatorVertexData
QgsInterpolatorVertexData(double x, double y, double z)
Constructor for QgsInterpolatorVertexData with the specified x, y, and z coordinate.
Definition: qgsinterpolator.h:49
QgsFeatureSource
An interface for objects which provide features via a getFeatures method.
Definition: qgsfeaturesource.h:37
QgsInterpolator
Interface class for interpolations.
Definition: qgsinterpolator.h:74
QgsInterpolator::layerData
QList< LayerData > layerData() const
Definition: qgsinterpolator.h:138
QgsInterpolator::mLayerData
QList< LayerData > mLayerData
Information about the input vector layers and the attributes (or z-values) that are used for interpol...
Definition: qgsinterpolator.h:160
QgsInterpolator::Canceled
@ Canceled
Operation was manually canceled.
Definition: qgsinterpolator.h:98
QgsInterpolator::ValueSource
ValueSource
Source for interpolated values from features.
Definition: qgsinterpolator.h:87
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsInterpolator::InvalidSource
@ InvalidSource
Operation failed due to invalid source.
Definition: qgsinterpolator.h:99
QgsFeedback
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:44
qgis_sip.h
QgsInterpolator::mCachedBaseData
QVector< QgsInterpolatorVertexData > mCachedBaseData
Cached vertex data for input sources.
Definition: qgsinterpolator.h:154
QgsInterpolator::LayerData::transformContext
QgsCoordinateTransformContext transformContext
Coordinate transform context.
Definition: qgsinterpolator.h:120
QgsInterpolator::Result
Result
Result of an interpolation operation.
Definition: qgsinterpolator.h:95
QgsInterpolator::SourceType
SourceType
Describes the type of input data.
Definition: qgsinterpolator.h:79
QgsInterpolator::SourceBreakLines
@ SourceBreakLines
Break lines.
Definition: qgsinterpolator.h:83
QgsGeometry
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
QgsInterpolator::ValueM
@ ValueM
Use feature's geometry M values for interpolation.
Definition: qgsinterpolator.h:91