QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
40 class CORE_EXPORT QgsPointCloudAttribute
41 {
42  public:
44  enum DataType
45  {
46  Char,
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
qgsfields.h
QgsPointCloudAttribute::DataType
DataType
Systems of unit measurement.
Definition: qgspointcloudattribute.h:44
QgsVector3D
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
Definition: qgsvector3d.h:31
QgsFields
Container of fields for a vector layer.
Definition: qgsfields.h:44
QgsPointCloudAttributeCollection::at
const QgsPointCloudAttribute & at(int index) const
Returns the attribute at the specified index.
Definition: qgspointcloudattribute.h:170
qgis.h
QgsPointCloudAttribute::UInt32
@ UInt32
Unsigned int32 4 bytes.
Definition: qgspointcloudattribute.h:51
QgsPointCloudAttributeCollection::count
int count() const
Returns the number of attributes present in the collection.
Definition: qgspointcloudattribute.h:165
QgsPointCloudAttribute::name
QString name() const
Returns name of the attribute.
Definition: qgspointcloudattribute.h:64
QgsPointCloudAttribute::Double
@ Double
Double 8 bytes.
Definition: qgspointcloudattribute.h:55
QgsPointCloudAttribute::Short
@ Short
Short int 2 bytes.
Definition: qgspointcloudattribute.h:48
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsPointCloudAttribute::UInt64
@ UInt64
Unsigned int64 8 bytes.
Definition: qgspointcloudattribute.h:53
QgsPointCloudAttribute::Int32
@ Int32
Int32 4 bytes.
Definition: qgspointcloudattribute.h:50
QgsPointCloudAttributeCollection::pointRecordSize
int pointRecordSize() const
Returns total size of record.
Definition: qgspointcloudattribute.h:187
QgsPointCloudAttribute::UShort
@ UShort
Unsigned short int 2 bytes.
Definition: qgspointcloudattribute.h:49
QgsPointCloudAttributeCollection
Collection of point cloud attributes.
Definition: qgspointcloudattribute.h:141
QgsPointCloudAttribute::Char
@ Char
Char 1 byte.
Definition: qgspointcloudattribute.h:46
QgsPointCloudAttribute
Attribute for point cloud data pair of name and size in bytes.
Definition: qgspointcloudattribute.h:40
QgsPointCloudAttribute::Int64
@ Int64
Int64 8 bytes.
Definition: qgspointcloudattribute.h:52
QgsPointCloudAttribute::size
int size() const
Returns size of the attribute in bytes.
Definition: qgspointcloudattribute.h:67
qgsvector3d.h
str
#define str(x)
Definition: qgis.cpp:37
QgsPointCloudAttribute::UChar
@ UChar
Unsigned char 1 byte.
Definition: qgspointcloudattribute.h:47
QgsPointCloudAttribute::Float
@ Float
Float 4 bytes.
Definition: qgspointcloudattribute.h:54
QgsPointCloudAttribute::type
DataType type() const
Returns the data type.
Definition: qgspointcloudattribute.h:74