28 #include <QProgressDialog>
33 , mTriangleInterpolator( 0 )
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 )
88 for ( ; layerDataIt !=
mLayerData.end(); ++layerDataIt )
90 if ( layerDataIt->vectorLayer )
92 nFeatures += layerDataIt->vectorLayer->featureCount();
98 if ( mShowProgressDialog )
107 for ( ; layerDataIt !=
mLayerData.end(); ++layerDataIt )
109 if ( layerDataIt->vectorLayer )
112 if ( !layerDataIt->zCoordInterpolation )
114 attList.
push_back( layerDataIt->interpolationAttribute );
121 if ( mShowProgressDialog )
127 theProgressDialog->
setValue( nProcessedFeatures );
129 insertData( &f, layerDataIt->zCoordInterpolation, layerDataIt->interpolationAttribute, layerDataIt->mInputType );
130 ++nProcessedFeatures;
135 delete theProgressDialog;
144 if ( mShowProgressDialog )
150 delete progressDialog;
153 mTriangleInterpolator = ctInterpolator;
160 mIsInitialized =
true;
163 if ( mExportTriangulationToFile )
169 int QgsTINInterpolator::insertData(
QgsFeature* f,
bool zCoord,
int attr, InputType type )
185 double attributeValue = 0;
186 bool attributeConversionOk =
false;
190 if ( !attributeVariant.
isValid() )
194 attributeValue = attributeVariant.
toDouble( &attributeConversionOk );
195 if ( !attributeConversionOk || qIsNaN( attributeValue ) )
202 bool hasZValue =
false;
215 currentWkbPtr >> x >> y;
216 if ( zCoord && hasZValue )
225 if ( mTriangulation->
addPoint( thePoint ) == -100 )
236 currentWkbPtr >> nPoints;
239 currentWkbPtr += 1 +
sizeof( int );
240 currentWkbPtr >> x >> y;
261 currentWkbPtr >> nPoints;
264 currentWkbPtr >> x >> y;
265 if ( zCoord && hasZValue )
296 currentWkbPtr >> nLines;
304 currentWkbPtr >> nPoints;
305 for (
int index2 = 0; index2 < nPoints; ++index2 )
307 currentWkbPtr >> x >> y;
339 currentWkbPtr >> nRings;
348 currentWkbPtr >> nPoints;
349 for (
int index2 = 0; index2 < nPoints; ++index2 )
351 currentWkbPtr >> x >> y;
384 currentWkbPtr >> nPolys;
387 currentWkbPtr += 1 +
sizeof( int );
389 currentWkbPtr >> nRings;
390 for (
int index2 = 0; index2 < nRings; ++index2 )
397 currentWkbPtr >> nPoints;
398 for (
int index3 = 0; index3 < nPoints; ++index3 )
400 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.
WkbType
Used for symbology operations.
QgsTINInterpolator(const QList< LayerData > &inputData, TIN_INTERPOLATION interpolation=Linear, bool showProgressDialog=false)
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...
void setValue(int progress)
Point3D is a class to represent a three dimensional point.
bool estimateFirstDerivatives(QProgressDialog *d=0)
This method adds the functionality of estimating normals at the data points.
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.
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 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.