QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
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#define SIP_NO_FILE
41
48
58class CORE_EXPORT IndexedPointCloudNode
59{
60 public:
64 IndexedPointCloudNode( int _d, int _x, int _y, int _z );
65
67 bool isValid() const { return mD >= 0; }
68
69 // TODO c++20 - replace with = default
70
72 {
73 return mD == other.d() && mX == other.x() && mY == other.y() && mZ == other.z();
74 }
75
80 IndexedPointCloudNode parentNode() const;
81
83 static IndexedPointCloudNode fromString( const QString &str );
84
86 QString toString() const;
87
89 int d() const;
90
92 int x() const;
93
95 int y() const;
96
98 int z() const;
99
100 private:
101 int mD = -1, mX = -1, mY = -1, mZ = -1;
102};
103
105
107CORE_EXPORT uint qHash( IndexedPointCloudNode id );
108
118class CORE_EXPORT QgsPointCloudCacheKey
119{
120 public:
122 QgsPointCloudCacheKey( const IndexedPointCloudNode &n, const QgsPointCloudRequest &request, const QgsPointCloudExpression &expression, const QString &uri );
123
124 bool operator==( const QgsPointCloudCacheKey &other ) const;
125
127 IndexedPointCloudNode node() const { return mNode; }
128
130 QString uri() const { return mUri; }
131
133 QgsPointCloudRequest request() const { return mRequest; }
134
136 QgsPointCloudExpression filterExpression() const { return mFilterExpression; }
137
138 private:
140 QString mUri;
141 QgsPointCloudRequest mRequest;
142 QgsPointCloudExpression mFilterExpression;
143};
144
146uint qHash( const QgsPointCloudCacheKey &key );
147
157class CORE_EXPORT QgsPointCloudDataBounds
158{
159 public:
163 QgsPointCloudDataBounds( qint64 xmin, qint64 ymin, qint64 zmin, qint64 xmax, qint64 ymax, qint64 zmax );
164
166 qint64 xMin() const;
167
169 qint64 yMin() const;
170
172 qint64 zMin() const;
173
175 qint64 xMax() const;
176
178 qint64 yMax() const;
179
181 qint64 zMax() const;
182
184 QgsRectangle mapExtent( const QgsVector3D &offset, const QgsVector3D &scale ) const;
185
187 QgsDoubleRange zRange( const QgsVector3D &offset, const QgsVector3D &scale ) const;
188
189 private:
190 qint64 mXMin = 0;
191 qint64 mYMin = 0;
192 qint64 mZMin = 0;
193 qint64 mXMax = 0;
194 qint64 mYMax = 0;
195 qint64 mZMax = 0;
196};
197
207class CORE_EXPORT QgsPointCloudIndex: public QObject
208{
209 Q_OBJECT
210 public:
213 {
215 Remote
216 };
217
221
227 virtual std::unique_ptr<QgsPointCloudIndex> clone() const = 0;
228
230 virtual void load( const QString &fileName ) = 0;
231
233 virtual bool isValid() const = 0;
234
239 QString error() const { return mError; }
240
247 virtual AccessType accessType() const = 0;
248
252 virtual qint64 pointCount() const = 0;
254 virtual bool hasStatisticsMetadata() const = 0;
256 virtual QVariant metadataStatistic( const QString &attribute, Qgis::Statistic statistic ) const;
258 virtual QVariantList metadataClasses( const QString &attribute ) const;
260 virtual QVariant metadataClassStatistic( const QString &attribute, const QVariant &value, Qgis::Statistic statistic ) const;
262 virtual QVariantMap originalMetadata() const = 0;
263
268 virtual QgsPointCloudStatistics metadataStatistics() const;
269
272
274 virtual bool hasNode( const IndexedPointCloudNode &n ) const;
275
277 virtual qint64 nodePointCount( const IndexedPointCloudNode &n ) const;
278
280 virtual QList<IndexedPointCloudNode> nodeChildren( const IndexedPointCloudNode &n ) const;
281
283 QgsPointCloudAttributeCollection attributes() const;
284
293 virtual std::unique_ptr< QgsPointCloudBlock > nodeData( const IndexedPointCloudNode &n, const QgsPointCloudRequest &request ) = 0;
294
306
308 QgsRectangle extent() const { return mExtent; }
309
311 double zMin() const { return mZMin; }
313 double zMax() const { return mZMax; }
314
316 QgsPointCloudDataBounds nodeBounds( const IndexedPointCloudNode &node ) const;
317
323 QgsRectangle nodeMapExtent( const IndexedPointCloudNode &node ) const;
324
330 QgsDoubleRange nodeZRange( const IndexedPointCloudNode &node ) const;
331
333 float nodeError( const IndexedPointCloudNode &n ) const;
334
336 QgsVector3D scale() const;
337
339 QgsVector3D offset() const;
340
344 int span() const;
345
349 int nodePointCount( const IndexedPointCloudNode &n );
350
357 bool setSubsetString( const QString &subset );
358
365 QString subsetString() const;
366
371 void copyCommonProperties( QgsPointCloudIndex *destination ) const;
372
378 QgsPointCloudBlock *getNodeDataFromCache( const IndexedPointCloudNode &node, const QgsPointCloudRequest &request );
379
383 void storeNodeDataToCache( QgsPointCloudBlock *data, const IndexedPointCloudNode &node, const QgsPointCloudRequest &request );
384
388 static void storeNodeDataToCacheStatic( QgsPointCloudBlock *data, const IndexedPointCloudNode &node, const QgsPointCloudRequest &request,
389 const QgsPointCloudExpression &expression, const QString &uri );
390
391 protected: //TODO private
393 void setAttributes( const QgsPointCloudAttributeCollection &attributes );
394
396 double mZMin = 0, mZMax = 0;
397
398 mutable QMutex mHierarchyMutex;
399 mutable QHash<IndexedPointCloudNode, int> mHierarchy;
404 int mSpan = 0;
405 QgsPointCloudExpression mFilterExpression;
406
407 QString mError;
408 QString mUri;
409 static QMutex sBlockCacheMutex;
410 static QCache<QgsPointCloudCacheKey, QgsPointCloudBlock> sBlockCache;
411};
412
413#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:5432
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:38
Q_DECLARE_TYPEINFO(IndexedPointCloudNode, Q_PRIMITIVE_TYPE)
CORE_EXPORT uint qHash(IndexedPointCloudNode id)
Hash function for indexed nodes.