QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 "qgspointcloudattribute.h"
25 
26 #include "lazperf/header.hpp"
27 
28 #define SIP_NO_FILE
29 
38 class CORE_EXPORT QgsLazInfo
39 {
40  public:
41  struct LazVlr
42  {
43  QString userId;
44  int recordId;
45  QByteArray data;
46  };
47 
49  {
50  QString attribute;
52  int size;
53  int offset;
54  };
55 
57  QgsLazInfo();
58 
60  bool isValid() const { return mIsValid; }
61 
63  QString error() const { return mError; }
64 
66  void parseRawHeader( char *data, uint64_t length );
67 
69  void parseRawVlrEntries( char *data, uint64_t length );
70 
72  uint64_t pointCount() const
73  {
74  return mHeader.version.major == 1 && mHeader.version.minor == 4 ? mHeader.point_count_14 : mHeader.point_count;
75  }
77  QgsVector3D scale() const { return mScale; }
79  QgsVector3D offset() const { return mOffset; }
81  QPair<uint16_t, uint16_t> creationYearDay() const { return mCreationYearDay; }
83  QPair<uint8_t, uint8_t> version() const { return mVersion; }
85  int pointFormat() const { return mPointFormat; }
87  QString projectId() const { return mProjectId; }
89  QString systemId() const { return mSystemId; }
91  QString softwareId() const { return mSoftwareId; }
93  QgsVector3D minCoords() const { return mMinCoords; }
95  QgsVector3D maxCoords() const { return mMaxCoords; }
97  uint32_t firstPointRecordOffset() const { return mHeader.point_offset; }
99  uint32_t firstVariableLengthRecord() const;
101  int pointRecordLength() const { return mHeader.point_record_length; }
103  int extrabytesCount() const { return mHeader.ebCount(); }
104 
106  uint64_t firstEvlrOffset() const { return mHeader.evlr_offset; }
108  uint32_t evlrCount() const { return mHeader.evlr_count; }
109 
111  QgsCoordinateReferenceSystem crs() const { return mCrs; }
112 
114  QVariantMap toMetadata() const;
115 
117  QByteArray vlrData( QString userId, int recordId );
118 
120  QgsPointCloudAttributeCollection attributes() const { return mAttributes; }
121 
123  QVector<ExtraBytesAttributeDetails> extrabytes() const { return mExtrabyteAttributes; }
124 
125 #ifndef SIP_RUN
126  lazperf::header14 header() const { return mHeader; }
128 #endif
129 
131  static QVector<ExtraBytesAttributeDetails> parseExtrabytes( char *rawData, int length, int pointRecordLength );
132 
134  static QgsLazInfo fromFile( std::ifstream &file );
136  static QgsLazInfo fromUrl( QUrl &url );
137 
139  static bool supportsRangeQueries( QUrl &url );
140 
141  private:
142  void parseHeader( lazperf::header14 &header );
143  void parseCrs();
144  void parseLazAttributes();
145  void parseExtrabyteAttributes();
146  private:
147  bool mIsValid = false;
148  QString mError;
149 
150  lazperf::header14 mHeader;
151 
152  QgsVector3D mScale, mOffset;
153  QPair<uint16_t, uint16_t> mCreationYearDay;
154  QPair<uint8_t, uint8_t> mVersion;
155  int mPointFormat = -1;
156  QString mProjectId;
157  QString mSystemId;
158  QString mSoftwareId;
159 
161 
162  QgsVector3D mMinCoords, mMaxCoords;
163 
164  int mVlrCount = 0;
165 
166  QVector<LazVlr> mVlrVector;
167 
169  QVector<ExtraBytesAttributeDetails> mExtrabyteAttributes;
170 };
171 
172 #endif // QGSLAZINFO_H
QgsPointCloudAttribute::DataType
DataType
Systems of unit measurement.
Definition: qgspointcloudattribute.h:44
QgsLazInfo::pointFormat
int pointFormat() const
Returns the point format of the point records contained in the LAZ file.
Definition: qgslazinfo.h:85
QgsVector3D
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
Definition: qgsvector3d.h:31
qgspointcloudattribute.h
QgsLazInfo::ExtraBytesAttributeDetails::size
int size
Definition: qgslazinfo.h:52
QgsLazInfo::evlrCount
uint32_t evlrCount() const
Returns the absolute offset to the first variable length record in the LAZ file.
Definition: qgslazinfo.h:108
QgsLazInfo::crs
QgsCoordinateReferenceSystem crs() const
Returns the coordinate system stored in the LAZ file.
Definition: qgslazinfo.h:111
QgsLazInfo::extrabytesCount
int extrabytesCount() const
Returns the number of extrabytes contained in the LAZ dataset.
Definition: qgslazinfo.h:103
QgsLazInfo::version
QPair< uint8_t, uint8_t > version() const
Returns the LAZ specification version of the LAZ file.
Definition: qgslazinfo.h:83
QgsLazInfo::projectId
QString projectId() const
Returns the project identifier contained in the LAZ file public header block (Optional field)
Definition: qgslazinfo.h:87
QgsLazInfo::ExtraBytesAttributeDetails::attribute
QString attribute
Definition: qgslazinfo.h:50
QgsLazInfo::error
QString error() const
Returns an error string detailing what went wrong with reading the LAZ info.
Definition: qgslazinfo.h:63
QgsLazInfo::ExtraBytesAttributeDetails
Definition: qgslazinfo.h:48
QgsLazInfo::ExtraBytesAttributeDetails::offset
int offset
Definition: qgslazinfo.h:53
QgsLazInfo::minCoords
QgsVector3D minCoords() const
Returns the minimum coordinate across X, Y and Z axis.
Definition: qgslazinfo.h:93
QgsPointCloudAttributeCollection
Collection of point cloud attributes.
Definition: qgspointcloudattribute.h:141
QgsLazInfo::isValid
bool isValid() const
Returns whether the LAZ header data passed to this class is from a valid LAZ file.
Definition: qgslazinfo.h:60
QgsLazInfo::softwareId
QString softwareId() const
Returns the identifier of the software used to generate the LAZ file public header block.
Definition: qgslazinfo.h:91
QgsLazInfo::creationYearDay
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:81
QgsLazInfo::attributes
QgsPointCloudAttributeCollection attributes() const
Returns the list of attributes contained in the LAZ file.
Definition: qgslazinfo.h:120
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:211
QgsLazInfo
Class for extracting information contained in LAZ file such as the public header block and variable l...
Definition: qgslazinfo.h:38
QgsLazInfo::firstPointRecordOffset
uint32_t firstPointRecordOffset() const
Returns the absolute offset to the first point record in the LAZ file.
Definition: qgslazinfo.h:97
QgsLazInfo::pointCount
uint64_t pointCount() const
Returns the number of points contained in the LAZ file.
Definition: qgslazinfo.h:72
QgsLazInfo::LazVlr::recordId
int recordId
Definition: qgslazinfo.h:44
QgsLazInfo::offset
QgsVector3D offset() const
Returns the offset of the points coordinates.
Definition: qgslazinfo.h:79
QgsLazInfo::firstEvlrOffset
uint64_t firstEvlrOffset() const
Returns the absolute offset to the first extended point record in the LAZ file.
Definition: qgslazinfo.h:106
QgsLazInfo::extrabytes
QVector< ExtraBytesAttributeDetails > extrabytes() const
Returns the list of extrabytes contained in the LAZ file.
Definition: qgslazinfo.h:123
QgsLazInfo::maxCoords
QgsVector3D maxCoords() const
Returns the maximum coordinate across X, Y and Z axis.
Definition: qgslazinfo.h:95
QgsLazInfo::pointRecordLength
int pointRecordLength() const
Returns the length of each point record in bytes.
Definition: qgslazinfo.h:101
QgsLazInfo::scale
QgsVector3D scale() const
Returns the scale of the points coordinates.
Definition: qgslazinfo.h:77
QgsLazInfo::ExtraBytesAttributeDetails::type
QgsPointCloudAttribute::DataType type
Definition: qgslazinfo.h:51
QgsLazInfo::LazVlr::userId
QString userId
Definition: qgslazinfo.h:43
QgsLazInfo::LazVlr
Definition: qgslazinfo.h:41
QgsLazInfo::LazVlr::data
QByteArray data
Definition: qgslazinfo.h:45
QgsLazInfo::systemId
QString systemId() const
Returns the system identifier contained in the LAZ file public header block.
Definition: qgslazinfo.h:89
qgscoordinatereferencesystem.h