QGIS API Documentation  3.24.2-Tisler (13c1a02865)
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 
27 #include "qgsvector3d.h"
28 
30 
39 class CORE_EXPORT QgsPointCloudAttribute
40 {
41  public:
43  enum DataType
44  {
45  Char,
55  };
56 
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  QVariant::Type variantType() const;
81 
89  QString displayType() const;
90 
94  static bool isNumeric( DataType type );
95 
96 #ifdef SIP_RUN
97  SIP_PYOBJECT __repr__();
98  % MethodCode
99  QString str = QStringLiteral( "<QgsPointCloudAttribute: %1 (%2)>" ).arg( sipCpp->name() ).arg( sipCpp->displayType() );
100  sipRes = PyUnicode_FromString( str.toUtf8().constData() );
101  % End
102 #endif
103 
107  static void getPointXYZ( const char *ptr, int i, std::size_t pointRecordSize, int xOffset, QgsPointCloudAttribute::DataType xType,
108  int yOffset, QgsPointCloudAttribute::DataType yType,
109  int zOffset, QgsPointCloudAttribute::DataType zType,
110  const QgsVector3D &indexScale, const QgsVector3D &indexOffset, double &x, double &y, double &z ) SIP_SKIP;
111 
115  static QVariantMap getAttributeMap( const char *data, std::size_t recordOffset, const QgsPointCloudAttributeCollection &attributeCollection ) SIP_SKIP;
116 
117  private:
118  void updateSize();
119 
120  QString mName;
121  int mSize = 0;
122  DataType mType;
123 };
124 
133 {
134  public:
138  QgsPointCloudAttributeCollection( const QVector<QgsPointCloudAttribute> &attributes );
140  void push_back( const QgsPointCloudAttribute &attribute );
141 
143  QVector<QgsPointCloudAttribute> attributes() const;
144 
148  int count() const { return mAttributes.size(); }
149 
153  const QgsPointCloudAttribute &at( int index ) const { return mAttributes.at( index ); }
154 
160  const QgsPointCloudAttribute *find( const QString &attributeName, int &offset ) const;
161 
167  int indexOf( const QString &name ) const;
168 
170  int pointRecordSize() const { return mSize; }
171 
175  QgsFields toFields() const;
176 
177  private:
178  int mSize = 0;
179  QVector<QgsPointCloudAttribute> mAttributes;
180 
181  struct CachedAttributeData
182  {
183  int index;
184  int offset;
185  CachedAttributeData( int index, int offset )
186  : index( index )
187  , offset( offset )
188  {}
189  };
190 
191  QMap< QString, CachedAttributeData > mCachedAttributes;
192 };
193 
194 #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.
int count() const
Returns the number of attributes present in the collection.
const QgsPointCloudAttribute & at(int index) const
Returns the attribute at the specified index.
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