QGIS API Documentation 4.1.0-Master (376402f9aeb)
Loading...
Searching...
No Matches
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 <fstream>
22#include <optional>
23
24#include "lazperf/vlr.hpp"
25#include "qgslazinfo.h"
26#include "qgspointcloudindex.h"
28
29#include <QFile>
30#include <QHash>
31#include <QList>
32#include <QString>
33#include <QStringList>
34#include <QVector>
35
36#define SIP_NO_FILE
37
39
41
42class CORE_EXPORT QgsCopcPointCloudIndex : public QgsAbstractPointCloudIndex
43{
44 public:
45 explicit QgsCopcPointCloudIndex();
46 ~QgsCopcPointCloudIndex() override;
47
48 void load( const QString &urlString, const QString &authcfg = QString() ) override;
49
50 bool hasNode( QgsPointCloudNodeId n ) const override;
52
53 std::unique_ptr< QgsPointCloudBlock> nodeData( QgsPointCloudNodeId n, const QgsPointCloudRequest &request ) override;
55
57 const QByteArray rawNodeData( QgsPointCloudNodeId n ) const;
58
59 QgsCoordinateReferenceSystem crs() const override;
60 qint64 pointCount() const override;
61 QVariantMap originalMetadata() const override { return mOriginalMetadata; }
62
63 bool isValid() const override;
64 Qgis::PointCloudAccessType accessType() const override { return mAccessType; };
65
71 bool writeStatistics( QgsPointCloudStatistics &stats ) override;
72
78 QgsPointCloudStatistics metadataStatistics() const override;
79
85 QVariantMap extraMetadata() const override;
86
87 bool needsHierarchyFetching( const QgsPointCloudNodeId &n ) const override;
88
89 protected:
90 bool loadSchema( QgsLazInfo &lazInfo );
91 bool loadHierarchy() const;
92
94 bool fetchNodeHierarchy( QgsPointCloudNodeId n ) const;
95
99 void fetchHierarchyPage( uint64_t offset, uint64_t byteSize ) const;
100
101 void populateHierarchy( const char *hierarchyPageData, uint64_t byteSize ) const;
102
104 QByteArray readRange( uint64_t offset, uint64_t length ) const;
105
106 QByteArray fetchCopcStatisticsEvlrData() const;
107
108 void reset();
109
110 bool mIsValid = false;
112 mutable std::ifstream mCopcFile;
113 mutable lazperf::copc_info_vlr mCopcInfoVlr;
114 mutable QHash<QgsPointCloudNodeId, QPair<uint64_t, int32_t>> mHierarchyNodePos;
115
116 mutable QMutex mFileMutex;
117
118 QVariantMap mOriginalMetadata;
119 mutable std::optional<QgsPointCloudStatistics> mStatistics;
120
121 std::unique_ptr<QgsLazInfo> mLazInfo = nullptr;
122
123 friend class QgsPointCloudLayerEditUtils;
124 friend class QgsPointCloudEditingIndex;
125};
126
128#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:6588
@ Local
Local means the source is a local file on the machine.
Definition qgis.h:6589
Represents an indexed point clouds data in octree.
virtual QVariantMap originalMetadata() const =0
Returns the original metadata map.
virtual QgsPointCloudNode getNode(QgsPointCloudNodeId id) const
Returns object for a given node.
virtual qint64 pointCount() const =0
Returns the number of points in the point cloud.
virtual bool hasNode(QgsPointCloudNodeId n) const
Returns whether the octree contain given node.
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 QVariantMap extraMetadata() const
Returns extra metadata that's not accessible through the other methods in an implementation-specific ...
virtual std::unique_ptr< QgsPointCloudBlock > nodeData(QgsPointCloudNodeId n, const QgsPointCloudRequest &request)=0
Returns 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 QgsPointCloudBlockRequest * asyncNodeData(QgsPointCloudNodeId n, const QgsPointCloudRequest &request)=0
Returns a handle responsible for loading a node data block.
virtual bool needsHierarchyFetching(const QgsPointCloudNodeId &) const
Returns whether calling getNode() for node will trigger a hierarchy page fetch.
virtual QgsPointCloudStatistics metadataStatistics() const
Returns the object containing the statistics metadata extracted from the dataset.
virtual void load(const QString &uri, const QString &authcfg=QString())=0
Loads the index from the uri, using an optional authcfg for network requests.
virtual bool isValid() const =0
Returns whether index is loaded and valid.
Represents a coordinate reference system (CRS).
Base class for handling loading QgsPointCloudBlock asynchronously.
Represents an indexed point cloud node's position in octree.
Keeps metadata for an indexed point cloud node.
Point cloud data request.