QGIS API Documentation 3.38.0-Grenoble (exported)
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
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
126 bool operator==( const QgsPointCloudCacheKey &other ) const;
127
129 IndexedPointCloudNode node() const { return mNode; }
130
132 QString uri() const { return mUri; }
133
135 QgsPointCloudRequest request() const { return mRequest; }
136
138 QgsPointCloudExpression filterExpression() const { return mFilterExpression; }
139
140 private:
142 QString mUri;
143 QgsPointCloudRequest mRequest;
144 QgsPointCloudExpression mFilterExpression;
145};
146
148uint qHash( const QgsPointCloudCacheKey &key );
149
159class CORE_EXPORT QgsPointCloudDataBounds
160{
161 public:
165 QgsPointCloudDataBounds( qint64 xmin, qint64 ymin, qint64 zmin, qint64 xmax, qint64 ymax, qint64 zmax );
166
168 qint64 xMin() const;
169
171 qint64 yMin() const;
172
174 qint64 zMin() const;
175
177 qint64 xMax() const;
178
180 qint64 yMax() const;
181
183 qint64 zMax() const;
184
186 QgsRectangle mapExtent( const QgsVector3D &offset, const QgsVector3D &scale ) const;
187
189 QgsDoubleRange zRange( const QgsVector3D &offset, const QgsVector3D &scale ) const;
190
191 private:
192 qint64 mXMin = 0;
193 qint64 mYMin = 0;
194 qint64 mZMin = 0;
195 qint64 mXMax = 0;
196 qint64 mYMax = 0;
197 qint64 mZMax = 0;
198};
199
209class CORE_EXPORT QgsPointCloudIndex: public QObject
210{
211 Q_OBJECT
212 public:
215 {
217 Remote
218 };
219
223
229 virtual std::unique_ptr<QgsPointCloudIndex> clone() const = 0;
230
232 virtual void load( const QString &fileName ) = 0;
233
235 virtual bool isValid() const = 0;
236
241 QString error() const { return mError; }
242
249 virtual AccessType accessType() const = 0;
250
254 virtual qint64 pointCount() const = 0;
256 virtual bool hasStatisticsMetadata() const = 0;
258 virtual QVariant metadataStatistic( const QString &attribute, Qgis::Statistic statistic ) const;
260 virtual QVariantList metadataClasses( const QString &attribute ) const;
262 virtual QVariant metadataClassStatistic( const QString &attribute, const QVariant &value, Qgis::Statistic statistic ) const;
264 virtual QVariantMap originalMetadata() const = 0;
265
270 virtual QgsPointCloudStatistics metadataStatistics() const;
271
274
276 virtual bool hasNode( const IndexedPointCloudNode &n ) const;
277
279 virtual qint64 nodePointCount( const IndexedPointCloudNode &n ) const;
280
282 virtual QList<IndexedPointCloudNode> nodeChildren( const IndexedPointCloudNode &n ) const;
283
285 QgsPointCloudAttributeCollection attributes() const;
286
295 virtual std::unique_ptr< QgsPointCloudBlock > nodeData( const IndexedPointCloudNode &n, const QgsPointCloudRequest &request ) = 0;
296
308
310 QgsRectangle extent() const { return mExtent; }
311
313 double zMin() const { return mZMin; }
315 double zMax() const { return mZMax; }
316
318 QgsPointCloudDataBounds nodeBounds( const IndexedPointCloudNode &node ) const;
319
325 QgsRectangle nodeMapExtent( const IndexedPointCloudNode &node ) const;
326
332 QgsDoubleRange nodeZRange( const IndexedPointCloudNode &node ) const;
333
335 float nodeError( const IndexedPointCloudNode &n ) const;
336
338 QgsVector3D scale() const;
339
341 QgsVector3D offset() const;
342
346 int span() const;
347
351 int nodePointCount( const IndexedPointCloudNode &n );
352
359 bool setSubsetString( const QString &subset );
360
367 QString subsetString() const;
368
373 void copyCommonProperties( QgsPointCloudIndex *destination ) const;
374
380 QgsPointCloudBlock *getNodeDataFromCache( const IndexedPointCloudNode &node, const QgsPointCloudRequest &request );
381
385 void storeNodeDataToCache( QgsPointCloudBlock *data, const IndexedPointCloudNode &node, const QgsPointCloudRequest &request );
386
390 static void storeNodeDataToCacheStatic( QgsPointCloudBlock *data, const IndexedPointCloudNode &node, const QgsPointCloudRequest &request,
391 const QgsPointCloudExpression &expression, const QString &uri );
392
393 protected: //TODO private
395 void setAttributes( const QgsPointCloudAttributeCollection &attributes );
396
398 double mZMin = 0, mZMax = 0;
399
400 mutable QMutex mHierarchyMutex;
401 mutable QHash<IndexedPointCloudNode, int> mHierarchy;
406 int mSpan = 0;
407 QgsPointCloudExpression mFilterExpression;
408
409 QString mError;
410 QString mUri;
411 static QMutex sBlockCacheMutex;
412 static QCache<QgsPointCloudCacheKey, QgsPointCloudBlock> sBlockCache;
413};
414
415#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
Compares nodes.
int z() const
Returns z.
Statistic
Available generic statistics.
Definition qgis.h:4981
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
Compares keys.
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.