QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
29 #include "qgis_core.h"
30 #include "qgsrectangle.h"
31 #include "qgsvector3d.h"
32 #include "qgis_sip.h"
33 #include "qgspointcloudblock.h"
34 #include "qgsrange.h"
35 #include "qgspointcloudattribute.h"
36 #include "qgsstatisticalsummary.h"
37 #include "qgspointcloudexpression.h"
38 
39 #define SIP_NO_FILE
40 
46 class QgsPointCloudIndex;
47 
57 class CORE_EXPORT IndexedPointCloudNode
58 {
59  public:
63  IndexedPointCloudNode( int _d, int _x, int _y, int _z );
64 
66  bool isValid() const { return mD >= 0; }
67 
68  // TODO c++20 - replace with = default
69 
71  bool operator==( IndexedPointCloudNode other ) const
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 
104 Q_DECLARE_TYPEINFO( IndexedPointCloudNode, Q_PRIMITIVE_TYPE );
105 
107 CORE_EXPORT uint qHash( IndexedPointCloudNode id );
108 
118 class CORE_EXPORT QgsPointCloudDataBounds
119 {
120  public:
124  QgsPointCloudDataBounds( qint32 xmin, qint32 ymin, qint32 zmin, qint32 xmax, qint32 ymax, qint32 zmax );
125 
127  qint32 xMin() const;
128 
130  qint32 yMin() const;
131 
133  qint32 zMin() const;
134 
136  qint32 xMax() const;
137 
139  qint32 yMax() const;
140 
142  qint32 zMax() const;
143 
145  QgsRectangle mapExtent( const QgsVector3D &offset, const QgsVector3D &scale ) const;
146 
148  QgsDoubleRange zRange( const QgsVector3D &offset, const QgsVector3D &scale ) const;
149 
150  private:
151  qint32 mXMin, mYMin, mZMin, mXMax, mYMax, mZMax;
152 };
153 
163 class CORE_EXPORT QgsPointCloudIndex: public QObject
164 {
165  Q_OBJECT
166  public:
169  {
171  Remote
172  };
173 
175  explicit QgsPointCloudIndex();
177 
183  virtual std::unique_ptr<QgsPointCloudIndex> clone() const = 0;
184 
186  virtual void load( const QString &fileName ) = 0;
187 
189  virtual bool isValid() const = 0;
190 
195  QString error() const { return mError; }
196 
203  virtual AccessType accessType() const = 0;
204 
206  virtual QgsCoordinateReferenceSystem crs() const = 0;
208  virtual qint64 pointCount() const = 0;
210  virtual bool hasStatisticsMetadata() const = 0;
212  virtual QVariant metadataStatistic( const QString &attribute, QgsStatisticalSummary::Statistic statistic ) const;
214  virtual QVariantList metadataClasses( const QString &attribute ) const;
216  virtual QVariant metadataClassStatistic( const QString &attribute, const QVariant &value, QgsStatisticalSummary::Statistic statistic ) const;
218  virtual QVariantMap originalMetadata() const = 0;
219 
224  virtual QgsPointCloudStatistics metadataStatistics() const;
225 
228 
230  virtual bool hasNode( const IndexedPointCloudNode &n ) const;
231 
233  virtual qint64 nodePointCount( const IndexedPointCloudNode &n ) const;
234 
236  virtual QList<IndexedPointCloudNode> nodeChildren( const IndexedPointCloudNode &n ) const;
237 
239  QgsPointCloudAttributeCollection attributes() const;
240 
251  virtual QgsPointCloudBlock *nodeData( const IndexedPointCloudNode &n, const QgsPointCloudRequest &request ) = 0;
252 
263  virtual QgsPointCloudBlockRequest *asyncNodeData( const IndexedPointCloudNode &n, const QgsPointCloudRequest &request ) = 0;
264 
266  QgsRectangle extent() const { return mExtent; }
267 
269  double zMin() const { return mZMin; }
271  double zMax() const { return mZMax; }
272 
274  QgsPointCloudDataBounds nodeBounds( const IndexedPointCloudNode &node ) const;
275 
281  QgsRectangle nodeMapExtent( const IndexedPointCloudNode &node ) const;
282 
288  QgsDoubleRange nodeZRange( const IndexedPointCloudNode &node ) const;
289 
291  float nodeError( const IndexedPointCloudNode &n ) const;
292 
294  QgsVector3D scale() const;
295 
297  QgsVector3D offset() const;
298 
302  int span() const;
303 
307  int nodePointCount( const IndexedPointCloudNode &n );
308 
315  bool setSubsetString( const QString &subset );
316 
323  QString subsetString() const;
324 
329  void copyCommonProperties( QgsPointCloudIndex *destination ) const;
330 
331  protected: //TODO private
333  void setAttributes( const QgsPointCloudAttributeCollection &attributes );
334 
336  double mZMin = 0, mZMax = 0;
337 
338  mutable QMutex mHierarchyMutex;
339  mutable QHash<IndexedPointCloudNode, int> mHierarchy;
344  int mSpan;
345  QgsPointCloudExpression mFilterExpression;
346 
347  QString mError;
348 };
349 
350 #endif // QGSPOINTCLOUDINDEX_H
QgsPointCloudIndex::mOffset
QgsVector3D mOffset
Offset of our int32 coordinates compared to CRS coords.
Definition: qgspointcloudindex.h:341
QgsPointCloudIndex::mAttributes
QgsPointCloudAttributeCollection mAttributes
Definition: qgspointcloudindex.h:343
qgsrectangle.h
QgsVector3D
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
Definition: qgsvector3d.h:31
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:105
IndexedPointCloudNode::y
int y() const
Returns y.
Definition: qgspointcloudindex.cpp:73
IndexedPointCloudNode::x
int x() const
Returns x.
Definition: qgspointcloudindex.cpp:68
qgspointcloudattribute.h
QgsPointCloudStatistics
Class used to store statistics of a point cloud dataset.
Definition: qgspointcloudstatistics.h:61
QgsPointCloudBlock
Base class for storing raw data from point cloud nodes.
Definition: qgspointcloudblock.h:38
qgsrange.h
qHash
CORE_EXPORT uint qHash(IndexedPointCloudNode id)
Hash function for indexed nodes.
Definition: qgspointcloudindex.cpp:83
qgsstatisticalsummary.h
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
IndexedPointCloudNode::d
int d() const
Returns d.
Definition: qgspointcloudindex.cpp:63
QgsPointCloudIndex::mHierarchy
QHash< IndexedPointCloudNode, int > mHierarchy
Data hierarchy.
Definition: qgspointcloudindex.h:339
QgsPointCloudIndex::mScale
QgsVector3D mScale
Scale of our int32 coordinates compared to CRS coords.
Definition: qgspointcloudindex.h:340
QgsPointCloudIndex::mSpan
int mSpan
All native attributes stored in the file.
Definition: qgspointcloudindex.h:344
QgsPointCloudRequest
Point cloud data request.
Definition: qgspointcloudrequest.h:39
IndexedPointCloudNode
Represents a indexed point cloud node in octree.
Definition: qgspointcloudindex.h:57
QgsPointCloudIndex::zMin
double zMin() const
Returns z min.
Definition: qgspointcloudindex.h:269
QgsPointCloudIndex::zMax
double zMax() const
Returns z max.
Definition: qgspointcloudindex.h:271
QgsPointCloudIndex::extent
QgsRectangle extent() const
Returns extent of the data.
Definition: qgspointcloudindex.h:266
IndexedPointCloudNode::operator==
bool operator==(IndexedPointCloudNode other) const
Compares nodes.
Definition: qgspointcloudindex.h:71
QgsPointCloudAttributeCollection
Collection of point cloud attributes.
Definition: qgspointcloudattribute.h:141
QgsPointCloudIndex::mExtent
QgsRectangle mExtent
2D extent of data
Definition: qgspointcloudindex.h:335
qgis_sip.h
IndexedPointCloudNode::isValid
bool isValid() const
Returns whether node is valid.
Definition: qgspointcloudindex.h:66
QgsPointCloudIndex::root
IndexedPointCloudNode root()
Returns root node of the index.
Definition: qgspointcloudindex.h:227
QgsPointCloudIndex::mRootBounds
QgsPointCloudDataBounds mRootBounds
Bounds of the root node's cube (in int32 coordinates)
Definition: qgspointcloudindex.h:342
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:211
QgsPointCloudIndex::error
QString error() const
Returns the error that occurred during the loading of the index.
Definition: qgspointcloudindex.h:195
QgsStatisticalSummary::Statistic
Statistic
Enumeration of flags that specify statistics to be calculated.
Definition: qgsstatisticalsummary.h:48
QgsDoubleRange
QgsRange which stores a range of double values.
Definition: qgsrange.h:202
qgsvector3d.h
QgsPointCloudIndex::mHierarchyMutex
QMutex mHierarchyMutex
Definition: qgspointcloudindex.h:338
str
#define str(x)
Definition: qgis.cpp:37
QgsPointCloudBlockRequest
Base class for handling loading QgsPointCloudBlock asynchronously.
Definition: qgspointcloudblockrequest.h:36
QgsPointCloudIndex::Local
@ Local
Local means the source is a local file on the machine.
Definition: qgspointcloudindex.h:170
QgsPointCloudIndex::AccessType
AccessType
The access type of the data, local is for local files and remote for remote files (over HTTP)
Definition: qgspointcloudindex.h:168
QgsPointCloudDataBounds
Represents packaged data bounds.
Definition: qgspointcloudindex.h:118
qgspointcloudblock.h
Q_DECLARE_TYPEINFO
Q_DECLARE_TYPEINFO(IndexedPointCloudNode, Q_PRIMITIVE_TYPE)
IndexedPointCloudNode::z
int z() const
Returns z.
Definition: qgspointcloudindex.cpp:78
QgsPointCloudIndex
Represents a indexed point clouds data in octree.
Definition: qgspointcloudindex.h:163
QgsPointCloudIndex::mFilterExpression
QgsPointCloudExpression mFilterExpression
The filter expression to be evaluated when fetching node data.
Definition: qgspointcloudindex.h:345
QgsPointCloudIndex::mError
QString mError
Definition: qgspointcloudindex.h:347