37 return QStringLiteral(
"mesh" );
45 QVector<QgsProfileIdentifyResults> res;
46 res.reserve( noLayerResults.size() );
62 , mProfileCurve( request.profileCurve() ? request.profileCurve()->clone() : nullptr )
63 , mSourceCrs( layer->
crs() )
64 , mTargetCrs( request.
crs() )
65 , mTransformContext( request.transformContext() )
66 , mOffset( layer->elevationProperties()->zOffset() )
67 , mScale( layer->elevationProperties()->zScale() )
69 , mStepDistance( request.stepDistance() )
89 if ( !mProfileCurve || mFeedback->isCanceled() )
93 QgsGeometry transformedCurve( mProfileCurve->clone() );
102 QgsDebugError( QStringLiteral(
"Error transforming profile line to mesh CRS" ) );
106 if ( mFeedback->isCanceled() )
109 mResults = std::make_unique< QgsMeshLayerProfileResults >();
110 mResults->mLayer = mLayer;
112 mResults->copyPropertiesFromGenerator(
this );
115 const double curveLength = transformedCurve.
length();
117 if ( !std::isnan( mStepDistance ) )
122 if ( mFeedback->isCanceled() )
127 if ( mFeedback->isCanceled() )
131 const double height = heightAt( point.
x(), point.
y() );
135 point.
transform( mLayerToTargetTransform );
141 mResults->mRawPoints.append(
QgsPoint( point.
x(), point.
y(), height ) );
144 if ( mFeedback->isCanceled() )
148 QgsGeos originalCurveGeos( mProfileCurve.get() );
151 for (
const QgsPoint &pixel : std::as_const( mResults->mRawPoints ) )
153 if ( mFeedback->isCanceled() )
156 const double distance = originalCurveGeos.
lineLocatePoint( pixel, &lastError );
158 if ( !std::isnan( pixel.z() ) )
160 mResults->minZ = std::min( pixel.z(), mResults->minZ );
161 mResults->maxZ = std::max( pixel.z(), mResults->maxZ );
163 mResults->mDistanceToHeightMap.insert( distance, pixel.z() );
171 return mResults.release();
176 return mFeedback.get();
179double QgsMeshLayerProfileGenerator::heightAt(
double x,
double y )
181 return QgsMeshLayerUtils::interpolateZForPoint( mTriangularMesh, x, y ) * mScale + mOffset;
@ Reverse
Reverse/inverse transform (from destination to source)
Abstract base class for storage of elevation profiles.
Abstract base class for objects which generate elevation profiles which represent a continuous surfac...
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)
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)
const QgsCoordinateReferenceSystem & crs