QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgspointcloudattribute.h
Go to the documentation of this file.
1/***************************************************************************
2 qgspointcloudattribute.h
3 ---------------------
4 begin : October 2020
5 copyright : (C) 2020 by Peter Petrik
6 email : zilolv 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 QGSPOINTCLOUDATTRIBUTE_H
19#define QGSPOINTCLOUDATTRIBUTE_H
20
21#include "qgis.h"
22#include "qgis_core.h"
23#include "qgsfields.h"
24#include <QString>
25#include <QVector>
26#include <QSet>
27
28#include "qgsvector3d.h"
29
31
40class CORE_EXPORT QgsPointCloudAttribute
41{
42 public:
45 {
56 };
57
61 QgsPointCloudAttribute( const QString &name, DataType type );
62
64 QString name() const { return mName; }
65
67 int size() const { return mSize; }
68
74 DataType type() const { return mType; }
75
81 QVariant::Type variantType() const;
82
90 QString displayType() const;
91
98 double convertValueToDouble( const char *ptr ) const SIP_SKIP;
99
103 static bool isNumeric( DataType type );
104
105#ifdef SIP_RUN
106 SIP_PYOBJECT __repr__();
107 % MethodCode
108 QString str = QStringLiteral( "<QgsPointCloudAttribute: %1 (%2)>" ).arg( sipCpp->name() ).arg( sipCpp->displayType() );
109 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
110 % End
111#endif
112
116 static void getPointXYZ( const char *ptr, int i, std::size_t pointRecordSize, int xOffset, QgsPointCloudAttribute::DataType xType,
117 int yOffset, QgsPointCloudAttribute::DataType yType,
118 int zOffset, QgsPointCloudAttribute::DataType zType,
119 const QgsVector3D &indexScale, const QgsVector3D &indexOffset, double &x, double &y, double &z ) SIP_SKIP;
120
124 static QVariantMap getAttributeMap( const char *data, std::size_t recordOffset, const QgsPointCloudAttributeCollection &attributeCollection ) SIP_SKIP;
125
126 private:
127 void updateSize();
128
129 QString mName;
130 int mSize = 0;
131 DataType mType;
132};
133
142{
143 public:
147 QgsPointCloudAttributeCollection( const QVector<QgsPointCloudAttribute> &attributes );
149 void push_back( const QgsPointCloudAttribute &attribute );
150
157 void extend( const QgsPointCloudAttributeCollection &otherCollection, const QSet<QString> &matchingNames );
158
160 QVector<QgsPointCloudAttribute> attributes() const;
161
165 int count() const { return mAttributes.size(); }
166
170 const QgsPointCloudAttribute &at( int index ) const { return mAttributes.at( index ); }
171
177 const QgsPointCloudAttribute *find( const QString &attributeName, int &offset ) const;
178
184 int indexOf( const QString &name ) const;
185
187 int pointRecordSize() const { return mSize; }
188
192 QgsFields toFields() const;
193
194 private:
195 int mSize = 0;
196 QVector<QgsPointCloudAttribute> mAttributes;
197
198 struct CachedAttributeData
199 {
200 int index;
201 int offset;
202 CachedAttributeData( int index, int offset )
203 : index( index )
204 , offset( offset )
205 {}
206 };
207
208 QMap< QString, CachedAttributeData > mCachedAttributes;
209};
210
211#endif // QGSPOINTCLOUDATTRIBUTE_H
Container of fields for a vector layer.
Definition: qgsfields.h:45
Collection of point cloud attributes.
int pointRecordSize() const
Returns total size of record.
const QgsPointCloudAttribute & at(int index) const
Returns the attribute at the specified index.
int count() const
Returns the number of attributes present in the collection.
Attribute for point cloud data pair of name and size in bytes.
DataType
Systems of unit measurement.
@ UShort
Unsigned short int 2 bytes.
@ UChar
Unsigned char 1 byte.
@ UInt32
Unsigned int32 4 bytes.
@ UInt64
Unsigned int64 8 bytes.
int size() const
Returns size of the attribute in bytes.
QString name() const
Returns name of the attribute.
DataType type() const
Returns the data type.
#define str(x)
Definition: qgis.cpp:37
#define SIP_SKIP
Definition: qgis_sip.h:126