QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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
57{
58 public:
61
63 {
64 double x = 0;
65 double y = 0;
66 double z = 0;
68 double distanceFromCurve = 0; // only used when the opacity by distance effect is enabled
69 QRgb color;
70 };
71
75 void finalize( QgsFeedback *feedback );
76
77 std::vector< PointResult > results;
78 double tolerance = 0;
79
80 double minZ = std::numeric_limits< double >::max();
81 double maxZ = std::numeric_limits< double >::lowest();
82
83 double pointSize = 1;
86 bool respectLayerColors = true;
87 QColor pointColor;
89
90 QString type() const override;
91 QMap< double, double > distanceToHeightMap() const override;
92 QgsDoubleRange zRange() const override;
93 QgsPointSequence sampledPoints() const override;
94 QVector< QgsGeometry > asGeometries() const override;
95 QVector< QgsAbstractProfileResults::Feature > asFeatures( Qgis::ProfileExportType type, QgsFeedback *feedback = nullptr ) const override;
96 void renderResults( QgsProfileRenderContext &context ) override;
97 QgsProfileSnapResult snapPoint( const QgsProfilePoint &point, const QgsProfileSnapContext &context ) override;
98 QVector<QgsProfileIdentifyResults> identify( const QgsProfilePoint &point, const QgsProfileIdentifyContext &context ) override;
99 QVector<QgsProfileIdentifyResults> identify( const QgsDoubleRange &distanceRange, const QgsDoubleRange &elevationRange, const QgsProfileIdentifyContext &context ) override;
100 void copyPropertiesFromGenerator( const QgsAbstractProfileGenerator *generator ) override;
101
102 private:
103 GEOSSTRtree *mPointIndex = nullptr;
104 QPointer< QgsPointCloudLayer > mLayer;
106 std::unique_ptr< QgsCurve > mProfileCurve;
107 double mTolerance = 0;
108 double mZOffset = 0;
109 double mZScale = 1.0;
110 double mMaxErrorInLayerCoordinates = 0;
111 QString mLayerId;
112
114};
115
116
125{
126 public:
132
133 protected:
148 bool collectData( QgsGeos &curve, const double mapUnitsPerPixel, const double maximumErrorPixels, const QgsDoubleRange &zRange, double &maxErrorInLayerCrs );
149
163 void gatherPoints( QgsPointCloudIndex &pc, QgsPointCloudRequest &request, double maxErrorPixels, double nodeErrorPixels, const QgsDoubleRange &zRange, const QgsRectangle &searchExtent );
164
180 QVector<QgsPointCloudNodeId> traverseTree( QgsPointCloudIndex &pc, QgsPointCloudNodeId n, double maxErrorPixels, double nodeErrorPixels, const QgsDoubleRange &zRange, const QgsRectangle &searchExtent );
181
194 int visitNodesSync( const QVector<QgsPointCloudNodeId> &nodes, QgsPointCloudIndex &pc, QgsPointCloudRequest &request, const QgsDoubleRange &zRange );
195
208 int visitNodesAsync( const QVector<QgsPointCloudNodeId> &nodes, QgsPointCloudIndex &pc, QgsPointCloudRequest &request, const QgsDoubleRange &zRange );
209
219 virtual void visitBlock( const QgsPointCloudBlock *block, const QgsDoubleRange &zRange ) = 0;
220
221 QPointer< QgsPointCloudLayer > mLayer;
223 const QVector< QgsPointCloudSubIndex > mSubIndexes;
225 std::unique_ptr< QgsPointCloudRenderer > mRenderer;
226
229
230 QString mId;
231
232 std::unique_ptr<QgsFeedback> mFeedback = nullptr;
233
234 double mTolerance = 0;
235
239
240 double mStepDistance = std::numeric_limits<double>::quiet_NaN();
241
242 double mZOffset = 0;
243 double mZScale = 1.0;
244
246 std::unique_ptr< QgsCurve > mProfileCurve;
247
248 std::unique_ptr< QgsPreparedPointCloudRendererData > mPreparedRendererData;
249 std::unique_ptr< QgsGeos > mSearchGeometryInLayerCrsGeometryEngine;
250};
251
260{
261 public:
266
268
269 QString sourceId() const override;
270 Qgis::ProfileGeneratorFlags flags() const override;
273 QgsFeedback *feedback() const override;
274 QString type() const override;
275
276 private:
277 void visitBlock( const QgsPointCloudBlock *block, const QgsDoubleRange &zRange ) override;
278
279 double mPointSize = 1;
282 QColor mPointColor;
283 bool mOpacityByDistanceEffect = false;
284
285 std::unique_ptr< QgsAbstractGeometry > mSearchGeometryInLayerCrs;
286 std::unique_ptr< QgsPointCloudLayerProfileResults > mResults;
287 QVector< QgsPointCloudLayerProfileResults::PointResult > mGatheredPoints;
288
290};
291
300{
301 public:
302 QString type() const override;
304 QVector<QgsProfileIdentifyResults> identify( const QgsProfilePoint &point, const QgsProfileIdentifyContext &context ) override;
305 void copyPropertiesFromGenerator( const QgsAbstractProfileGenerator *generator ) override;
306 void renderResults( QgsProfileRenderContext &context ) override;
307
308 private:
309 QPointer< QgsPointCloudLayer > mLayer;
310 QString mLayerId;
312 std::unique_ptr< QgsCurve > mProfileCurve;
313 double mTolerance = 0.0;
314 double mZOffset = 0.0;
315 double mZScale = 1.0;
316
318};
319
320
329{
330 public:
335
337
338 QString sourceId() const override;
339 bool generateProfile( const QgsProfileGenerationContext &context ) override;
341 QgsFeedback *feedback() const override;
342 QString type() const override;
343
344 private:
345 void visitBlock( const QgsPointCloudBlock *block, const QgsDoubleRange &zRange ) override;
346
347 std::unique_ptr< QgsTriangulatedPointCloudLayerProfileResults > mResults;
348 std::unique_ptr< QgsAbstractGeometry > mSearchGeometryInLayerCrs;
349 QVector< QgsPoint > mGatheredPoints;
350
352 std::unique_ptr< QgsLineSymbol > mLineSymbol;
353 std::unique_ptr< QgsFillSymbol > mFillSymbol;
354 double mElevationLimit = std::numeric_limits< double >::quiet_NaN();
355
357};
358
359
360#endif // QGSPOINTCLOUDLAYERPROFILEGENERATOR_H
PointCloudSymbol
Rendering symbols for point cloud points.
Definition qgis.h:4387
@ Square
Renders points as squares.
Definition qgis.h:4388
QFlags< ProfileGeneratorFlag > ProfileGeneratorFlags
Definition qgis.h:4365
RenderUnit
Rendering size units.
Definition qgis.h:5340
@ Millimeters
Millimeters.
Definition qgis.h:5341
ProfileExportType
Types of export for elevation profiles.
Definition qgis.h:4374
ProfileSurfaceSymbology
Surface symbology type for elevation profile plots.
Definition qgis.h:4322
@ Line
The elevation surface will be rendered using a line symbol.
Definition qgis.h:4323
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:217
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:139
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