QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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 { return mHeader.version.major == 1 && mHeader.version.minor == 4 ? mHeader.point_count_14 : mHeader.point_count; }
73 QgsVector3D scale() const { return mScale; }
75 QgsVector3D offset() const { return mOffset; }
77 QPair<uint16_t, uint16_t> creationYearDay() const { return mCreationYearDay; }
79 QPair<uint8_t, uint8_t> version() const { return mVersion; }
81 int pointFormat() const { return mPointFormat; }
83 QString projectId() const { return mProjectId; }
85 QString systemId() const { return mSystemId; }
87 QString softwareId() const { return mSoftwareId; }
89 QgsVector3D minCoords() const { return mMinCoords; }
91 QgsVector3D maxCoords() const { return mMaxCoords; }
93 uint32_t firstPointRecordOffset() const { return mHeader.point_offset; }
95 uint32_t firstVariableLengthRecord() const;
97 int pointRecordLength() const { return mHeader.point_record_length; }
99 int extrabytesCount() const { return mHeader.ebCount(); }
100
102 uint64_t firstEvlrOffset() const { return mHeader.evlr_offset; }
104 uint32_t evlrCount() const { return mHeader.evlr_count; }
105
107 QgsCoordinateReferenceSystem crs() const { return mCrs; }
108
110 QVariantMap toMetadata() const;
111
113 QByteArray vlrData( QString userId, int recordId );
114
116 QgsPointCloudAttributeCollection attributes() const { return mAttributes; }
117
119 QVector<ExtraBytesAttributeDetails> extrabytes() const { return mExtrabyteAttributes; }
120
121#ifndef SIP_RUN
123 lazperf::header14 header() const { return mHeader; }
124#endif
125
127 static QVector<ExtraBytesAttributeDetails> parseExtrabytes( char *rawData, int length, int pointRecordLength );
128
130 static QgsLazInfo fromFile( std::ifstream &file );
132 static QgsLazInfo fromUrl( QUrl &url, const QString &authcfg = QString() );
133
134 private:
135 void parseHeader( lazperf::header14 &header );
136 void parseCrs();
137 void parseLazAttributes();
138 void parseExtrabyteAttributes();
139
140 private:
141 bool mIsValid = false;
142 QString mError;
143
144 lazperf::header14 mHeader;
145
146 QgsVector3D mScale, mOffset;
147 QPair<uint16_t, uint16_t> mCreationYearDay;
148 QPair<uint8_t, uint8_t> mVersion;
149 int mPointFormat = -1;
150 QString mProjectId;
151 QString mSystemId;
152 QString mSoftwareId;
153
155
156 QgsVector3D mMinCoords, mMaxCoords;
157
158 int mVlrCount = 0;
159
160 QVector<LazVlr> mVlrVector;
161
163 QVector<ExtraBytesAttributeDetails> mExtrabyteAttributes;
164};
165
166#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:85
QgsVector3D maxCoords() const
Returns the maximum coordinate across X, Y and Z axis.
Definition qgslazinfo.h:91
QgsPointCloudAttributeCollection attributes() const
Returns the list of attributes contained in the LAZ file.
Definition qgslazinfo.h:116
int extrabytesCount() const
Returns the number of extrabytes contained in the LAZ dataset.
Definition qgslazinfo.h:99
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:83
uint64_t firstEvlrOffset() const
Returns the absolute offset to the first extended point record in the LAZ file.
Definition qgslazinfo.h:102
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:93
uint32_t evlrCount() const
Returns the absolute offset to the first variable length record in the LAZ file.
Definition qgslazinfo.h:104
QPair< uint8_t, uint8_t > version() const
Returns the LAZ specification version of the LAZ file.
Definition qgslazinfo.h:79
lazperf::header14 header() const
Returns the LAZPERF header object.
Definition qgslazinfo.h:123
QgsVector3D scale() const
Returns the scale of the points coordinates.
Definition qgslazinfo.h:73
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:81
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:77
QgsCoordinateReferenceSystem crs() const
Returns the coordinate system stored in the LAZ file.
Definition qgslazinfo.h:107
QVector< ExtraBytesAttributeDetails > extrabytes() const
Returns the list of extrabytes contained in the LAZ file.
Definition qgslazinfo.h:119
QString softwareId() const
Returns the identifier of the software used to generate the LAZ file public header block.
Definition qgslazinfo.h:87
QgsLazInfo()
Constructor for an empty laz info parser.
QgsVector3D minCoords() const
Returns the minimum coordinate across X, Y and Z axis.
Definition qgslazinfo.h:89
QgsVector3D offset() const
Returns the offset of the points coordinates.
Definition qgslazinfo.h:75
int pointRecordLength() const
Returns the length of each point record in bytes.
Definition qgslazinfo.h:97
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:33
QgsPointCloudAttribute::DataType type
Definition qgslazinfo.h:50
QByteArray data
Definition qgslazinfo.h:44