QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgscopcpointcloudindex.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscopcpointcloudindex.h
3  --------------------
4  begin : March 2022
5  copyright : (C) 2022 by Belgacem Nedjima
6  email : belgacem dot nedjima 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 QGSCOPCPOINTCLOUDINDEX_H
19 #define QGSCOPCPOINTCLOUDINDEX_H
20 
21 #include <QObject>
22 #include <QString>
23 #include <QHash>
24 #include <QStringList>
25 #include <QVector>
26 #include <QList>
27 #include <QFile>
28 
29 #include <fstream>
30 
31 #include "qgspointcloudindex.h"
32 #include "qgspointcloudattribute.h"
33 #include "qgsstatisticalsummary.h"
34 #include "qgis_sip.h"
36 
37 #include "qgslazinfo.h"
38 #include "lazperf/vlr.hpp"
39 
41 #define SIP_NO_FILE
42 
44 
45 class CORE_EXPORT QgsCopcPointCloudIndex: public QgsPointCloudIndex
46 {
47  Q_OBJECT
48  public:
49 
50  explicit QgsCopcPointCloudIndex();
51  ~QgsCopcPointCloudIndex();
52 
53  std::unique_ptr<QgsPointCloudIndex> clone() const override;
54 
55  void load( const QString &fileName ) override;
56 
57  bool hasNode( const IndexedPointCloudNode &n ) const override;
58  QList<IndexedPointCloudNode> nodeChildren( const IndexedPointCloudNode &n ) const override;
59 
60  QgsPointCloudBlock *nodeData( const IndexedPointCloudNode &n, const QgsPointCloudRequest &request ) override;
62 
63  QgsCoordinateReferenceSystem crs() const override;
64  qint64 pointCount() const override;
65  bool hasStatisticsMetadata() const override { return false; };
66  QVariantMap originalMetadata() const override { return mOriginalMetadata; }
67 
68  bool isValid() const override;
70 
76  bool writeStatistics( QgsPointCloudStatistics &stats );
77 
83  QgsPointCloudStatistics readStatistics();
84 
89  void copyCommonProperties( QgsCopcPointCloudIndex *destination ) const;
90 
91  protected:
92  bool loadSchema( QgsLazInfo &lazInfo );
93  bool loadHierarchy();
94 
96  virtual bool fetchNodeHierarchy( const IndexedPointCloudNode &n ) const;
97 
102  virtual void fetchHierarchyPage( uint64_t offset, uint64_t byteSize ) const;
103 
104  QByteArray fetchCopcStatisticsEvlrData();
105 
106  bool mIsValid = false;
107  QString mFileName;
108  mutable std::ifstream mCopcFile;
109  mutable lazperf::copc_info_vlr mCopcInfoVlr;
110  mutable QHash<IndexedPointCloudNode, QPair<uint64_t, int32_t>> mHierarchyNodePos;
111 
112  QVariantMap mOriginalMetadata;
113 
114  std::unique_ptr<QgsLazInfo> mLazInfo = nullptr;
115 };
116 
118 #endif // QGSCOPCPOINTCLOUDINDEX_H
qgslazinfo.h
QgsPointCloudIndex::nodeData
virtual QgsPointCloudBlock * nodeData(const IndexedPointCloudNode &n, const QgsPointCloudRequest &request)=0
Returns node data block.
QgsPointCloudIndex::nodeChildren
virtual QList< IndexedPointCloudNode > nodeChildren(const IndexedPointCloudNode &n) const
Returns all children of node.
Definition: qgspointcloudindex.cpp:172
QgsPointCloudIndex::crs
virtual QgsCoordinateReferenceSystem crs() const =0
Returns the coordinate reference system of the point cloud index.
QgsPointCloudIndex::copyCommonProperties
void copyCommonProperties(QgsPointCloudIndex *destination) const
Copies common properties to the destination index.
Definition: qgspointcloudindex.cpp:352
qgspointcloudattribute.h
QgsPointCloudStatistics
Class used to store statistics of a point cloud dataset.
Definition: qgspointcloudstatistics.h:61
QgsPointCloudIndex::clone
virtual std::unique_ptr< QgsPointCloudIndex > clone() const =0
Returns a clone of the current point cloud index object.
QgsPointCloudBlock
Base class for storing raw data from point cloud nodes.
Definition: qgspointcloudblock.h:38
qgsstatisticalsummary.h
QgsPointCloudIndex::isValid
virtual bool isValid() const =0
Returns whether index is loaded and valid.
QgsPointCloudIndex::accessType
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...
QgsPointCloudRequest
Point cloud data request.
Definition: qgspointcloudrequest.h:39
qgspointcloudstatistics.h
QgsPointCloudIndex::originalMetadata
virtual QVariantMap originalMetadata() const =0
Returns the original metadata map.
IndexedPointCloudNode
Represents a indexed point cloud node in octree.
Definition: qgspointcloudindex.h:57
QgsPointCloudIndex::load
virtual void load(const QString &fileName)=0
Loads the index from the file.
QgsPointCloudIndex::hasNode
virtual bool hasNode(const IndexedPointCloudNode &n) const
Returns whether the octree contain given node.
Definition: qgspointcloudindex.cpp:160
QgsPointCloudIndex::hasStatisticsMetadata
virtual bool hasStatisticsMetadata() const =0
Returns whether the dataset contains metadata of statistics.
qgis_sip.h
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:211
qgspointcloudindex.h
QgsLazInfo
Class for extracting information contained in LAZ file such as the public header block and variable l...
Definition: qgslazinfo.h:38
QgsPointCloudIndex::asyncNodeData
virtual QgsPointCloudBlockRequest * asyncNodeData(const IndexedPointCloudNode &n, const QgsPointCloudRequest &request)=0
Returns a handle responsible for loading a node data block.
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
QgsPointCloudIndex
Represents a indexed point clouds data in octree.
Definition: qgspointcloudindex.h:163
QgsPointCloudIndex::pointCount
virtual qint64 pointCount() const =0
Returns the number of points in the point cloud.