QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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 <QList>
22 #include <QVector>
23 
24 #include "qgis_sip.h"
25 #include "qgis_analysis.h"
26 
27 class QgsFeatureSource;
28 class QgsGeometry;
29 class QgsFeedback;
30 
35 struct ANALYSIS_EXPORT QgsInterpolatorVertexData
36 {
37 
42  QgsInterpolatorVertexData( double x, double y, double z )
43  : x( x )
44  , y( y )
45  , z( z )
46  {}
47 
49  QgsInterpolatorVertexData() = default;
50 
52  double x = 0.0;
54  double y = 0.0;
56  double z = 0.0;
57 };
58 
65 class ANALYSIS_EXPORT QgsInterpolator
66 {
67  public:
68 
71  {
75  };
76 
79  {
83  };
84 
86  enum Result
87  {
88  Success = 0,
92  };
93 
95  struct LayerData
96  {
98  QgsFeatureSource *source = nullptr;
102  int interpolationAttribute = -1;
104  QgsInterpolator::SourceType sourceType = SourcePoints;
105  };
106 
107  QgsInterpolator( const QList<QgsInterpolator::LayerData> &layerData );
108 
109  virtual ~QgsInterpolator() = default;
110 
118  virtual int interpolatePoint( double x, double y, double &result SIP_OUT, QgsFeedback *feedback = nullptr ) = 0;
119 
121  QList<LayerData> layerData() const { return mLayerData; } SIP_SKIP
122 
123  protected:
124 
134  Result cacheBaseData( QgsFeedback *feedback = nullptr );
135 
137  QVector<QgsInterpolatorVertexData> mCachedBaseData;
138 
140  bool mDataIsCached = false;
141 
143  QList<LayerData> mLayerData;
144 
145  private:
146  QgsInterpolator() = delete;
147 
155  bool addVerticesToCache( const QgsGeometry &geom, ValueSource source, double attributeValue );
156 };
157 
158 #endif
QList< LayerData > mLayerData
Information about the input vector layers and the attributes (or z-values) that are used for interpol...
Interface class for interpolations.
Operation failed due to invalid source.
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:106
SourceType
Describes the type of input data.
Operation was manually canceled.
Interpolation data for an individual source vertex.
Base class for feedback objects to be used for cancellation of something running in a worker thread...
Definition: qgsfeedback.h:44
ValueSource
Source for interpolated values from features.
Take value from feature&#39;s attribute.
QVector< QgsInterpolatorVertexData > mCachedBaseData
Cached vertex data for input sources.
#define SIP_SKIP
Definition: qgis_sip.h:119
Use feature&#39;s geometry Z values for interpolation.
Result
Result of an interpolation operation.
A source together with the information about interpolation attribute / z-coordinate interpolation and...
QList< LayerData > layerData() const
An interface for objects which provide features via a getFeatures method.
#define SIP_OUT
Definition: qgis_sip.h:51
Use feature&#39;s geometry M values for interpolation.
Operation failed due to invalid feature geometry.
QgsInterpolatorVertexData(double x, double y, double z)
Constructor for QgsInterpolatorVertexData with the specified x, y, and z coordinate.