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();
116 switch ( layer.valueSource )
119 attList.push_back( layer.interpolationAttribute );
138 mFeedback->
setProgress( 100.0 * static_cast< double >( nProcessedFeatures ) / nFeatures );
140 insertData( f, layer.valueSource, layer.interpolationAttribute, layer.sourceType );
141 ++nProcessedFeatures;
155 mTriangleInterpolator = ctInterpolator;
162 mIsInitialized =
true;
165 if ( mTriangulationSink )
180 double attributeValue = 0;
181 bool attributeConversionOk =
false;
186 QVariant attributeVariant = f.
attribute( attr );
187 if ( !attributeVariant.isValid() )
191 attributeValue = attributeVariant.toDouble( &attributeConversionOk );
192 if ( !attributeConversionOk || std::isnan( attributeValue ) )
217 if ( addPointsFromGeometry( g, source, attributeValue ) != 0 )
229 if ( addPointsFromGeometry( g, source, attributeValue ) != 0 )
238 std::vector<const QgsCurve *> curves;
241 std::vector< const QgsCurvePolygon * > polygons;
247 polygons.emplace_back( qgsgeometry_cast< const QgsCurvePolygon * >( ms->
geometryN( i ) ) );
252 polygons.emplace_back( qgsgeometry_cast< const QgsCurvePolygon * >( g.
constGet() ) );
260 if ( polygon->exteriorRing() )
261 curves.emplace_back( polygon->exteriorRing() );
263 for (
int i = 0; i < polygon->numInteriorRings(); ++i )
265 curves.emplace_back( polygon->interiorRing( i ) );
276 curves.emplace_back( qgsgeometry_cast< const QgsCurve * >( mc->
geometryN( i ) ) );
281 curves.emplace_back( qgsgeometry_cast< const QgsCurve * >( g.
constGet() ) );
285 for (
const QgsCurve *curve : curves )
290 QVector< QgsPoint > linePoints;
310 linePoints.append(
QgsPoint( p.
x(), p.
y(), z ) );
312 mTriangulation->
addLine( linePoints, type );
328 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...
const QgsCoordinateReferenceSystem & crs
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.
This class represents a coordinate reference system (CRS).
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.