38 return QStringLiteral(
"mesh" );
46 QVector<QgsProfileIdentifyResults> res;
47 res.reserve( noLayerResults.size() );
63 , mProfileCurve( request.profileCurve() ? request.profileCurve()->clone() : nullptr )
64 , mSourceCrs( layer->crs() )
65 , mTargetCrs( request.crs() )
66 , mTransformContext( request.transformContext() )
67 , mOffset( layer->elevationProperties()->zOffset() )
68 , mScale( layer->elevationProperties()->zScale() )
70 , mStepDistance( request.stepDistance() )
90 if ( !mProfileCurve || mFeedback->isCanceled() )
94 QgsGeometry transformedCurve( mProfileCurve->clone() );
103 QgsDebugError( QStringLiteral(
"Error transforming profile line to mesh CRS" ) );
107 if ( mFeedback->isCanceled() )
110 mResults = std::make_unique< QgsMeshLayerProfileResults >();
111 mResults->mLayer = mLayer;
113 mResults->copyPropertiesFromGenerator(
this );
116 const double curveLength = transformedCurve.
length();
118 if ( !std::isnan( mStepDistance ) )
123 if ( mFeedback->isCanceled() )
128 if ( mFeedback->isCanceled() )
132 const double height = heightAt( point.
x(), point.
y() );
136 point.
transform( mLayerToTargetTransform );
142 mResults->mRawPoints.append(
QgsPoint( point.
x(), point.
y(), height ) );
145 if ( mFeedback->isCanceled() )
149 QgsGeos originalCurveGeos( mProfileCurve.get() );
152 for (
const QgsPoint &pixel : std::as_const( mResults->mRawPoints ) )
154 if ( mFeedback->isCanceled() )
157 const double distance = originalCurveGeos.
lineLocatePoint( pixel, &lastError );
159 if ( !std::isnan( pixel.z() ) )
161 mResults->minZ = std::min( pixel.z(), mResults->minZ );
162 mResults->maxZ = std::max( pixel.z(), mResults->maxZ );
164 mResults->mDistanceToHeightMap.insert( distance, pixel.z() );
172 return mResults.release();
177 return mFeedback.get();
180double QgsMeshLayerProfileGenerator::heightAt(
double x,
double y )
182 return QgsMeshLayerUtils::interpolateZForPoint( mTriangularMesh, x, y ) * mScale + mOffset;
@ Reverse
Reverse/inverse transform (from destination to source).
Abstract base class for storage of elevation profiles.
std::unique_ptr< QgsLineSymbol > mLineSymbol
QgsAbstractProfileSurfaceGenerator(const QgsProfileRequest &request)
Constructor for QgsAbstractProfileSurfaceGenerator.
Qgis::ProfileSurfaceSymbology mSymbology
std::unique_ptr< QgsFillSymbol > mFillSymbol
QVector< QgsProfileIdentifyResults > identify(const QgsProfilePoint &point, const QgsProfileIdentifyContext &context) override
Identify results visible at the specified profile point.
Custom exception class for Coordinate Reference System related exceptions.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
A geometry is the spatial representation of a feature.
double length() const
Returns the planar, 2-dimensional length of geometry.
QgsGeometry densifyByDistance(double distance) const
Densifies the geometry by adding regularly placed extra nodes inside each segment so that the maximum...
Qgis::GeometryOperationResult transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool transformZ=false)
Transforms this geometry as described by the coordinate transform ct.
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.
Does vector analysis using the GEOS library and handles import, export, and exception handling.
void prepareGeometry() override
Prepares the geometry, so that subsequent calls to spatial relation methods are much faster.
double lineLocatePoint(const QgsPoint &point, QString *errorMsg=nullptr) const
Returns a distance representing the location along this linestring of the closest point on this lines...
~QgsMeshLayerProfileGenerator() override
QgsFeedback * feedback() const override
Access to feedback object of the generator (may be nullptr).
QgsMeshLayerProfileGenerator(QgsMeshLayer *layer, const QgsProfileRequest &request)
Constructor for QgsMeshLayerProfileGenerator.
QgsAbstractProfileResults * takeResults() override
Takes results from the generator.
bool generateProfile(const QgsProfileGenerationContext &context=QgsProfileGenerationContext()) override
Generate the profile (based on data stored in the class).
QString sourceId() const override
Returns a unique identifier representing the source of the profile.
QString type() const override
Returns the unique string identifier for the results type.
QVector< QgsProfileIdentifyResults > identify(const QgsProfilePoint &point, const QgsProfileIdentifyContext &context) override
Identify results visible at the specified profile point.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
void updateTriangularMesh(const QgsCoordinateTransform &transform=QgsCoordinateTransform())
Gets native mesh and updates (creates if it doesn't exist) the base triangular mesh.
QgsMapLayerElevationProperties * elevationProperties() override
Returns the layer's elevation properties.
QgsTriangularMesh * triangularMesh(double minimumTriangleSize=0) const
Returns triangular mesh (nullptr before rendering or calling to updateMesh).
Point geometry type, with support for z-dimension and m-values.
void transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection d=Qgis::TransformDirection::Forward, bool transformZ=false) override
Transforms the geometry using a coordinate transform.
Encapsulates the context in which an elevation profile is to be generated.
Encapsulates the context of identifying profile results.
Stores identify results generated by a QgsAbstractProfileResults object.
Encapsulates a point on a distance-elevation profile.
Encapsulates properties and constraints relating to fetching elevation profiles from different source...
#define QgsDebugError(str)