QGIS API Documentation 3.41.0-Master (25ec5511245)
Loading...
Searching...
No Matches
qgspointcloudindex.h
Go to the documentation of this file.
1/***************************************************************************
2 qgspointcloudindex.h
3 --------------------
4 begin : October 2020
5 copyright : (C) 2020 by Peter Petrik
6 email : zilolv 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
18#ifndef QGSPOINTCLOUDINDEX_H
19#define QGSPOINTCLOUDINDEX_H
20
21#include <QObject>
22#include <QString>
23#include <QHash>
24#include <QStringList>
25#include <QVector>
26#include <QList>
27#include <QMutex>
28#include <QCache>
29
30#include "qgis_core.h"
31#include "qgsrectangle.h"
32#include "qgsvector3d.h"
33#include "qgis_sip.h"
34#include "qgspointcloudblock.h"
35#include "qgsrange.h"
37#include "qgspointcloudexpression.h"
39
40
41#define SIP_NO_FILE
42
49
59class CORE_EXPORT IndexedPointCloudNode
60{
61 public:
65 IndexedPointCloudNode( int _d, int _x, int _y, int _z );
66
68 bool isValid() const { return mD >= 0; }
69
70 // TODO c++20 - replace with = default
71
73 {
74 return mD == other.d() && mX == other.x() && mY == other.y() && mZ == other.z();
75 }
76
81 IndexedPointCloudNode parentNode() const;
82
84 static IndexedPointCloudNode fromString( const QString &str );
85
87 QString toString() const;
88
90 int d() const;
91
93 int x() const;
94
96 int y() const;
97
99 int z() const;
100
101 private:
102 int mD = -1, mX = -1, mY = -1, mZ = -1;
103};
104
106
108CORE_EXPORT uint qHash( IndexedPointCloudNode id );
109
119class CORE_EXPORT QgsPointCloudCacheKey
120{
121 public:
123 QgsPointCloudCacheKey( const IndexedPointCloudNode &n, const QgsPointCloudRequest &request, const QgsPointCloudExpression &expression, const QString &uri );
124
125 bool operator==( const QgsPointCloudCacheKey &other ) const;
126
128 IndexedPointCloudNode node() const { return mNode; }
129
131 QString uri() const { return mUri; }
132
134 QgsPointCloudRequest request() const { return mRequest; }
135
137 QgsPointCloudExpression filterExpression() const { return mFilterExpression; }
138
139 private:
141 QString mUri;
142 QgsPointCloudRequest mRequest;
143 QgsPointCloudExpression mFilterExpression;
144};
145
147uint qHash( const QgsPointCloudCacheKey &key );
148
158class CORE_EXPORT QgsPointCloudDataBounds
159{
160 public:
164 QgsPointCloudDataBounds( qint64 xmin, qint64 ymin, qint64 zmin, qint64 xmax, qint64 ymax, qint64 zmax );
165
167 qint64 xMin() const;
168
170 qint64 yMin() const;
171
173 qint64 zMin() const;
174
176 qint64 xMax() const;
177
179 qint64 yMax() const;
180
182 qint64 zMax() const;
183
185 QgsRectangle mapExtent( const QgsVector3D &offset, const QgsVector3D &scale ) const;
186
188 QgsDoubleRange zRange( const QgsVector3D &offset, const QgsVector3D &scale ) const;
189
190 private:
191 qint64 mXMin = 0;
192 qint64 mYMin = 0;
193 qint64 mZMin = 0;
194 qint64 mXMax = 0;
195 qint64 mYMax = 0;
196 qint64 mZMax = 0;
197};
198
208class CORE_EXPORT QgsPointCloudIndex: public QObject
209{
210 Q_OBJECT
211 public:
214 {
216 Remote
217 };
218
222
228 virtual std::unique_ptr<QgsPointCloudIndex> clone() const = 0;
229
231 virtual void load( const QString &fileName ) = 0;
232
234 virtual bool isValid() const = 0;
235
240 QString error() const { return mError; }
241
248 virtual AccessType accessType() const = 0;
249
253 virtual qint64 pointCount() const = 0;
255 virtual bool hasStatisticsMetadata() const = 0;
257 virtual QVariant metadataStatistic( const QString &attribute, Qgis::Statistic statistic ) const;
259 virtual QVariantList metadataClasses( const QString &attribute ) const;
261 virtual QVariant metadataClassStatistic( const QString &attribute, const QVariant &value, Qgis::Statistic statistic ) const;
263 virtual QVariantMap originalMetadata() const = 0;
264
269 virtual QgsPointCloudStatistics metadataStatistics() const;
270
273
275 virtual bool hasNode( const IndexedPointCloudNode &n ) const;
276
278 virtual qint64 nodePointCount( const IndexedPointCloudNode &n ) const;
279
281 virtual QList<IndexedPointCloudNode> nodeChildren( const IndexedPointCloudNode &n ) const;
282
284 QgsPointCloudAttributeCollection attributes() const;
285
294 virtual std::unique_ptr< QgsPointCloudBlock > nodeData( const IndexedPointCloudNode &n, const QgsPointCloudRequest &request ) = 0;
295
307
309 QgsRectangle extent() const { return mExtent; }
310
312 double zMin() const { return mZMin; }
314 double zMax() const { return mZMax; }
315
317 QgsPointCloudDataBounds nodeBounds( const IndexedPointCloudNode &node ) const;
318
324 QgsRectangle nodeMapExtent( const IndexedPointCloudNode &node ) const;
325
331 QgsDoubleRange nodeZRange( const IndexedPointCloudNode &node ) const;
332
334 float nodeError( const IndexedPointCloudNode &n ) const;
335
337 QgsVector3D scale() const;
338
340 QgsVector3D offset() const;
341
345 int span() const;
346
353 bool setSubsetString( const QString &subset );
354
361 QString subsetString() const;
362
367 void copyCommonProperties( QgsPointCloudIndex *destination ) const;
368
374 QgsPointCloudBlock *getNodeDataFromCache( const IndexedPointCloudNode &node, const QgsPointCloudRequest &request );
375
379 void storeNodeDataToCache( QgsPointCloudBlock *data, const IndexedPointCloudNode &node, const QgsPointCloudRequest &request );
380
384 static void storeNodeDataToCacheStatic( QgsPointCloudBlock *data, const IndexedPointCloudNode &node, const QgsPointCloudRequest &request,
385 const QgsPointCloudExpression &expression, const QString &uri );
386
387 protected: //TODO private
389 void setAttributes( const QgsPointCloudAttributeCollection &attributes );
390
392 double mZMin = 0, mZMax = 0;
393
394 mutable QMutex mHierarchyMutex;
395 mutable QHash<IndexedPointCloudNode, int> mHierarchy;
400 int mSpan = 0;
401 QgsPointCloudExpression mFilterExpression;
402
403 QString mError;
404 QString mUri;
405 static QMutex sBlockCacheMutex;
406 static QCache<QgsPointCloudCacheKey, QgsPointCloudBlock> sBlockCache;
407};
408
409#endif // QGSPOINTCLOUDINDEX_H
Represents a indexed point cloud node in octree.
int y() const
Returns y.
bool isValid() const
Returns whether node is valid.
int x() const
Returns x.
int d() const
Returns d.
bool operator==(IndexedPointCloudNode other) const
int z() const
Returns z.
Statistic
Available generic statistics.
Definition qgis.h:5438
This class represents a coordinate reference system (CRS).
QgsRange which stores a range of double values.
Definition qgsrange.h:231
Collection of point cloud attributes.
Base class for handling loading QgsPointCloudBlock asynchronously.
Base class for storing raw data from point cloud nodes.
Container class for QgsPointCloudBlock cache keys.
IndexedPointCloudNode node() const
Returns the key's IndexedPointCloudNode.
QgsPointCloudExpression filterExpression() const
Returns the key's QgsPointCloudExpression.
QgsPointCloudRequest request() const
Returns the key's QgsPointCloudRequest.
QgsPointCloudCacheKey(const IndexedPointCloudNode &n, const QgsPointCloudRequest &request, const QgsPointCloudExpression &expression, const QString &uri)
Ctor.
bool operator==(const QgsPointCloudCacheKey &other) const
QString uri() const
Returns the key's uri.
Represents packaged data bounds.
qint64 xMin() const
Returns x min.
qint64 zMin() const
Returns z min.
qint64 yMax() const
Returns y max.
qint64 xMax() const
Returns x max.
QgsPointCloudDataBounds(qint64 xmin, qint64 ymin, qint64 zmin, qint64 xmax, qint64 ymax, qint64 zmax)
Constructs bounds.
QgsDoubleRange zRange(const QgsVector3D &offset, const QgsVector3D &scale) const
Returns the z range, applying the specified offset and scale.
QgsPointCloudDataBounds()
Constructs invalid bounds.
QgsRectangle mapExtent(const QgsVector3D &offset, const QgsVector3D &scale) const
Returns 2D rectangle in map coordinates.
qint64 zMax() const
Returns z max.
qint64 yMin() const
Returns y min.
Represents a indexed point clouds data in octree.
double zMax() const
Returns z max.
virtual QgsPointCloudBlockRequest * asyncNodeData(const IndexedPointCloudNode &n, const QgsPointCloudRequest &request)=0
Returns a handle responsible for loading a node data block.
QgsPointCloudIndex()
Constructs index.
QString error() const
Returns the error that occurred during the loading of the index.
double zMin() const
Returns z min.
AccessType
The access type of the data, local is for local files and remote for remote files (over HTTP)
@ Local
Local means the source is a local file on the machine.
virtual qint64 pointCount() const =0
Returns the number of points in the point cloud.
virtual AccessType accessType() const =0
Returns the access type of the data If the access type is Remote, data will be fetched from an HTTP s...
virtual std::unique_ptr< QgsPointCloudIndex > clone() const =0
Returns a clone of the current point cloud index object.
QHash< IndexedPointCloudNode, int > mHierarchy
Data hierarchy.
virtual bool isValid() const =0
Returns whether index is loaded and valid.
QgsRectangle extent() const
Returns extent of the data.
virtual QgsCoordinateReferenceSystem crs() const =0
Returns the coordinate reference system of the point cloud index.
QgsPointCloudDataBounds mRootBounds
Bounds of the root node's cube (in int32 coordinates)
QgsRectangle mExtent
2D extent of data
QgsPointCloudAttributeCollection mAttributes
QgsVector3D mOffset
Offset of our int32 coordinates compared to CRS coords.
virtual void load(const QString &fileName)=0
Loads the index from the file.
IndexedPointCloudNode root()
Returns root node of the index.
static QMutex sBlockCacheMutex
virtual bool hasStatisticsMetadata() const =0
Returns whether the dataset contains metadata of statistics.
static QCache< QgsPointCloudCacheKey, QgsPointCloudBlock > sBlockCache
virtual std::unique_ptr< QgsPointCloudBlock > nodeData(const IndexedPointCloudNode &n, const QgsPointCloudRequest &request)=0
Returns node data block.
QgsVector3D mScale
Scale of our int32 coordinates compared to CRS coords.
virtual QVariantMap originalMetadata() const =0
Returns the original metadata map.
QgsPointCloudExpression mFilterExpression
The filter expression to be evaluated when fetching node data.
Point cloud data request.
Class used to store statistics of a point cloud dataset.
A rectangle specified with double values.
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
Definition qgsvector3d.h:31
#define str(x)
Definition qgis.cpp:39
Q_DECLARE_TYPEINFO(IndexedPointCloudNode, Q_PRIMITIVE_TYPE)
CORE_EXPORT uint qHash(IndexedPointCloudNode id)
Hash function for indexed nodes.