QGIS API Documentation 3.27.0-Master (0a97e3138f)
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"
27#include "qgslinesymbol.h"
28#include "qgsvector3d.h"
29#include "qgsgeos.h"
30
31#include <geos_c.h>
32#include <memory>
33
35class QgsCurve;
44class QgsGeos;
46
47#define SIP_NO_FILE
48
49
58{
59
60 public:
61
64
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;
146 QgsAbstractProfileResults *takeResults() 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
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
Represents a indexed point cloud node in octree.
PointCloudSymbol
Rendering symbols for point cloud points.
Definition: qgis.h:1949
@ Square
Renders points as squares.
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 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 terrain providers.
This class represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
Class for doing transforms between two map coordinate systems.
Abstract base class for curved geometry type.
Definition: qgscurve.h:36
QgsRange which stores a range of double values.
Definition: qgsrange.h:203
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:45
Does vector analysis using the geos library and handles import, export, exception handling*.
Definition: qgsgeos.h:104
Collection of point cloud attributes.
Base class for storing raw data from point cloud nodes.
Represents a indexed point clouds data in octree.
Implementation of QgsAbstractProfileGenerator for point cloud layers.
Implementation of QgsAbstractProfileResults for point cloud layers.
Represents a map layer supporting display of point clouds.
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.
Definition: qgsrectangle.h:42
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:168
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:169
QVector< QgsPoint > QgsPointSequence