QGIS API Documentation 3.43.0-Master (b60ef06885e)
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 <QString>
22#include <QHash>
23#include <QStringList>
24#include <QVector>
25#include <QList>
26#include <QFile>
27
28#include <fstream>
29#include <optional>
30
31#include "qgspointcloudindex.h"
33
34#include "qgslazinfo.h"
35#include "lazperf/vlr.hpp"
36
38#define SIP_NO_FILE
39
41
42class CORE_EXPORT QgsCopcPointCloudIndex: public QgsAbstractPointCloudIndex
43{
44 public:
45
46 explicit QgsCopcPointCloudIndex();
47 ~QgsCopcPointCloudIndex();
48
49 void load( const QString &fileName ) override;
50
51 bool hasNode( const QgsPointCloudNodeId &n ) const override;
52 QgsPointCloudNode getNode( const QgsPointCloudNodeId &id ) const override;
53
54 std::unique_ptr< QgsPointCloudBlock> nodeData( const QgsPointCloudNodeId &n, const QgsPointCloudRequest &request ) override;
56
58 const QByteArray rawNodeData( QgsPointCloudNodeId n ) const;
59
60 QgsCoordinateReferenceSystem crs() const override;
61 qint64 pointCount() const override;
62 QVariantMap originalMetadata() const override { return mOriginalMetadata; }
63
64 bool isValid() const override;
65 Qgis::PointCloudAccessType accessType() const override { return mAccessType; };
66
72 bool writeStatistics( QgsPointCloudStatistics &stats ) override;
73
80
86 QVariantMap extraMetadata() const override;
87
88 protected:
89 bool loadSchema( QgsLazInfo &lazInfo );
90 bool loadHierarchy() const;
91
93 bool fetchNodeHierarchy( const QgsPointCloudNodeId &n ) const;
94
98 virtual void fetchHierarchyPage( uint64_t offset, uint64_t byteSize ) const;
99
100 void populateHierarchy( const char *hierarchyPageData, uint64_t byteSize ) const;
101
103 QByteArray readRange( uint64_t offset, uint64_t length ) const;
104
105 QByteArray fetchCopcStatisticsEvlrData() const;
106
107 void reset();
108
109 bool mIsValid = false;
111 mutable std::ifstream mCopcFile;
112 mutable lazperf::copc_info_vlr mCopcInfoVlr;
113 mutable QHash<QgsPointCloudNodeId, QPair<uint64_t, int32_t>> mHierarchyNodePos;
114
115 mutable QMutex mFileMutex;
116
117 QVariantMap mOriginalMetadata;
118 mutable std::optional<QgsPointCloudStatistics> mStatistics;
119
120 std::unique_ptr<QgsLazInfo> mLazInfo = nullptr;
121
122 friend class QgsPointCloudLayerEditUtils;
123 friend class QgsPointCloudEditingIndex;
124};
125
127#endif // QGSCOPCPOINTCLOUDINDEX_H
PointCloudAccessType
The access type of the data, local is for local files and remote for remote files (over HTTP).
Definition qgis.h:5850
@ Local
Local means the source is a local file on the machine.
Represents an indexed point clouds data in octree.
virtual QVariantMap originalMetadata() const =0
Returns the original metadata map.
virtual qint64 pointCount() const =0
Returns the number of points in the point cloud.
virtual QgsCoordinateReferenceSystem crs() const =0
Returns the coordinate reference system of the point cloud index.
virtual bool writeStatistics(QgsPointCloudStatistics &stats)
Writes the statistics object stats into the backing file, if possible.
virtual bool hasNode(const QgsPointCloudNodeId &n) const
Returns whether the octree contain given node.
virtual QVariantMap extraMetadata() const
Returns extra metadata that's not accessible through the other methods in an implementation-specific ...
virtual void load(const QString &fileName)=0
Loads the index from the file.
virtual QgsPointCloudBlockRequest * asyncNodeData(const QgsPointCloudNodeId &n, const QgsPointCloudRequest &request)=0
Returns a handle responsible for loading a node data block.
virtual Qgis::PointCloudAccessType 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 QgsPointCloudStatistics metadataStatistics() const
Returns the object containing the statistics metadata extracted from the dataset.
virtual std::unique_ptr< QgsPointCloudBlock > nodeData(const QgsPointCloudNodeId &n, const QgsPointCloudRequest &request)=0
Returns node data block.
virtual bool isValid() const =0
Returns whether index is loaded and valid.
virtual QgsPointCloudNode getNode(const QgsPointCloudNodeId &id) const
Returns object for a given node.
Represents a coordinate reference system (CRS).
Extracts information contained in a LAZ file, such as the public header block and variable length rec...
Definition qgslazinfo.h:39
Base class for handling loading QgsPointCloudBlock asynchronously.
A QgsPointCloudIndex that is used as an editing buffer when editing point cloud data.
Contains utility functions for editing point cloud layers.
Represents an indexed point cloud node's position in octree.
Keeps metadata for an indexed point cloud node.
Point cloud data request.
Used to store statistics of a point cloud dataset.