QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
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();
176 double QgsMeshLayerProfileGenerator::heightAt(
double x,
double y )
178 return QgsMeshLayerUtils::interpolateZForPoint( mTriangularMesh, x, y ) * mScale + mOffset;
Encapsulates the context of identifying profile results.
Point geometry type, with support for z-dimension and m-values.
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.
std::unique_ptr< QgsFillSymbol > mFillSymbol
const QgsCoordinateReferenceSystem & crs
QString type() const override
Returns the unique string identifier for the results type.
QgsFeedback * feedback() const override
Access to feedback object of the generator (may be nullptr)
bool generateProfile(const QgsProfileGenerationContext &context=QgsProfileGenerationContext()) override
Generate the profile (based on data stored in the class).
QgsTriangularMesh * triangularMesh(double minimumTriangleSize=0) const
Returns triangular mesh (nullptr before rendering or calling to updateMesh).
Encapsulates a point on a distance-elevation profile.
Encapsulates the context in which an elevation profile is to be generated.
void updateTriangularMesh(const QgsCoordinateTransform &transform=QgsCoordinateTransform())
Gets native mesh and updates (creates if it doesn't exist) the base triangular mesh.
Stores identify results generated by a QgsAbstractProfileResults object.
Qgis::ProfileSurfaceSymbology mSymbology
Custom exception class for Coordinate Reference System related exceptions.
QgsMeshLayerProfileGenerator(QgsMeshLayer *layer, const QgsProfileRequest &request)
Constructor for QgsMeshLayerProfileGenerator.
std::unique_ptr< QgsLineSymbol > mLineSymbol
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.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Does vector analysis using the geos library and handles import, export, exception handling*.
QgsAbstractProfileResults * takeResults() override
Takes results from the generator.
~QgsMeshLayerProfileGenerator() override
QgsGeometry densifyByDistance(double distance) const
Densifies the geometry by adding regularly placed extra nodes inside each segment so that the maximum...
Encapsulates properties and constraints relating to fetching elevation profiles from different source...
double length() const
Returns the planar, 2-dimensional length of geometry.
QVector< QgsProfileIdentifyResults > identify(const QgsProfilePoint &point, const QgsProfileIdentifyContext &context) override
Identify results visible at the specified profile point.
A geometry is the spatial representation of a feature.
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...
Abstract base class for storage of elevation profiles.
QString sourceId() const override
Returns a unique identifier representing the source of the profile.
QgsAbstractGeometry::vertex_iterator vertices_end() const
Returns STL-style iterator pointing to the imaginary vertex after the last vertex of the geometry.
QgsMapLayerElevationProperties * elevationProperties() override
Returns the layer's elevation properties.
QgsAbstractGeometry::vertex_iterator vertices_begin() const
Returns STL-style iterator pointing to the first vertex of the geometry.
void prepareGeometry() override
Prepares the geometry, so that subsequent calls to spatial relation methods are much faster.
QVector< QgsProfileIdentifyResults > identify(const QgsProfilePoint &point, const QgsProfileIdentifyContext &context) override
Identify results visible at the specified profile point.