QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
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:
57
60 QgsPointCloudAttribute( const QString &name, DataType type );
61
63 QString name() const { return mName; }
64
66 int size() const { return mSize; }
67
73 DataType type() const { return mType; }
74
80 QMetaType::Type variantType() const;
81
89 QString displayType() const;
90
97 double convertValueToDouble( const char *ptr ) const SIP_SKIP;
98
102 static bool isNumeric( DataType type );
103
104#ifdef SIP_RUN
105 SIP_PYOBJECT __repr__();
106 % MethodCode
107 QString str = QStringLiteral( "<QgsPointCloudAttribute: %1 (%2)>" ).arg( sipCpp->name() ).arg( sipCpp->displayType() );
108 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
109 % End
110#endif
111
115 static void getPointXYZ( const char *ptr, int i, std::size_t pointRecordSize, int xOffset, QgsPointCloudAttribute::DataType xType,
116 int yOffset, QgsPointCloudAttribute::DataType yType,
117 int zOffset, QgsPointCloudAttribute::DataType zType,
118 const QgsVector3D &indexScale, const QgsVector3D &indexOffset, double &x, double &y, double &z ) SIP_SKIP;
119
123 static QVariantMap getAttributeMap( const char *data, std::size_t recordOffset, const QgsPointCloudAttributeCollection &attributeCollection ) SIP_SKIP;
124
125 private:
126 void updateSize();
127
128 QString mName;
129 int mSize = 0;
130 DataType mType = DataType::Char;
131};
132
141{
142 public:
143
146 QgsPointCloudAttributeCollection( const QVector<QgsPointCloudAttribute> &attributes );
148 void push_back( const QgsPointCloudAttribute &attribute );
149
156 void extend( const QgsPointCloudAttributeCollection &otherCollection, const QSet<QString> &matchingNames );
157
159 QVector<QgsPointCloudAttribute> attributes() const;
160
164 int count() const { return mAttributes.size(); }
165
169 const QgsPointCloudAttribute &at( int index ) const { return mAttributes.at( index ); }
170
176 const QgsPointCloudAttribute *find( const QString &attributeName, int &offset ) const;
177
183 int indexOf( const QString &name ) const;
184
186 int pointRecordSize() const { return mSize; }
187
191 QgsFields toFields() const;
192
193 private:
194 int mSize = 0;
195 QVector<QgsPointCloudAttribute> mAttributes;
196
197 struct CachedAttributeData
198 {
199 int index;
200 int offset;
201 CachedAttributeData( int index, int offset )
202 : index( index )
203 , offset( offset )
204 {}
205 };
206
207 QMap< QString, CachedAttributeData > mCachedAttributes;
208};
209
210#endif // QGSPOINTCLOUDATTRIBUTE_H
Container of fields for a vector layer.
Definition qgsfields.h:46
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.
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
Definition qgsvector3d.h:31
#define str(x)
Definition qgis.cpp:39
#define SIP_SKIP
Definition qgis_sip.h:126