28 #include <QProgressDialog>
32 , mTriangulation( nullptr )
33 , mTriangleInterpolator( nullptr )
34 , mIsInitialized( false )
35 , mShowProgressDialog( showProgressDialog )
36 , mExportTriangulationToFile( false )
37 , mInterpolation( interpolation )
43 delete mTriangulation;
44 delete mTriangleInterpolator;
49 if ( !mIsInitialized )
54 if ( !mTriangleInterpolator )
60 if ( !mTriangleInterpolator->
calcPoint( x, y, &r ) )
68 void QgsTINInterpolator::initialize()
79 mTriangulation = theDualEdgeTriangulation;
84 int nProcessedFeatures = 0;
85 if ( mShowProgressDialog )
87 Q_FOREACH (
const LayerData& layer,
mLayerData )
89 if ( layer.vectorLayer )
91 nFeatures += layer.vectorLayer->featureCount();
97 if ( mShowProgressDialog )
105 Q_FOREACH (
const LayerData& layer,
mLayerData )
107 if ( layer.vectorLayer )
110 if ( !layer.zCoordInterpolation )
112 attList.
push_back( layer.interpolationAttribute );
119 if ( mShowProgressDialog )
125 theProgressDialog->
setValue( nProcessedFeatures );
127 insertData( &f, layer.zCoordInterpolation, layer.interpolationAttribute, layer.mInputType );
128 ++nProcessedFeatures;
133 delete theProgressDialog;
142 if ( mShowProgressDialog )
148 delete progressDialog;
151 mTriangleInterpolator = ctInterpolator;
158 mIsInitialized =
true;
161 if ( mExportTriangulationToFile )
167 int QgsTINInterpolator::insertData(
QgsFeature* f,
bool zCoord,
int attr, InputType type )
183 double attributeValue = 0;
184 bool attributeConversionOk =
false;
188 if ( !attributeVariant.
isValid() )
192 attributeValue = attributeVariant.
toDouble( &attributeConversionOk );
193 if ( !attributeConversionOk || qIsNaN( attributeValue ) )
200 bool hasZValue =
false;
215 currentWkbPtr >> x >> y;
216 if ( zCoord && hasZValue )
225 if ( mTriangulation->
addPoint( thePoint ) == -100 )
237 currentWkbPtr >> nPoints;
240 currentWkbPtr.readHeader();
241 currentWkbPtr >> x >> y;
263 currentWkbPtr >> nPoints;
266 currentWkbPtr >> x >> y;
267 if ( zCoord && hasZValue )
299 currentWkbPtr >> nLines;
307 currentWkbPtr >> nPoints;
308 for (
int index2 = 0; index2 < nPoints; ++index2 )
310 currentWkbPtr >> x >> y;
343 currentWkbPtr >> nRings;
352 currentWkbPtr >> nPoints;
353 for (
int index2 = 0; index2 < nPoints; ++index2 )
355 currentWkbPtr >> x >> y;
389 currentWkbPtr >> nPolys;
392 currentWkbPtr.readHeader();
394 currentWkbPtr >> nRings;
395 for (
int index2 = 0; index2 < nRings; ++index2 )
402 currentWkbPtr >> nPoints;
403 for (
int index3 = 0; index3 < nPoints; ++index3 )
405 currentWkbPtr >> x >> y;
Decorator class which adds the functionality of estimating normals at the data points.
Wrapper for iterator of features from vector data provider or vector layer.
QList< LayerData > mLayerData
virtual int addPoint(Point3D *p)=0
Adds a point to the triangulation Ownership is transferred to this class.
Interface class for interpolations.
virtual void addTriangulation(Triangulation *t)
Adds an association to a triangulation.
void push_back(const T &value)
virtual void setTriangulation(NormVecDecorator *tin)
LinTriangleInterpolator is a class which interpolates linearly on a triangulation.
void setLabelText(const QString &text)
A geometry is the spatial representation of a feature.
QgsTINInterpolator(const QList< LayerData > &inputData, TIN_INTERPOLATION interpolation=Linear, bool showProgressDialog=false)
WkbType
Used for symbology operations.
This class represents a line.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
double getZ() const
Returns the z-coordinate of the point.
QString tr(const char *sourceText, const char *disambiguation, int n)
DualEdgeTriangulation is an implementation of a triangulation class based on the dual edge data struc...
QgsWKBTypes::Type readHeader() const
void setValue(int progress)
Point3D is a class to represent a three dimensional point.
virtual bool saveAsShapefile(const QString &fileName) const override
Saves the triangulation as a (line) shapefile.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QGis::WkbType wkbType() const
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
virtual void addLine(Line3D *line, bool breakline)=0
Adds a line (e.g.
void setTriangleInterpolator(TriangleInterpolator *inter) override
Sets an interpolator.
bool estimateFirstDerivatives(QProgressDialog *d=nullptr)
This method adds the functionality of estimating normals at the data points.
void insertPoint(Point3D *p)
Inserts a node behind the current position and sets the current position to this new node...
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
int wkbSize() const
Returns the size of the WKB in asWkb().
int interpolatePoint(double x, double y, double &result) override
Calculates interpolation value for map coordinates x, y.
This is an implementation of a Clough-Tocher interpolator based on a triangular tessellation.
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
virtual bool calcPoint(double x, double y, Point3D *result)=0
Performs a linear interpolation in a triangle and assigns the x-,y- and z-coordinates to point...
double toDouble(bool *ok) const
bool nextFeature(QgsFeature &f)
const unsigned char * asWkb() const
Returns the buffer containing this geometry in WKB format.