QGIS API Documentation  3.37.0-Master (a5b4d9743e8)
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 
41 struct ANALYSIS_EXPORT QgsInterpolatorVertexData
42 {
43 
48  QgsInterpolatorVertexData( double x, double y, double z )
49  : x( x )
50  , y( y )
51  , z( z )
52  {}
53 
56 
58  double x = 0.0;
60  double y = 0.0;
62  double z = 0.0;
63 };
64 
73 class ANALYSIS_EXPORT QgsInterpolator
74 {
75  public:
76 
79  {
83  };
84 
87  {
91  };
92 
94  enum Result
95  {
96  Success = 0,
100  };
101 
103  struct LayerData
104  {
106  QgsFeatureSource *source = nullptr;
110  int interpolationAttribute = -1;
112  QgsInterpolator::SourceType sourceType = SourcePoints;
113 
120  };
121 
122  QgsInterpolator( const QList<QgsInterpolator::LayerData> &layerData );
123 
124  virtual ~QgsInterpolator() = default;
125 
134  virtual int interpolatePoint( double x, double y, double &result SIP_OUT, QgsFeedback *feedback = nullptr ) = 0;
135 
137  QList<LayerData> layerData() const { return mLayerData; } SIP_SKIP
138 
139  protected:
140 
150  Result cacheBaseData( QgsFeedback *feedback = nullptr );
151 
153  QVector<QgsInterpolatorVertexData> mCachedBaseData;
154 
156  bool mDataIsCached = false;
157 
159  QList<LayerData> mLayerData;
160 
161  private:
162  QgsInterpolator() = delete;
163 
171  bool addVerticesToCache( const QgsGeometry &geom, ValueSource source, double attributeValue );
172 };
173 
174 #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.
Definition: qgsgeometry.h:162
Interface class for interpolations.
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.
ValueSource
Source for interpolated values from features.
@ ValueM
Use feature's geometry M values for interpolation.
@ ValueAttribute
Take value from feature's attribute.
@ ValueZ
Use feature's geometry Z values for interpolation.
Result
Result of an interpolation operation.
@ Canceled
Operation was manually canceled.
@ InvalidSource
Operation failed due to invalid source.
@ FeatureGeometryError
Operation failed due to invalid feature geometry.
SourceType
Describes the type of input data.
@ SourcePoints
Point source.
@ SourceStructureLines
Structure lines.
@ SourceBreakLines
Break lines.
QList< LayerData > mLayerData
Information about the input vector layers and the attributes (or z-values) that are used for interpol...
virtual ~QgsInterpolator()=default
QList< LayerData > layerData() const
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_OUT
Definition: qgis_sip.h:58
Interpolation data for an individual source vertex.
QgsInterpolatorVertexData()=default
Constructor for QgsInterpolatorVertexData.
QgsInterpolatorVertexData(double x, double y, double z)
Constructor for QgsInterpolatorVertexData with the specified x, y, and z coordinate.
A source together with the information about interpolation attribute / z-coordinate interpolation and...
QgsCoordinateTransformContext transformContext
Coordinate transform context.