37 , mIsInitialized( false )
38 , mFeedback( feedback )
39 , mInterpolation( interpolation )
45 delete mTriangulation;
46 delete mTriangleInterpolator;
51 if ( !mIsInitialized )
56 if ( !mTriangleInterpolator )
62 if ( !mTriangleInterpolator->
calcPoint( x, y, r ) )
77 mTriangulationSink = sink;
80 void QgsTinInterpolator::initialize()
91 mTriangulation = dualEdgeTriangulation;
96 int nProcessedFeatures = 0;
103 nFeatures += layer.source->featureCount();
114 switch ( layer.valueSource )
117 attList.push_back( layer.interpolationAttribute );
136 mFeedback->
setProgress( 100.0 * static_cast< double >( nProcessedFeatures ) / nFeatures );
138 insertData( f, layer.valueSource, layer.interpolationAttribute, layer.sourceType );
139 ++nProcessedFeatures;
153 mTriangleInterpolator = ctInterpolator;
160 mIsInitialized =
true;
163 if ( mTriangulationSink )
178 double attributeValue = 0;
179 bool attributeConversionOk =
false;
184 QVariant attributeVariant = f.
attribute( attr );
185 if ( !attributeVariant.isValid() )
189 attributeValue = attributeVariant.toDouble( &attributeConversionOk );
190 if ( !attributeConversionOk || std::isnan( attributeValue ) )
215 if ( addPointsFromGeometry( g, source, attributeValue ) != 0 )
227 if ( addPointsFromGeometry( g, source, attributeValue ) != 0 )
236 std::vector<const QgsCurve *> curves;
239 std::vector< const QgsCurvePolygon * > polygons;
245 polygons.emplace_back( qgsgeometry_cast< const QgsCurvePolygon * >( ms->
geometryN( i ) ) );
250 polygons.emplace_back( qgsgeometry_cast< const QgsCurvePolygon * >( g.
constGet() ) );
258 if ( polygon->exteriorRing() )
259 curves.emplace_back( polygon->exteriorRing() );
261 for (
int i = 0; i < polygon->numInteriorRings(); ++i )
263 curves.emplace_back( polygon->interiorRing( i ) );
274 curves.emplace_back( qgsgeometry_cast< const QgsCurve * >( mc->
geometryN( i ) ) );
279 curves.emplace_back( qgsgeometry_cast< const QgsCurve * >( g.
constGet() ) );
283 for (
const QgsCurve *curve : curves )
288 QVector< QgsPoint > linePoints;
308 linePoints.append(
QgsPoint( p.
x(), p.
y(), z ) );
310 mTriangulation->
addLine( linePoints, type );
326 int QgsTinInterpolator::addPointsFromGeometry(
const QgsGeometry &g,
ValueSource source,
double attributeValue )
bool isMeasure() const
Returns true if the geometry contains m values.
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
Information about the input vector layers and the attributes (or z-values) that are used for interpol...
~QgsTinInterpolator() override
Interface class for interpolations.
bool isMultipart() const
Returns true if WKB of the geometry is of WKBMulti* type.
virtual void addTriangulation(Triangulation *t)
Adds an association to a triangulation.
LinTriangleInterpolator is a class which interpolates linearly on a triangulation.
QgsWkbTypes::Type wkbType() const
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
void setProgress(double progress)
Sets the current progress for the feedback object.
An interface for objects which accept features via addFeature(s) methods.
Curve polygon geometry type.
Clough-Tocher interpolation.
Container of fields for a vector layer.
virtual void setTriangulation(NormVecDecorator *tin)
A geometry is the spatial representation of a feature.
SourceType
Describes the type of input data.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Multi surface geometry collection.
DualEdgeTriangulation is an implementation of a triangulation class based on the dual edge data struc...
Base class for feedback objects to be used for cancellation of something running in a worker thread...
ValueSource
Source for interpolated values from features.
Take value from feature's attribute.
static QgsFields triangulationFields()
Returns the fields output by features when saving the triangulation.
static GeometryType geometryType(Type type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
bool saveTriangulation(QgsFeatureSink *sink, QgsFeedback *feedback=nullptr) const override
Saves the triangulation features to a feature sink.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
T qgsgeometry_cast(const QgsAbstractGeometry *geom)
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
Multi curve geometry collection.
Abstract base class for curved geometry type.
int interpolatePoint(double x, double y, double &result, QgsFeedback *feedback) override
Calculates interpolation value for map coordinates x, y.
void setTriangleInterpolator(TriangleInterpolator *inter) override
Sets an interpolator.
Point geometry type, with support for z-dimension and m-values.
Use feature's geometry Z values for interpolation.
virtual bool calcPoint(double x, double y, QgsPoint &result)=0
Performs a linear interpolation in a triangle and assigns the x-,y- and z-coordinates to point...
int numGeometries() const
Returns the number of geometries within the collection.
virtual int addPoint(const QgsPoint &point)=0
Adds a point to the triangulation.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
A source together with the information about interpolation attribute / z-coordinate interpolation and...
TinInterpolation
Indicates the type of interpolation to be performed.
QgsTinInterpolator(const QList< QgsInterpolator::LayerData > &inputData, TinInterpolation interpolation=Linear, QgsFeedback *feedback=nullptr)
Constructor for QgsTinInterpolator.
bool isCanceled() const
Tells whether the operation has been canceled already.
void setTriangulationSink(QgsFeatureSink *sink)
Sets the optional sink for saving the triangulation features.
static QgsFields triangulationFields()
Returns the fields output by features when calling saveTriangulation().
Use feature's geometry M values for interpolation.
This is an implementation of a Clough-Tocher interpolator based on a triangular tessellation.
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
virtual void addLine(const QVector< QgsPoint > &points, QgsInterpolator::SourceType lineType)=0
Adds a line (e.g.
QList< int > QgsAttributeList
bool nextFeature(QgsFeature &f)
bool estimateFirstDerivatives(QgsFeedback *feedback=nullptr)
This method adds the functionality of estimating normals at the data points. Return true in the case ...
QgsAbstractGeometry::vertex_iterator vertices_end() const
Returns STL-style iterator pointing to the imaginary vertex after the last vertex of the geometry...
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
QgsAbstractGeometry::vertex_iterator vertices_begin() const
Returns STL-style iterator pointing to the first vertex of the geometry.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.