QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 
36 struct ANALYSIS_EXPORT QgsInterpolatorVertexData
37 {
38 
43  QgsInterpolatorVertexData( double x, double y, double z )
44  : x( x )
45  , y( y )
46  , z( z )
47  {}
48 
50  QgsInterpolatorVertexData() = default;
51 
53  double x = 0.0;
55  double y = 0.0;
57  double z = 0.0;
58 };
59 
66 class ANALYSIS_EXPORT QgsInterpolator
67 {
68  public:
69 
72  {
76  };
77 
80  {
84  };
85 
87  enum Result
88  {
89  Success = 0,
93  };
94 
96  struct LayerData
97  {
99  QgsFeatureSource *source = nullptr;
103  int interpolationAttribute = -1;
105  QgsInterpolator::SourceType sourceType = SourcePoints;
106 
113  };
114 
115  QgsInterpolator( const QList<QgsInterpolator::LayerData> &layerData );
116 
117  virtual ~QgsInterpolator() = default;
118 
127  virtual int interpolatePoint( double x, double y, double &result SIP_OUT, QgsFeedback *feedback = nullptr ) = 0;
128 
130  QList<LayerData> layerData() const { return mLayerData; } SIP_SKIP
131 
132  protected:
133 
143  Result cacheBaseData( QgsFeedback *feedback = nullptr );
144 
146  QVector<QgsInterpolatorVertexData> mCachedBaseData;
147 
149  bool mDataIsCached = false;
150 
152  QList<LayerData> mLayerData;
153 
154  private:
155  QgsInterpolator() = delete;
156 
164  bool addVerticesToCache( const QgsGeometry &geom, ValueSource source, double attributeValue );
165 };
166 
167 #endif
QgsInterpolator::FeatureGeometryError
@ FeatureGeometryError
Operation failed due to invalid feature geometry.
Definition: qgsinterpolator.h:92
QgsCoordinateTransformContext
Definition: qgscoordinatetransformcontext.h:57
QgsInterpolator::SourceStructureLines
@ SourceStructureLines
Structure lines.
Definition: qgsinterpolator.h:74
QgsInterpolator::ValueAttribute
@ ValueAttribute
Take value from feature's attribute.
Definition: qgsinterpolator.h:81
QgsInterpolatorVertexData
Interpolation data for an individual source vertex.
Definition: qgsinterpolator.h:36
SIP_OUT
#define SIP_OUT
Definition: qgis_sip.h:58
QgsInterpolator::SourcePoints
@ SourcePoints
Point source.
Definition: qgsinterpolator.h:73
qgscoordinatetransformcontext.h
QgsInterpolator::LayerData
A source together with the information about interpolation attribute / z-coordinate interpolation and...
Definition: qgsinterpolator.h:96
QgsInterpolator::ValueZ
@ ValueZ
Use feature's geometry Z values for interpolation.
Definition: qgsinterpolator.h:82
QgsInterpolatorVertexData::QgsInterpolatorVertexData
QgsInterpolatorVertexData(double x, double y, double z)
Constructor for QgsInterpolatorVertexData with the specified x, y, and z coordinate.
Definition: qgsinterpolator.h:43
QgsFeatureSource
Definition: qgsfeaturesource.h:37
QgsInterpolator
Definition: qgsinterpolator.h:66
QgsInterpolator::layerData
QList< LayerData > layerData() const
Definition: qgsinterpolator.h:130
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:152
QgsInterpolator::Canceled
@ Canceled
Operation was manually canceled.
Definition: qgsinterpolator.h:90
QgsInterpolator::ValueSource
ValueSource
Source for interpolated values from features.
Definition: qgsinterpolator.h:79
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsInterpolator::InvalidSource
@ InvalidSource
Operation failed due to invalid source.
Definition: qgsinterpolator.h:91
QgsFeedback
Definition: qgsfeedback.h:43
qgis_sip.h
QgsInterpolator::mCachedBaseData
QVector< QgsInterpolatorVertexData > mCachedBaseData
Cached vertex data for input sources.
Definition: qgsinterpolator.h:146
QgsInterpolator::LayerData::transformContext
QgsCoordinateTransformContext transformContext
Coordinate transform context.
Definition: qgsinterpolator.h:112
QgsInterpolator::Result
Result
Result of an interpolation operation.
Definition: qgsinterpolator.h:87
QgsInterpolator::SourceType
SourceType
Describes the type of input data.
Definition: qgsinterpolator.h:71
QgsInterpolator::SourceBreakLines
@ SourceBreakLines
Break lines.
Definition: qgsinterpolator.h:75
QgsGeometry
Definition: qgsgeometry.h:122
QgsInterpolator::ValueM
@ ValueM
Use feature's geometry M values for interpolation.
Definition: qgsinterpolator.h:83