QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 #include "qgis_core.h"
21 #include "qgis_sip.h"
25 #include "qgscoordinatetransform.h"
26 #include "qgspointcloudattribute.h"
27 #include "qgslinesymbol.h"
28 #include "qgsvector3d.h"
29 #include "qgsgeos.h"
30 
31 #include <geos_c.h>
32 #include <memory>
33 
34 class QgsProfileRequest;
35 class QgsCurve;
36 class QgsPointCloudLayer;
41 class QgsPointCloudIndex;
43 class QgsPointCloudBlock;
44 class QgsGeos;
46 
47 #define SIP_NO_FILE
48 
49 
58 {
59 
60  public:
61 
64 
65  struct PointResult
66  {
67  double x = 0;
68  double y = 0;
69  double z = 0;
70  double distanceAlongCurve = 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;
91  bool opacityByDistanceEffect = false;
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  void renderResults( QgsProfileRenderContext &context ) override;
99  QgsProfileSnapResult snapPoint( const QgsProfilePoint &point, const QgsProfileSnapContext &context ) override;
100  QVector<QgsProfileIdentifyResults> identify( const QgsProfilePoint &point, const QgsProfileIdentifyContext &context ) override;
101  QVector<QgsProfileIdentifyResults> identify( const QgsDoubleRange &distanceRange, const QgsDoubleRange &elevationRange, const QgsProfileIdentifyContext &context ) override;
102  void copyPropertiesFromGenerator( const QgsAbstractProfileGenerator *generator ) override;
103 
104  private:
105 
106  GEOSSTRtree *mPointIndex = nullptr;
107  QPointer< QgsPointCloudLayer > mLayer;
109  std::unique_ptr< QgsCurve > mProfileCurve;
110  double mTolerance = 0;
111  double mZOffset = 0;
112  double mZScale = 1.0;
113  double mMaxErrorInLayerCoordinates = 0;
114 
115  // only required for GEOS < 3.9
116 #if GEOS_VERSION_MAJOR<4 && GEOS_VERSION_MINOR<9
117  std::vector< geos::unique_ptr > mSTRTreeItems;
118 #endif
119 
121 };
122 
123 
132 {
133 
134  public:
135 
140 
142 
143  QString sourceId() const override;
144  Qgis::ProfileGeneratorFlags flags() const override;
145  bool generateProfile( const QgsProfileGenerationContext &context = QgsProfileGenerationContext() ) override;
147  QgsFeedback *feedback() const override;
148 
149  private:
150  QVector<IndexedPointCloudNode> traverseTree( const QgsPointCloudIndex *pc, IndexedPointCloudNode n, double maxErrorPixels, double nodeErrorPixels, const QgsDoubleRange &zRange );
151  int visitNodesSync( const QVector<IndexedPointCloudNode> &nodes, QgsPointCloudIndex *pc, QgsPointCloudRequest &request, const QgsDoubleRange &zRange );
152  int visitNodesAsync( const QVector<IndexedPointCloudNode> &nodes, QgsPointCloudIndex *pc, QgsPointCloudRequest &request, const QgsDoubleRange &zRange );
153  void visitBlock( const QgsPointCloudBlock *block, const QgsDoubleRange &zRange );
154 
155  QPointer< QgsPointCloudLayer > mLayer;
156  QgsPointCloudAttributeCollection mLayerAttributes;
157  std::unique_ptr< QgsPointCloudRenderer > mRenderer;
158  double mMaximumScreenError = 0.3;
160 
161  double mPointSize = 1;
164  QColor mPointColor;
165  bool mOpacityByDistanceEffect = false;
166 
167  QString mId;
168  std::unique_ptr<QgsFeedback> mFeedback = nullptr;
169 
170  std::unique_ptr< QgsCurve > mProfileCurve;
171 
172  double mTolerance = 0;
173 
174  QgsCoordinateReferenceSystem mSourceCrs;
175  QgsCoordinateReferenceSystem mTargetCrs;
176  QgsCoordinateTransformContext mTransformContext;
177 
178  QgsVector3D mScale;
179  QgsVector3D mOffset;
180  double mZOffset = 0;
181  double mZScale = 1.0;
182 
183  double mStepDistance = std::numeric_limits<double>::quiet_NaN();
184 
185  QgsCoordinateTransform mLayerToTargetTransform;
186 
187  std::unique_ptr< QgsAbstractGeometry > mSearchGeometryInLayerCrs;
188  std::unique_ptr< QgsGeos > mSearchGeometryInLayerCrsGeometryEngine;
189  QgsRectangle mMaxSearchExtentInLayerCrs;
190 
191  std::unique_ptr< QgsPreparedPointCloudRendererData > mPreparedRendererData;
192 
193  std::unique_ptr< QgsPointCloudLayerProfileResults > mResults;
194  QVector< QgsPointCloudLayerProfileResults::PointResult > mGatheredPoints;
195 
197 
198 };
199 
200 #endif // QGSPOINTCLOUDLAYERPROFILEGENERATOR_H
QgsProfileIdentifyContext
Encapsulates the context of identifying profile results.
Definition: qgsabstractprofilegenerator.h:125
QgsCurve
Abstract base class for curved geometry type.
Definition: qgscurve.h:35
QgsPointCloudLayerProfileResults::pointColor
QColor pointColor
Definition: qgspointcloudlayerprofilegenerator.h:90
QgsCoordinateTransformContext
Contains information about the context in which a coordinate transform is executed.
Definition: qgscoordinatetransformcontext.h:57
QgsUnitTypes::RenderUnit
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:167
QgsPointCloudLayer
Represents a map layer supporting display of point clouds.
Definition: qgspointcloudlayer.h:45
QgsProfileSnapResult
Encapsulates results of snapping a profile point.
Definition: qgsprofilesnapping.h:56
QgsVector3D
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
Definition: qgsvector3d.h:31
qgscoordinatetransformcontext.h
QgsPointCloudLayerProfileResults::PointResult
Definition: qgspointcloudlayerprofilegenerator.h:65
QgsPointCloudLayerProfileGenerator
Implementation of QgsAbstractProfileGenerator for point cloud layers.
Definition: qgspointcloudlayerprofilegenerator.h:131
QgsPreparedPointCloudRendererData
Base class for 2d point cloud renderer prepared data containers.
Definition: qgspointcloudrenderer.h:256
QgsAbstractProfileGenerator
Abstract base class for objects which generate elevation profiles.
Definition: qgsabstractprofilegenerator.h:392
QgsProfileRenderContext
Abstract base class for storage of elevation profiles.
Definition: qgsabstractprofilegenerator.h:40
qgspointcloudattribute.h
QgsUnitTypes::RenderMillimeters
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:169
QgsPointCloudBlock
Base class for storing raw data from point cloud nodes.
Definition: qgspointcloudblock.h:38
QgsPointCloudLayerProfileResults
Implementation of QgsAbstractProfileResults for point cloud layers.
Definition: qgspointcloudlayerprofilegenerator.h:57
QgsProfileSnapContext
Encapsulates the context of snapping a profile point.
Definition: qgsprofilesnapping.h:30
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
QgsAbstractProfileResults::identify
virtual QVector< QgsProfileIdentifyResults > identify(const QgsProfilePoint &point, const QgsProfileIdentifyContext &context)
Identify results visible at the specified profile point.
Definition: qgsabstractprofilegenerator.cpp:67
QgsAbstractProfileResults::sampledPoints
virtual QgsPointSequence sampledPoints() const =0
Returns a list of sampled points, with their calculated elevation as the point z value.
QgsProfilePoint
Encapsulates a point on a distance-elevation profile.
Definition: qgsprofilepoint.h:30
QgsPointCloudRequest
Point cloud data request.
Definition: qgspointcloudrequest.h:39
QgsPointCloudLayerProfileResults::results
std::vector< PointResult > results
Definition: qgspointcloudlayerprofilegenerator.h:80
QgsProfileGenerationContext
Encapsulates the context in which an elevation profile is to be generated.
Definition: qgsabstractprofilegenerator.h:262
QgsAbstractProfileResults::copyPropertiesFromGenerator
virtual void copyPropertiesFromGenerator(const QgsAbstractProfileGenerator *generator)
Copies properties from specified generator to the results object.
Definition: qgsabstractprofilegenerator.cpp:77
QgsAbstractProfileResults::asGeometries
virtual QVector< QgsGeometry > asGeometries() const =0
Returns a list of geometries representing the calculated elevation results.
IndexedPointCloudNode
Represents a indexed point cloud node in octree.
Definition: qgspointcloudindex.h:57
QgsFeedback
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:44
QgsAbstractProfileGenerator::feedback
virtual QgsFeedback * feedback() const =0
Access to feedback object of the generator (may be nullptr)
QgsPointCloudAttributeCollection
Collection of point cloud attributes.
Definition: qgspointcloudattribute.h:141
QgsGeos
Does vector analysis using the geos library and handles import, export, exception handling*.
Definition: qgsgeos.h:103
QgsAbstractProfileResults::zRange
virtual QgsDoubleRange zRange() const =0
Returns the range of the retrieved elevation values.
qgis_sip.h
Qgis::PointCloudSymbol::Square
@ Square
Renders points as squares.
Qgis::PointCloudSymbol
PointCloudSymbol
Rendering symbols for point cloud points.
Definition: qgis.h:1888
QgsProfileRequest
Encapsulates properties and constraints relating to fetching elevation profiles from different source...
Definition: qgsprofilerequest.h:37
qgscoordinatetransform.h
QgsAbstractProfileResults::renderResults
virtual void renderResults(QgsProfileRenderContext &context)=0
Renders the results to the specified context.
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:211
QgsDoubleRange
QgsRange which stores a range of double values.
Definition: qgsrange.h:202
qgsvector3d.h
QgsPointSequence
QVector< QgsPoint > QgsPointSequence
Definition: qgsabstractgeometry.h:52
QgsAbstractProfileResults::distanceToHeightMap
virtual QMap< double, double > distanceToHeightMap() const =0
Returns the map of distance (chainage) to height.
QgsPointCloudRenderer
Abstract base class for 2d point cloud renderers.
Definition: qgspointcloudrenderer.h:296
QgsAbstractProfileGenerator::flags
virtual Qgis::ProfileGeneratorFlags flags() const
Returns flags which reflect how the profile generator operates.
Definition: qgsabstractprofilegenerator.cpp:141
QgsAbstractProfileResults::type
virtual QString type() const =0
Returns the unique string identifier for the results type.
QgsAbstractProfileResults
Abstract base class for storage of elevation profiles.
Definition: qgsabstractprofilegenerator.h:193
QgsPointCloudLayerProfileResults::PointResult::color
QRgb color
Definition: qgspointcloudlayerprofilegenerator.h:72
QgsPointCloudIndex
Represents a indexed point clouds data in octree.
Definition: qgspointcloudindex.h:163
QgsAbstractTerrainProvider
Abstract base class for terrain providers.
Definition: qgsterrainprovider.h:40
QgsAbstractProfileGenerator::takeResults
virtual QgsAbstractProfileResults * takeResults()=0
Takes results from the generator.
QgsCoordinateTransform
Class for doing transforms between two map coordinate systems.
Definition: qgscoordinatetransform.h:57
QgsAbstractProfileGenerator::sourceId
virtual QString sourceId() const =0
Returns a unique identifier representing the source of the profile.
qgscoordinatereferencesystem.h
QgsAbstractProfileResults::snapPoint
virtual QgsProfileSnapResult snapPoint(const QgsProfilePoint &point, const QgsProfileSnapContext &context)
Snaps a point to the generated elevation profile.
Definition: qgsabstractprofilegenerator.cpp:62
qgsabstractprofilegenerator.h
qgsgeos.h
qgslinesymbol.h
QgsAbstractProfileGenerator::generateProfile
virtual bool generateProfile(const QgsProfileGenerationContext &context=QgsProfileGenerationContext())=0
Generate the profile (based on data stored in the class).