/
qgsinterpolator.h
98 lines (79 loc) · 3.38 KB
/
qgsinterpolator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/***************************************************************************
qgsinterpolator.h
------------------------
begin : March 10, 2008
copyright : (C) 2008 by Marco Hugentobler
email : marco dot hugentobler at karto dot baug dot ethz dot ch
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSINTERPOLATOR_H
#define QGSINTERPOLATOR_H
#include <QVector>
#include "qgis_analysis.h"
class QgsVectorLayer;
class QgsGeometry;
struct ANALYSIS_EXPORT vertexData
{
double x;
double y;
double z;
};
/** \ingroup analysis
* Interface class for interpolations. Interpolators take
the vertices of a vector layer as base data. The z-Value
can be an attribute or the z-coordinates in case of 25D types*/
class ANALYSIS_EXPORT QgsInterpolator
{
public:
//! Describes the type of input data
enum InputType
{
POINTS,
STRUCTURE_LINES,
BREAK_LINES
};
//! A layer together with the information about interpolation attribute / z-coordinate interpolation and the type (point, structure line, breakline)
struct LayerData
{
QgsVectorLayer *vectorLayer = nullptr;
bool zCoordInterpolation;
int interpolationAttribute;
InputType mInputType;
};
QgsInterpolator( const QList<LayerData> &layerData );
virtual ~QgsInterpolator() = default;
/** Calculates interpolation value for map coordinates x, y
\param x x-coordinate (in map units)
\param y y-coordinate (in map units)
\param result out: interpolation result
\return 0 in case of success*/
virtual int interpolatePoint( double x, double y, double &result ) = 0;
//! \note not available in Python bindings
QList<LayerData> layerData() const { return mLayerData; }
protected:
/** Caches the vertex and value data from the provider. All the vertex data
will be held in virtual memory
\return 0 in case of success*/
int cacheBaseData();
QVector<vertexData> mCachedBaseData;
//! Flag that tells if the cache already has been filled
bool mDataIsCached;
//Information about the input vector layers and the attributes (or z-values) that are used for interpolation
QList<LayerData> mLayerData;
private:
QgsInterpolator(); //forbidden
/** Helper method that adds the vertices of a geometry to the mCachedBaseData
\param geom the geometry
\param zCoord true if the z-coordinate of the geometry is to be interpolated
\param attributeValue the attribute value for interpolation (if not interpolated from z-coordinate)
\return 0 in case of success*/
int addVerticesToCache( const QgsGeometry &geom, bool zCoord, double attributeValue );
};
#endif