QGIS API Documentation 3.99.0-Master (a8f284845db)
Loading...
Searching...
No Matches
qgspointcloudlayerprofilegenerator.h
Go to the documentation of this file.
1/***************************************************************************
2 qgspointcloudlayerprofilegenerator.h
3 ---------------
4 begin : April 2022
5 copyright : (C) 2022 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#ifndef QGSPOINTCLOUDLAYERPROFILEGENERATOR_H
18#define QGSPOINTCLOUDLAYERPROFILEGENERATOR_H
19
20
21#include <geos_c.h>
22#include <memory>
23
24#include "qgis_core.h"
31#include "qgspointcloudindex.h"
33
34#define SIP_NO_FILE
35
37class QgsCurve;
38class QgsGeos;
47
48
49
58{
59
60 public:
61
64
66 {
67 double x = 0;
68 double y = 0;
69 double z = 0;
71 double distanceFromCurve = 0; // only used when the opacity by distance effect is enabled
72 QRgb color;
73 };
74
78 void finalize( QgsFeedback *feedback );
79
80 std::vector< PointResult > results;
81 double tolerance = 0;
82
83 double minZ = std::numeric_limits< double >::max();
84 double maxZ = std::numeric_limits< double >::lowest();
85
86 double pointSize = 1;
89 bool respectLayerColors = true;
90 QColor pointColor;
92
93 QString type() const override;
94 QMap< double, double > distanceToHeightMap() const override;
95 QgsDoubleRange zRange() const override;
96 QgsPointSequence sampledPoints() const override;
97 QVector< QgsGeometry > asGeometries() const override;
98 QVector< QgsAbstractProfileResults::Feature > asFeatures( Qgis::ProfileExportType type, QgsFeedback *feedback = nullptr ) const override;
99 void renderResults( QgsProfileRenderContext &context ) override;
100 QgsProfileSnapResult snapPoint( const QgsProfilePoint &point, const QgsProfileSnapContext &context ) override;
101 QVector<QgsProfileIdentifyResults> identify( const QgsProfilePoint &point, const QgsProfileIdentifyContext &context ) override;
102 QVector<QgsProfileIdentifyResults> identify( const QgsDoubleRange &distanceRange, const QgsDoubleRange &elevationRange, const QgsProfileIdentifyContext &context ) override;
103 void copyPropertiesFromGenerator( const QgsAbstractProfileGenerator *generator ) override;
104
105 private:
106
107 GEOSSTRtree *mPointIndex = nullptr;
108 QPointer< QgsPointCloudLayer > mLayer;
110 std::unique_ptr< QgsCurve > mProfileCurve;
111 double mTolerance = 0;
112 double mZOffset = 0;
113 double mZScale = 1.0;
114 double mMaxErrorInLayerCoordinates = 0;
115 QString mLayerId;
116
118};
119
120
129{
130 public:
136
137 protected:
138
153 bool collectData( QgsGeos &curve, const double mapUnitsPerPixel, const double maximumErrorPixels, const QgsDoubleRange &zRange, double &maxErrorInLayerCrs );
154
168 void gatherPoints( QgsPointCloudIndex &pc, QgsPointCloudRequest &request, double maxErrorPixels, double nodeErrorPixels, const QgsDoubleRange &zRange, const QgsRectangle &searchExtent );
169
185 QVector<QgsPointCloudNodeId> traverseTree( QgsPointCloudIndex &pc, QgsPointCloudNodeId n, double maxErrorPixels, double nodeErrorPixels, const QgsDoubleRange &zRange, const QgsRectangle &searchExtent );
186
199 int visitNodesSync( const QVector<QgsPointCloudNodeId> &nodes, QgsPointCloudIndex &pc, QgsPointCloudRequest &request, const QgsDoubleRange &zRange );
200
213 int visitNodesAsync( const QVector<QgsPointCloudNodeId> &nodes, QgsPointCloudIndex &pc, QgsPointCloudRequest &request, const QgsDoubleRange &zRange );
214
224 virtual void visitBlock( const QgsPointCloudBlock *block, const QgsDoubleRange &zRange ) = 0;
225
226 QPointer< QgsPointCloudLayer > mLayer;
228 const QVector< QgsPointCloudSubIndex > mSubIndexes;
230 std::unique_ptr< QgsPointCloudRenderer > mRenderer;
231
234
235 QString mId;
236
237 std::unique_ptr<QgsFeedback> mFeedback = nullptr;
238
239 double mTolerance = 0;
240
244
245 double mStepDistance = std::numeric_limits<double>::quiet_NaN();
246
247 double mZOffset = 0;
248 double mZScale = 1.0;
249
251 std::unique_ptr< QgsCurve > mProfileCurve;
252
253 std::unique_ptr< QgsPreparedPointCloudRendererData > mPreparedRendererData;
254 std::unique_ptr< QgsGeos > mSearchGeometryInLayerCrsGeometryEngine;
255};
256
265{
266
267 public:
268
273
275
276 QString sourceId() const override;
277 Qgis::ProfileGeneratorFlags flags() const override;
280 QgsFeedback *feedback() const override;
281 QString type() const override;
282
283 private:
284 void visitBlock( const QgsPointCloudBlock *block, const QgsDoubleRange &zRange ) override;
285
286 double mPointSize = 1;
289 QColor mPointColor;
290 bool mOpacityByDistanceEffect = false;
291
292 std::unique_ptr< QgsAbstractGeometry > mSearchGeometryInLayerCrs;
293 std::unique_ptr< QgsPointCloudLayerProfileResults > mResults;
294 QVector< QgsPointCloudLayerProfileResults::PointResult > mGatheredPoints;
295
297};
298
307{
308
309 public:
310
311 QString type() const override;
313 QVector<QgsProfileIdentifyResults> identify( const QgsProfilePoint &point, const QgsProfileIdentifyContext &context ) override;
314 void copyPropertiesFromGenerator( const QgsAbstractProfileGenerator *generator ) override;
315 void renderResults( QgsProfileRenderContext &context ) override;
316
317 private:
318 QPointer< QgsPointCloudLayer > mLayer;
319 QString mLayerId;
321 std::unique_ptr< QgsCurve > mProfileCurve;
322 double mTolerance = 0.0;
323 double mZOffset = 0.0;
324 double mZScale = 1.0;
325
327};
328
329
338{
339
340 public:
341
346
348
349 QString sourceId() const override;
350 bool generateProfile( const QgsProfileGenerationContext &context ) override;
352 QgsFeedback *feedback() const override;
353 QString type() const override;
354
355 private:
356 void visitBlock( const QgsPointCloudBlock *block, const QgsDoubleRange &zRange ) override;
357
358 std::unique_ptr< QgsTriangulatedPointCloudLayerProfileResults > mResults;
359 std::unique_ptr< QgsAbstractGeometry > mSearchGeometryInLayerCrs;
360 QVector< QgsPoint > mGatheredPoints;
361
363 std::unique_ptr< QgsLineSymbol > mLineSymbol;
364 std::unique_ptr< QgsFillSymbol > mFillSymbol;
365 double mElevationLimit = std::numeric_limits< double >::quiet_NaN();
366
368};
369
370
371#endif // QGSPOINTCLOUDLAYERPROFILEGENERATOR_H
PointCloudSymbol
Rendering symbols for point cloud points.
Definition qgis.h:4355
@ Square
Renders points as squares.
Definition qgis.h:4356
QFlags< ProfileGeneratorFlag > ProfileGeneratorFlags
Definition qgis.h:4333
RenderUnit
Rendering size units.
Definition qgis.h:5305
@ Millimeters
Millimeters.
Definition qgis.h:5306
ProfileExportType
Types of export for elevation profiles.
Definition qgis.h:4342
ProfileSurfaceSymbology
Surface symbology type for elevation profile plots.
Definition qgis.h:4290
@ Line
The elevation surface will be rendered using a line symbol.
Definition qgis.h:4291
Abstract base class for objects which generate elevation profiles.
Abstract base class for storage of elevation profiles.
virtual QgsDoubleRange zRange() const =0
Returns the range of the retrieved elevation values.
virtual void renderResults(QgsProfileRenderContext &context)=0
Renders the results to the specified context.
virtual QMap< double, double > distanceToHeightMap() const =0
Returns the map of distance (chainage) to height.
virtual QString type() const =0
Returns the unique string identifier for the results type.
virtual QVector< QgsAbstractProfileResults::Feature > asFeatures(Qgis::ProfileExportType type, QgsFeedback *feedback=nullptr) const
Returns a list of features representing the calculated elevation results.
virtual QgsPointSequence sampledPoints() const =0
Returns a list of sampled points, with their calculated elevation as the point z value.
virtual QgsProfileSnapResult snapPoint(const QgsProfilePoint &point, const QgsProfileSnapContext &context)
Snaps a point to the generated elevation profile.
virtual QVector< QgsProfileIdentifyResults > identify(const QgsProfilePoint &point, const QgsProfileIdentifyContext &context)
Identify results visible at the specified profile point.
virtual QVector< QgsGeometry > asGeometries() const =0
Returns a list of geometries representing the calculated elevation results.
virtual void copyPropertiesFromGenerator(const QgsAbstractProfileGenerator *generator)
Copies properties from specified generator to the results object.
Abstract base class for storage of elevation profiles which represent a continuous surface (e....
QVector< QgsProfileIdentifyResults > identify(const QgsProfilePoint &point, const QgsProfileIdentifyContext &context) override
Identify results visible at the specified profile point.
Abstract base class for terrain providers.
Represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
Handles coordinate transforms between two coordinate systems.
Abstract base class for curved geometry type.
Definition qgscurve.h:36
QgsRange which stores a range of double values.
Definition qgsrange.h:236
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
Does vector analysis using the GEOS library and handles import, export, and exception handling.
Definition qgsgeos.h:141
A collection of point cloud attributes.
Base class for storing raw data from point cloud nodes.
Smart pointer for QgsAbstractPointCloudIndex.
QVector< QgsPointCloudNodeId > traverseTree(QgsPointCloudIndex &pc, QgsPointCloudNodeId n, double maxErrorPixels, double nodeErrorPixels, const QgsDoubleRange &zRange, const QgsRectangle &searchExtent)
Recursively traverses the point cloud node tree to gather visible nodes.
virtual ~QgsPointCloudLayerProfileGeneratorBase() override
std::unique_ptr< QgsPointCloudRenderer > mRenderer
virtual void visitBlock(const QgsPointCloudBlock *block, const QgsDoubleRange &zRange)=0
Visits a point cloud block and collects points within the given Z range and search geometry.
const QVector< QgsPointCloudSubIndex > mSubIndexes
void gatherPoints(QgsPointCloudIndex &pc, QgsPointCloudRequest &request, double maxErrorPixels, double nodeErrorPixels, const QgsDoubleRange &zRange, const QgsRectangle &searchExtent)
Collects points from the point cloud index within the given extent and Z range.
int visitNodesAsync(const QVector< QgsPointCloudNodeId > &nodes, QgsPointCloudIndex &pc, QgsPointCloudRequest &request, const QgsDoubleRange &zRange)
Asynchronously visits point cloud nodes, loading their data and processing valid blocks.
bool collectData(QgsGeos &curve, const double mapUnitsPerPixel, const double maximumErrorPixels, const QgsDoubleRange &zRange, double &maxErrorInLayerCrs)
Collects point cloud data along a curve within the specified range and tolerance.
QgsPointCloudLayerProfileGeneratorBase(QgsPointCloudLayer *layer, const QgsProfileRequest &request)
Constructor for QgsPointCloudLayerProfileGeneratorBase.
std::unique_ptr< QgsPreparedPointCloudRendererData > mPreparedRendererData
int visitNodesSync(const QVector< QgsPointCloudNodeId > &nodes, QgsPointCloudIndex &pc, QgsPointCloudRequest &request, const QgsDoubleRange &zRange)
Synchronously visits point cloud nodes and processes their data.
Qgis::ProfileGeneratorFlags flags() const override
Returns flags which reflect how the profile generator operates.
QgsPointCloudLayerProfileGenerator(QgsPointCloudLayer *layer, const QgsProfileRequest &request)
Constructor for QgsPointCloudLayerProfileGenerator.
QString sourceId() const override
Returns a unique identifier representing the source of the profile.
QgsFeedback * feedback() const override
Access to feedback object of the generator (may be nullptr).
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).
void finalize(QgsFeedback *feedback)
Finalizes results – should be called after last point is added.
QString type() const override
Returns the unique string identifier for the results type.
Represents a map layer supporting display of point clouds.
Represents an indexed point cloud node's position in octree.
Abstract base class for 2d point cloud renderers.
Point cloud data request.
Base class for 2d point cloud renderer prepared data containers.
Encapsulates the context in which an elevation profile is to be generated.
Encapsulates the context of identifying profile results.
Encapsulates a point on a distance-elevation profile.
Abstract base class for storage of elevation profiles.
Encapsulates properties and constraints relating to fetching elevation profiles from different source...
Encapsulates the context of snapping a profile point.
Encapsulates results of snapping a profile point.
A rectangle specified with double values.
QgsAbstractProfileResults * takeResults() override
Takes results from the generator.
QgsFeedback * feedback() const override
Access to feedback object of the generator (may be nullptr).
bool generateProfile(const QgsProfileGenerationContext &context) 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.
QgsTriangulatedPointCloudLayerProfileGenerator(QgsPointCloudLayer *layer, const QgsProfileRequest &request)
Constructor for QgsTriangulatedPointCloudLayerProfileGenerator.
Implementation of QgsAbstractProfileSurfaceResults for triangulated point cloud layers.
QVector< QgsPoint > QgsPointSequence