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;
95 long long nFeatures = 0;
96 long long nProcessedFeatures = 0;
99 for (
const LayerData &layer : std::as_const(
mLayerData ) )
103 nFeatures += layer.source->featureCount();
111 for (
const LayerData &layer : std::as_const(
mLayerData ) )
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() || attributeVariant.isNull() )
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( mc->
curveN( i ) );
281 curves.emplace_back( qgsgeometry_cast< const QgsCurve * >( g.
constGet() ) );
285 for (
const QgsCurve *curve : curves )
291 curve->points( linePoints );
292 for (
QgsPoint &point : linePoints )
298 point.setZ( attributeValue );
300 point.addZValue( attributeValue );
305 point.setZ( point.m() );
307 point.addZValue( point.m() );
314 mTriangulation->
addLine( linePoints, type );
330 int QgsTinInterpolator::addPointsFromGeometry(
const QgsGeometry &g, ValueSource source,
double attributeValue )
This is an implementation of a Clough-Tocher interpolator based on a triangular tessellation.
virtual void setTriangulation(NormVecDecorator *tin)
LinTriangleInterpolator is a class which interpolates linearly on a triangulation.
Decorator class which adds the functionality of estimating normals at the data points.
void setTriangleInterpolator(TriangleInterpolator *inter) override
Sets an interpolator.
bool estimateFirstDerivatives(QgsFeedback *feedback=nullptr)
This method adds the functionality of estimating normals at the data points. Return true in the case ...
bool is3D() const SIP_HOLDGIL
Returns true if the geometry is 3D and contains a z-value.
bool isMeasure() const SIP_HOLDGIL
Returns true if the geometry contains m values.
This class represents a coordinate reference system (CRS).
Curve polygon geometry type.
Abstract base class for curved geometry type.
DualEdgeTriangulation is an implementation of a triangulation class based on the dual edge data struc...
bool saveTriangulation(QgsFeatureSink *sink, QgsFeedback *feedback=nullptr) const override
Saves the triangulation features to a feature sink.
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
This class wraps a request for features to a vector layer (or directly its vector data provider).
An interface for objects which accept features via addFeature(s) methods.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
QVariant attribute(const QString &name) const
Lookup attribute value by attribute name.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
bool isCanceled() const SIP_HOLDGIL
Tells whether the operation has been canceled already.
void setProgress(double progress)
Sets the current progress for the feedback object.
Container of fields for a vector layer.
int numGeometries() const SIP_HOLDGIL
Returns the number of geometries within the collection.
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
A geometry is the spatial representation of a feature.
const QgsAbstractGeometry * constGet() const SIP_HOLDGIL
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
QgsWkbTypes::Type wkbType() const SIP_HOLDGIL
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
bool isMultipart() const SIP_HOLDGIL
Returns true if WKB of the geometry is of WKBMulti* type.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
QgsAbstractGeometry::vertex_iterator vertices_begin() const
Returns STL-style iterator pointing to the first vertex of the geometry.
QgsAbstractGeometry::vertex_iterator vertices_end() const
Returns STL-style iterator pointing to the imaginary vertex after the last vertex of the geometry.
Interface class for interpolations.
ValueSource
Source for interpolated values from features.
@ ValueM
Use feature's geometry M values for interpolation.
@ ValueAttribute
Take value from feature's attribute.
@ ValueZ
Use feature's geometry Z values for interpolation.
@ SourcePoints
Point source.
@ SourceStructureLines
Structure lines.
@ SourceBreakLines
Break lines.
QList< LayerData > mLayerData
Information about the input vector layers and the attributes (or z-values) that are used for interpol...
Multi curve geometry collection.
QgsCurve * curveN(int index)
Returns the curve with the specified index.
Multi surface geometry collection.
Point geometry type, with support for z-dimension and m-values.
QgsTinInterpolator(const QList< QgsInterpolator::LayerData > &inputData, TinInterpolation interpolation=Linear, QgsFeedback *feedback=nullptr)
Constructor for QgsTinInterpolator.
TinInterpolation
Indicates the type of interpolation to be performed.
@ CloughTocher
Clough-Tocher interpolation.
~QgsTinInterpolator() override
int interpolatePoint(double x, double y, double &result, QgsFeedback *feedback) override
Calculates interpolation value for map coordinates x, y.
static QgsFields triangulationFields()
Returns the fields output by features when saving the triangulation.
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().
virtual void addLine(const QgsPointSequence &points, QgsInterpolator::SourceType lineType)=0
Adds a line (e.g.
virtual int addPoint(const QgsPoint &point)=0
Adds a point to the triangulation.
static GeometryType geometryType(Type type) SIP_HOLDGIL
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
virtual void addTriangulation(QgsTriangulation *t)
Adds an association to a triangulation.
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.
QVector< QgsPoint > QgsPointSequence
QList< int > QgsAttributeList
const QgsCoordinateReferenceSystem & crs