QGIS API Documentation 3.99.0-Master (8e76e220402)
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"
25#include "qgis_sip.h"
31#include "qgsgeos.h"
32#include "qgslinesymbol.h"
34#include "qgspointcloudindex.h"
36#include "qgsvector3d.h"
37
39class QgsCurve;
48class QgsGeos;
50
51#define SIP_NO_FILE
52
53
62{
63
64 public:
65
68
70 {
71 double x = 0;
72 double y = 0;
73 double z = 0;
75 double distanceFromCurve = 0; // only used when the opacity by distance effect is enabled
76 QRgb color;
77 };
78
82 void finalize( QgsFeedback *feedback );
83
84 std::vector< PointResult > results;
85 double tolerance = 0;
86
87 double minZ = std::numeric_limits< double >::max();
88 double maxZ = std::numeric_limits< double >::lowest();
89
90 double pointSize = 1;
93 bool respectLayerColors = true;
94 QColor pointColor;
96
97 QString type() const override;
98 QMap< double, double > distanceToHeightMap() const override;
99 QgsDoubleRange zRange() const override;
100 QgsPointSequence sampledPoints() const override;
101 QVector< QgsGeometry > asGeometries() const override;
102 QVector< QgsAbstractProfileResults::Feature > asFeatures( Qgis::ProfileExportType type, QgsFeedback *feedback = nullptr ) const override;
103 void renderResults( QgsProfileRenderContext &context ) override;
104 QgsProfileSnapResult snapPoint( const QgsProfilePoint &point, const QgsProfileSnapContext &context ) override;
105 QVector<QgsProfileIdentifyResults> identify( const QgsProfilePoint &point, const QgsProfileIdentifyContext &context ) override;
106 QVector<QgsProfileIdentifyResults> identify( const QgsDoubleRange &distanceRange, const QgsDoubleRange &elevationRange, const QgsProfileIdentifyContext &context ) override;
107 void copyPropertiesFromGenerator( const QgsAbstractProfileGenerator *generator ) override;
108
109 private:
110
111 GEOSSTRtree *mPointIndex = nullptr;
112 QPointer< QgsPointCloudLayer > mLayer;
114 std::unique_ptr< QgsCurve > mProfileCurve;
115 double mTolerance = 0;
116 double mZOffset = 0;
117 double mZScale = 1.0;
118 double mMaxErrorInLayerCoordinates = 0;
119 QString mLayerId;
120
122};
123
124
133{
134 public:
140
141 protected:
142
157 bool collectData( QgsGeos &curve, const double mapUnitsPerPixel, const double maximumErrorPixels, const QgsDoubleRange &zRange, double &maxErrorInLayerCrs );
158
172 void gatherPoints( QgsPointCloudIndex &pc, QgsPointCloudRequest &request, double maxErrorPixels, double nodeErrorPixels, const QgsDoubleRange &zRange, const QgsRectangle &searchExtent );
173
189 QVector<QgsPointCloudNodeId> traverseTree( QgsPointCloudIndex &pc, QgsPointCloudNodeId n, double maxErrorPixels, double nodeErrorPixels, const QgsDoubleRange &zRange, const QgsRectangle &searchExtent );
190
203 int visitNodesSync( const QVector<QgsPointCloudNodeId> &nodes, QgsPointCloudIndex &pc, QgsPointCloudRequest &request, const QgsDoubleRange &zRange );
204
217 int visitNodesAsync( const QVector<QgsPointCloudNodeId> &nodes, QgsPointCloudIndex &pc, QgsPointCloudRequest &request, const QgsDoubleRange &zRange );
218
228 virtual void visitBlock( const QgsPointCloudBlock *block, const QgsDoubleRange &zRange ) = 0;
229
230 QPointer< QgsPointCloudLayer > mLayer;
232 const QVector< QgsPointCloudSubIndex > mSubIndexes;
234 std::unique_ptr< QgsPointCloudRenderer > mRenderer;
235
238
239 QString mId;
240
241 std::unique_ptr<QgsFeedback> mFeedback = nullptr;
242
243 double mTolerance = 0;
244
248
249 double mStepDistance = std::numeric_limits<double>::quiet_NaN();
250
251 double mZOffset = 0;
252 double mZScale = 1.0;
253
255 std::unique_ptr< QgsCurve > mProfileCurve;
256
257 std::unique_ptr< QgsPreparedPointCloudRendererData > mPreparedRendererData;
258 std::unique_ptr< QgsGeos > mSearchGeometryInLayerCrsGeometryEngine;
259};
260
269{
270
271 public:
272
277
279
280 QString sourceId() const override;
281 Qgis::ProfileGeneratorFlags flags() const override;
284 QgsFeedback *feedback() const override;
285 QString type() const override;
286
287 private:
288 void visitBlock( const QgsPointCloudBlock *block, const QgsDoubleRange &zRange ) override;
289
290 double mPointSize = 1;
293 QColor mPointColor;
294 bool mOpacityByDistanceEffect = false;
295
296 std::unique_ptr< QgsAbstractGeometry > mSearchGeometryInLayerCrs;
297 std::unique_ptr< QgsPointCloudLayerProfileResults > mResults;
298 QVector< QgsPointCloudLayerProfileResults::PointResult > mGatheredPoints;
299
301};
302
311{
312
313 public:
314
315 QString type() const override;
317 QVector<QgsProfileIdentifyResults> identify( const QgsProfilePoint &point, const QgsProfileIdentifyContext &context ) override;
318 void copyPropertiesFromGenerator( const QgsAbstractProfileGenerator *generator ) override;
319 void renderResults( QgsProfileRenderContext &context ) override;
320
321 private:
322 QPointer< QgsPointCloudLayer > mLayer;
323 QString mLayerId;
325 std::unique_ptr< QgsCurve > mProfileCurve;
326 double mTolerance = 0.0;
327 double mZOffset = 0.0;
328 double mZScale = 1.0;
329
331};
332
333
342{
343
344 public:
345
350
352
353 QString sourceId() const override;
354 bool generateProfile( const QgsProfileGenerationContext &context ) override;
356 QgsFeedback *feedback() const override;
357 QString type() const override;
358
359 private:
360 void visitBlock( const QgsPointCloudBlock *block, const QgsDoubleRange &zRange ) override;
361
362 std::unique_ptr< QgsTriangulatedPointCloudLayerProfileResults > mResults;
363 std::unique_ptr< QgsAbstractGeometry > mSearchGeometryInLayerCrs;
364 QVector< QgsPoint > mGatheredPoints;
365
367 std::unique_ptr< QgsLineSymbol > mLineSymbol;
368 std::unique_ptr< QgsFillSymbol > mFillSymbol;
369 double mElevationLimit = std::numeric_limits< double >::quiet_NaN();
370
372};
373
374
375#endif // QGSPOINTCLOUDLAYERPROFILEGENERATOR_H
PointCloudSymbol
Rendering symbols for point cloud points.
Definition qgis.h:4340
@ Square
Renders points as squares.
Definition qgis.h:4341
QFlags< ProfileGeneratorFlag > ProfileGeneratorFlags
Definition qgis.h:4318
RenderUnit
Rendering size units.
Definition qgis.h:5290
@ Millimeters
Millimeters.
Definition qgis.h:5291
ProfileExportType
Types of export for elevation profiles.
Definition qgis.h:4327
ProfileSurfaceSymbology
Surface symbology type for elevation profile plots.
Definition qgis.h:4275
@ Line
The elevation surface will be rendered using a line symbol.
Definition qgis.h:4276
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