QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
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 
28 #include "qgis_core.h"
29 #include "qgsrectangle.h"
30 #include "qgsvector3d.h"
31 #include "qgis_sip.h"
32 #include "qgspointcloudblock.h"
33 #include "qgsrange.h"
34 
35 #define SIP_NO_FILE
36 
39 
49 class CORE_EXPORT IndexedPointCloudNode
50 {
51  public:
55  IndexedPointCloudNode( int _d, int _x, int _y, int _z );
56 
58  bool isValid() const { return mD >= 0; }
59 
61  bool operator==( IndexedPointCloudNode other ) const
62  {
63  return mD == other.d() && mX == other.x() && mY == other.y() && mZ == other.z();
64  }
65 
67  static IndexedPointCloudNode fromString( const QString &str );
68 
70  QString toString() const;
71 
73  int d() const;
74 
76  int x() const;
77 
79  int y() const;
80 
82  int z() const;
83 
84  private:
85  int mD = -1, mX = -1, mY = -1, mZ = -1;
86 };
87 
89 
91 CORE_EXPORT uint qHash( IndexedPointCloudNode id );
92 
102 class CORE_EXPORT QgsPointCloudDataBounds
103 {
104  public:
108  QgsPointCloudDataBounds( qint32 xmin, qint32 ymin, qint32 zmin, qint32 xmax, qint32 ymax, qint32 zmax );
109 
111  qint32 xMin() const;
112 
114  qint32 yMin() const;
115 
117  qint32 zMin() const;
118 
120  qint32 xMax() const;
121 
123  qint32 yMax() const;
124 
126  qint32 zMax() const;
127 
129  QgsRectangle mapExtent( const QgsVector3D &offset, const QgsVector3D &scale ) const;
130 
132  QgsDoubleRange zRange( const QgsVector3D &offset, const QgsVector3D &scale ) const;
133 
134  private:
135  qint32 mXMin, mYMin, mZMin, mXMax, mYMax, mZMax;
136 };
137 
138 
148 class CORE_EXPORT QgsPointCloudIndex: public QObject
149 {
150  Q_OBJECT
151  public:
153  explicit QgsPointCloudIndex();
155 
157  virtual void load( const QString &fileName ) = 0;
158 
160  virtual bool isValid() const = 0;
161 
164 
166  bool hasNode( const IndexedPointCloudNode &n ) const { return mHierarchy.contains( n ); }
167 
169  QList<IndexedPointCloudNode> nodeChildren( const IndexedPointCloudNode &n ) const;
170 
172  QgsPointCloudAttributeCollection attributes() const;
173 
184  virtual QgsPointCloudBlock *nodeData( const IndexedPointCloudNode &n, const QgsPointCloudRequest &request ) = 0;
185 
187  QgsRectangle extent() const { return mExtent; }
188 
190  double zMin() const { return mZMin; }
192  double zMax() const { return mZMax; }
193 
195  QgsPointCloudDataBounds nodeBounds( const IndexedPointCloudNode &node ) const;
196 
202  QgsRectangle nodeMapExtent( const IndexedPointCloudNode &node ) const;
203 
209  QgsDoubleRange nodeZRange( const IndexedPointCloudNode &node ) const;
210 
212  float nodeError( const IndexedPointCloudNode &n ) const;
213 
215  QgsVector3D scale() const;
216 
218  QgsVector3D offset() const;
219 
223  int span() const;
224 
228  int nodePointCount( const IndexedPointCloudNode &n );
229 
230  protected: //TODO private
232  void setAttributes( const QgsPointCloudAttributeCollection &attributes );
233 
235  double mZMin = 0, mZMax = 0;
236 
237  QHash<IndexedPointCloudNode, int> mHierarchy;
242  int mSpan;
243 };
244 
245 #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.
QgsRange which stores a range of double values.
Definition: qgsrange.h:203
Collection of point cloud attributes.
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.
virtual QgsPointCloudBlock * nodeData(const IndexedPointCloudNode &n, const QgsPointCloudRequest &request)=0
Returns node data block.
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.
QgsPointCloudDataBounds mRootBounds
Bounds of the root node's cube (in int32 coordinates)
QgsRectangle mExtent
2D extent of data
QgsPointCloudAttributeCollection mAttributes
bool hasNode(const IndexedPointCloudNode &n) const
Returns whether the octree contain given node.
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.
int mSpan
All native attributes stored in the file.
QgsVector3D mScale
Scale of our int32 coordinates compared to CRS coords.
Point cloud data request.
A rectangle specified with double values.
Definition: qgsrectangle.h:42
Q_DECLARE_TYPEINFO(IndexedPointCloudNode, Q_PRIMITIVE_TYPE)
CORE_EXPORT uint qHash(IndexedPointCloudNode id)
Hash function for indexed nodes.