37 return QStringLiteral(
"mesh" );
45 QVector<QgsProfileIdentifyResults> res;
46 res.reserve( noLayerResults.size() );
61 , mProfileCurve( request.profileCurve() ? request.profileCurve()->clone() : nullptr )
62 , mSourceCrs( layer->
crs() )
63 , mTargetCrs( request.
crs() )
64 , mTransformContext( request.transformContext() )
65 , mOffset( layer->elevationProperties()->zOffset() )
66 , mScale( layer->elevationProperties()->zScale() )
68 , mStepDistance( request.stepDistance() )
87 if ( !mProfileCurve || mFeedback->isCanceled() )
91 QgsGeometry transformedCurve( mProfileCurve->clone() );
96 transformedCurve.
transform( mLayerToTargetTransform, Qgis::TransformDirection::Reverse );
100 QgsDebugMsg( QStringLiteral(
"Error transforming profile line to mesh CRS" ) );
104 if ( mFeedback->isCanceled() )
107 mResults = std::make_unique< QgsMeshLayerProfileResults >();
108 mResults->mLayer = mLayer;
109 mResults->copyPropertiesFromGenerator(
this );
112 const double curveLength = transformedCurve.
length();
114 if ( !std::isnan( mStepDistance ) )
119 if ( mFeedback->isCanceled() )
124 if ( mFeedback->isCanceled() )
128 const double height = heightAt( point.
x(), point.
y() );
132 point.
transform( mLayerToTargetTransform );
138 mResults->mRawPoints.append(
QgsPoint( point.
x(), point.
y(), height ) );
141 if ( mFeedback->isCanceled() )
145 QgsGeos originalCurveGeos( mProfileCurve.get() );
148 for (
const QgsPoint &pixel : std::as_const( mResults->mRawPoints ) )
150 if ( mFeedback->isCanceled() )
153 const double distance = originalCurveGeos.
lineLocatePoint( pixel, &lastError );
155 if ( !std::isnan( pixel.z() ) )
157 mResults->minZ = std::min( pixel.z(), mResults->minZ );
158 mResults->maxZ = std::max( pixel.z(), mResults->maxZ );
160 mResults->mDistanceToHeightMap.insert( distance, pixel.z() );
168 return mResults.release();
173 return mFeedback.get();
176double QgsMeshLayerProfileGenerator::heightAt(
double x,
double y )
178 return QgsMeshLayerUtils::interpolateZForPoint( mTriangularMesh, x, y ) * mScale + mOffset;
Abstract base class for storage of elevation profiles.
std::unique_ptr< QgsLineSymbol > mLineSymbol
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) SIP_THROW(QgsCsException)
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, 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 SIP_THROW(QgsCsException)
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...
const QgsCoordinateReferenceSystem & crs