QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgslazinfo.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslazinfo.h
3 --------------------
4 begin : April 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 QGSLAZINFO_H
19#define QGSLAZINFO_H
20
21#include <fstream>
22
23#include "lazperf/header.hpp"
26
27#define SIP_NO_FILE
28
37class CORE_EXPORT QgsLazInfo
38{
39 public:
40 struct LazVlr
41 {
42 QString userId;
44 QByteArray data;
45 };
46
54
56 QgsLazInfo();
57
59 bool isValid() const { return mIsValid; }
60
62 QString error() const { return mError; }
63
65 void parseRawHeader( char *data, uint64_t length );
66
68 void parseRawVlrEntries( char *data, uint64_t length );
69
71 uint64_t pointCount() const
72 {
73 return mHeader.version.major == 1 && mHeader.version.minor == 4 ? mHeader.point_count_14 : mHeader.point_count;
74 }
75
76 QgsVector3D scale() const { return mScale; }
78 QgsVector3D offset() const { return mOffset; }
80 QPair<uint16_t, uint16_t> creationYearDay() const { return mCreationYearDay; }
82 QPair<uint8_t, uint8_t> version() const { return mVersion; }
84 int pointFormat() const { return mPointFormat; }
86 QString projectId() const { return mProjectId; }
88 QString systemId() const { return mSystemId; }
90 QString softwareId() const { return mSoftwareId; }
92 QgsVector3D minCoords() const { return mMinCoords; }
94 QgsVector3D maxCoords() const { return mMaxCoords; }
96 uint32_t firstPointRecordOffset() const { return mHeader.point_offset; }
98 uint32_t firstVariableLengthRecord() const;
100 int pointRecordLength() const { return mHeader.point_record_length; }
102 int extrabytesCount() const { return mHeader.ebCount(); }
103
105 uint64_t firstEvlrOffset() const { return mHeader.evlr_offset; }
107 uint32_t evlrCount() const { return mHeader.evlr_count; }
108
110 QgsCoordinateReferenceSystem crs() const { return mCrs; }
111
113 QVariantMap toMetadata() const;
114
116 QByteArray vlrData( QString userId, int recordId );
117
119 QgsPointCloudAttributeCollection attributes() const { return mAttributes; }
120
122 QVector<ExtraBytesAttributeDetails> extrabytes() const { return mExtrabyteAttributes; }
123
124#ifndef SIP_RUN
126 lazperf::header14 header() const { return mHeader; }
127#endif
128
130 static QVector<ExtraBytesAttributeDetails> parseExtrabytes( char *rawData, int length, int pointRecordLength );
131
133 static QgsLazInfo fromFile( std::ifstream &file );
135 static QgsLazInfo fromUrl( QUrl &url, const QString &authcfg = QString() );
136
137 private:
138 void parseHeader( lazperf::header14 &header );
139 void parseCrs();
140 void parseLazAttributes();
141 void parseExtrabyteAttributes();
142 private:
143 bool mIsValid = false;
144 QString mError;
145
146 lazperf::header14 mHeader;
147
148 QgsVector3D mScale, mOffset;
149 QPair<uint16_t, uint16_t> mCreationYearDay;
150 QPair<uint8_t, uint8_t> mVersion;
151 int mPointFormat = -1;
152 QString mProjectId;
153 QString mSystemId;
154 QString mSoftwareId;
155
157
158 QgsVector3D mMinCoords, mMaxCoords;
159
160 int mVlrCount = 0;
161
162 QVector<LazVlr> mVlrVector;
163
165 QVector<ExtraBytesAttributeDetails> mExtrabyteAttributes;
166};
167
168#endif // QGSLAZINFO_H
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:38
QString systemId() const
Returns the system identifier contained in the LAZ file public header block.
Definition qgslazinfo.h:88
QgsVector3D maxCoords() const
Returns the maximum coordinate across X, Y and Z axis.
Definition qgslazinfo.h:94
QgsPointCloudAttributeCollection attributes() const
Returns the list of attributes contained in the LAZ file.
Definition qgslazinfo.h:119
int extrabytesCount() const
Returns the number of extrabytes contained in the LAZ dataset.
Definition qgslazinfo.h:102
bool isValid() const
Returns whether the LAZ header data passed to this class is from a valid LAZ file.
Definition qgslazinfo.h:59
QString projectId() const
Returns the project identifier contained in the LAZ file public header block (Optional field).
Definition qgslazinfo.h:86
uint64_t firstEvlrOffset() const
Returns the absolute offset to the first extended point record in the LAZ file.
Definition qgslazinfo.h:105
QString error() const
Returns an error string detailing what went wrong with reading the LAZ info.
Definition qgslazinfo.h:62
uint32_t firstPointRecordOffset() const
Returns the absolute offset to the first point record in the LAZ file.
Definition qgslazinfo.h:96
uint32_t evlrCount() const
Returns the absolute offset to the first variable length record in the LAZ file.
Definition qgslazinfo.h:107
QPair< uint8_t, uint8_t > version() const
Returns the LAZ specification version of the LAZ file.
Definition qgslazinfo.h:82
lazperf::header14 header() const
Returns the LAZPERF header object.
Definition qgslazinfo.h:126
QgsVector3D scale() const
Returns the scale of the points coordinates.
Definition qgslazinfo.h:76
uint64_t pointCount() const
Returns the number of points contained in the LAZ file.
Definition qgslazinfo.h:71
int pointFormat() const
Returns the point format of the point records contained in the LAZ file.
Definition qgslazinfo.h:84
QPair< uint16_t, uint16_t > creationYearDay() const
Returns the pair ( creation_year, creation_day ) extracted from the LAZ file public header block.
Definition qgslazinfo.h:80
QgsCoordinateReferenceSystem crs() const
Returns the coordinate system stored in the LAZ file.
Definition qgslazinfo.h:110
QVector< ExtraBytesAttributeDetails > extrabytes() const
Returns the list of extrabytes contained in the LAZ file.
Definition qgslazinfo.h:122
QString softwareId() const
Returns the identifier of the software used to generate the LAZ file public header block.
Definition qgslazinfo.h:90
QgsLazInfo()
Constructor for an empty laz info parser.
QgsVector3D minCoords() const
Returns the minimum coordinate across X, Y and Z axis.
Definition qgslazinfo.h:92
QgsVector3D offset() const
Returns the offset of the points coordinates.
Definition qgslazinfo.h:78
int pointRecordLength() const
Returns the length of each point record in bytes.
Definition qgslazinfo.h:100
A collection of point cloud attributes.
DataType
Systems of unit measurement.
A 3D vector (similar to QVector3D) with the difference that it uses double precision instead of singl...
Definition qgsvector3d.h:30
QgsPointCloudAttribute::DataType type
Definition qgslazinfo.h:50
QByteArray data
Definition qgslazinfo.h:44