QGIS API Documentation  3.20.0-Odense (decaadbb31)
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,
51  };
52 
56  QgsPointCloudAttribute( const QString &name, DataType type );
57 
59  QString name() const { return mName; }
60 
62  int size() const { return mSize; }
63 
69  DataType type() const { return mType; }
70 
76  QVariant::Type variantType() const;
77 
85  QString displayType() const;
86 
90  static bool isNumeric( DataType type );
91 
92 #ifdef SIP_RUN
93  SIP_PYOBJECT __repr__();
94  % MethodCode
95  QString str = QStringLiteral( "<QgsPointCloudAttribute: %1 (%2)>" ).arg( sipCpp->name() ).arg( sipCpp->displayType() );
96  sipRes = PyUnicode_FromString( str.toUtf8().constData() );
97  % End
98 #endif
99 
103  static void getPointXYZ( const char *ptr, int i, std::size_t pointRecordSize, int xOffset, QgsPointCloudAttribute::DataType xType,
104  int yOffset, QgsPointCloudAttribute::DataType yType,
105  int zOffset, QgsPointCloudAttribute::DataType zType,
106  const QgsVector3D &indexScale, const QgsVector3D &indexOffset, double &x, double &y, double &z ) SIP_SKIP;
107 
111  static QVariantMap getAttributeMap( const char *data, std::size_t recordOffset, const QgsPointCloudAttributeCollection &attributeCollection ) SIP_SKIP;
112 
113  private:
114  void updateSize();
115 
116  QString mName;
117  int mSize = 0;
118  DataType mType;
119 };
120 
129 {
130  public:
134  QgsPointCloudAttributeCollection( const QVector<QgsPointCloudAttribute> &attributes );
136  void push_back( const QgsPointCloudAttribute &attribute );
137 
139  QVector<QgsPointCloudAttribute> attributes() const;
140 
144  int count() const { return mAttributes.size(); }
145 
149  const QgsPointCloudAttribute &at( int index ) const { return mAttributes.at( index ); }
150 
156  const QgsPointCloudAttribute *find( const QString &attributeName, int &offset ) const;
157 
163  int indexOf( const QString &name ) const;
164 
166  int pointRecordSize() const { return mSize; }
167 
171  QgsFields toFields() const;
172 
173  private:
174  int mSize = 0;
175  QVector<QgsPointCloudAttribute> mAttributes;
176 
177  struct CachedAttributeData
178  {
179  int index;
180  int offset;
181  CachedAttributeData( int index, int offset )
182  : index( index )
183  , offset( offset )
184  {}
185  };
186 
187  QMap< QString, CachedAttributeData > mCachedAttributes;
188 };
189 
190 #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.
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