QGIS API Documentation  3.20.0-Odense (decaadbb31)
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 
38 #define SIP_NO_FILE
39 
44 
54 class CORE_EXPORT IndexedPointCloudNode
55 {
56  public:
60  IndexedPointCloudNode( int _d, int _x, int _y, int _z );
61 
63  bool isValid() const { return mD >= 0; }
64 
66  bool operator==( IndexedPointCloudNode other ) const
67  {
68  return mD == other.d() && mX == other.x() && mY == other.y() && mZ == other.z();
69  }
70 
75  IndexedPointCloudNode parentNode() const;
76 
78  static IndexedPointCloudNode fromString( const QString &str );
79 
81  QString toString() const;
82 
84  int d() const;
85 
87  int x() const;
88 
90  int y() const;
91 
93  int z() const;
94 
95  private:
96  int mD = -1, mX = -1, mY = -1, mZ = -1;
97 };
98 
100 
102 CORE_EXPORT uint qHash( IndexedPointCloudNode id );
103 
113 class CORE_EXPORT QgsPointCloudDataBounds
114 {
115  public:
119  QgsPointCloudDataBounds( qint32 xmin, qint32 ymin, qint32 zmin, qint32 xmax, qint32 ymax, qint32 zmax );
120 
122  qint32 xMin() const;
123 
125  qint32 yMin() const;
126 
128  qint32 zMin() const;
129 
131  qint32 xMax() const;
132 
134  qint32 yMax() const;
135 
137  qint32 zMax() const;
138 
140  QgsRectangle mapExtent( const QgsVector3D &offset, const QgsVector3D &scale ) const;
141 
143  QgsDoubleRange zRange( const QgsVector3D &offset, const QgsVector3D &scale ) const;
144 
145  private:
146  qint32 mXMin, mYMin, mZMin, mXMax, mYMax, mZMax;
147 };
148 
158 class CORE_EXPORT QgsPointCloudIndex: public QObject
159 {
160  Q_OBJECT
161  public:
164  {
166  Remote
167  };
168 
170  explicit QgsPointCloudIndex();
172 
174  virtual void load( const QString &fileName ) = 0;
175 
177  virtual bool isValid() const = 0;
178 
185  virtual AccessType accessType() const = 0;
186 
188  virtual QgsCoordinateReferenceSystem crs() const = 0;
190  virtual qint64 pointCount() const = 0;
192  virtual QVariant metadataStatistic( const QString &attribute, QgsStatisticalSummary::Statistic statistic ) const = 0;
194  virtual QVariantList metadataClasses( const QString &attribute ) const = 0;
196  virtual QVariant metadataClassStatistic( const QString &attribute, const QVariant &value, QgsStatisticalSummary::Statistic statistic ) const = 0;
198  virtual QVariantMap originalMetadata() const = 0;
199 
202 
204  virtual bool hasNode( const IndexedPointCloudNode &n ) const;
205 
207  virtual QList<IndexedPointCloudNode> nodeChildren( const IndexedPointCloudNode &n ) const;
208 
210  QgsPointCloudAttributeCollection attributes() const;
211 
222  virtual QgsPointCloudBlock *nodeData( const IndexedPointCloudNode &n, const QgsPointCloudRequest &request ) = 0;
223 
235 
237  QgsRectangle extent() const { return mExtent; }
238 
240  double zMin() const { return mZMin; }
242  double zMax() const { return mZMax; }
243 
245  QgsPointCloudDataBounds nodeBounds( const IndexedPointCloudNode &node ) const;
246 
252  QgsRectangle nodeMapExtent( const IndexedPointCloudNode &node ) const;
253 
259  QgsDoubleRange nodeZRange( const IndexedPointCloudNode &node ) const;
260 
262  float nodeError( const IndexedPointCloudNode &n ) const;
263 
265  QgsVector3D scale() const;
266 
268  QgsVector3D offset() const;
269 
273  int span() const;
274 
278  int nodePointCount( const IndexedPointCloudNode &n );
279 
280  protected: //TODO private
282  void setAttributes( const QgsPointCloudAttributeCollection &attributes );
283 
285  double mZMin = 0, mZMax = 0;
286 
287  mutable QMutex mHierarchyMutex;
288  mutable QHash<IndexedPointCloudNode, int> mHierarchy;
293  int mSpan;
294 };
295 
296 #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.
This class represents a coordinate reference system (CRS).
QgsRange which stores a range of double values.
Definition: qgsrange.h:203
Collection of point cloud attributes.
Base class for handling loading QgsPointCloudBlock asynchronously.
Base class for storing raw data from point cloud nodes.
Represents packaged data bounds.
qint32 xMax() const
Returns x max.
QgsPointCloudDataBounds(qint32 xmin, qint32 ymin, qint32 zmin, qint32 xmax, qint32 ymax, qint32 zmax)
Constructs bounds.
qint32 xMin() const
Returns x min.
qint32 yMax() const
Returns y max.
QgsDoubleRange zRange(const QgsVector3D &offset, const QgsVector3D &scale) const
Returns the z range, applying the specified offset and scale.
QgsPointCloudDataBounds()
Constructs invalid bounds.
qint32 zMax() const
Returns z max.
QgsRectangle mapExtent(const QgsVector3D &offset, const QgsVector3D &scale) const
Returns 2D rectangle in map coordinates.
qint32 yMin() const
Returns y min.
qint32 zMin() const
Returns z min.
Represents a indexed point clouds data in octree.
double zMax() const
Returns z max.
QgsPointCloudIndex()
Constructs 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)
virtual qint64 pointCount() const =0
Returns the number of points in the point cloud.
virtual QgsPointCloudBlock * nodeData(const IndexedPointCloudNode &n, const QgsPointCloudRequest &request)=0
Returns node data block.
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...
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.
virtual QVariant metadataClassStatistic(const QString &attribute, const QVariant &value, QgsStatisticalSummary::Statistic statistic) const =0
Returns the statistic statistic of the class value of the attribute attribute.
virtual QVariant metadataStatistic(const QString &attribute, QgsStatisticalSummary::Statistic statistic) const =0
Returns the statistic statistic of attribute.
virtual QgsPointCloudBlockRequest * asyncNodeData(const IndexedPointCloudNode &n, const QgsPointCloudRequest &request)=0
Returns a handle responsible for loading a node data block.
int mSpan
All native attributes stored in the file.
QgsVector3D mScale
Scale of our int32 coordinates compared to CRS coords.
virtual QVariantMap originalMetadata() const =0
Returns the original metadata map.
virtual QVariantList metadataClasses(const QString &attribute) const =0
Returns the classes of attribute.
Point cloud data request.
A rectangle specified with double values.
Definition: qgsrectangle.h:42
Statistic
Enumeration of flags that specify statistics to be calculated.
#define str(x)
Definition: qgis.cpp:37
Q_DECLARE_TYPEINFO(IndexedPointCloudNode, Q_PRIMITIVE_TYPE)
CORE_EXPORT uint qHash(IndexedPointCloudNode id)
Hash function for indexed nodes.