QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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 "qgsvector3d.h"
25
26#include <QSet>
27#include <QString>
28#include <QVector>
29
30using namespace Qt::StringLiterals;
31
33
42class CORE_EXPORT QgsPointCloudAttribute
43{
44 public:
59
62 QgsPointCloudAttribute( const QString &name, DataType type );
63
65 QString name() const { return mName; }
66
68 int size() const { return mSize; }
69
75 DataType type() const { return mType; }
76
82 QMetaType::Type variantType() const;
83
91 QString displayType() const;
92
99 double convertValueToDouble( const char *ptr ) const SIP_SKIP;
100
104 static bool isNumeric( DataType type );
105
106#ifdef SIP_RUN
107 // clang-format off
108 SIP_PYOBJECT __repr__();
109 % MethodCode
110 QString str = u"<QgsPointCloudAttribute: %1 (%2)>"_s.arg( sipCpp->name() ).arg( sipCpp->displayType() );
111 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
112 % End
113// clang-format on
114#endif
115
119 static void getPointXYZ(
120 const char *ptr,
121 int i,
122 std::size_t pointRecordSize,
123 int xOffset,
125 int yOffset,
127 int zOffset,
129 const QgsVector3D &indexScale,
130 const QgsVector3D &indexOffset,
131 double &x,
132 double &y,
133 double &z
134 ) SIP_SKIP;
135
139 static QVariantMap getAttributeMap( const char *data, std::size_t recordOffset, const QgsPointCloudAttributeCollection &attributeCollection ) SIP_SKIP;
140
141 private:
142 void updateSize();
143
144 QString mName;
145 int mSize = 0;
146 DataType mType = DataType::Char;
147};
148
157{
158 public:
161 QgsPointCloudAttributeCollection( const QVector<QgsPointCloudAttribute> &attributes );
163 void push_back( const QgsPointCloudAttribute &attribute );
164
171 void extend( const QgsPointCloudAttributeCollection &otherCollection, const QSet<QString> &matchingNames );
172
174 QVector<QgsPointCloudAttribute> attributes() const;
175
179 int count() const { return mAttributes.size(); }
180
184 const QgsPointCloudAttribute &at( int index ) const { return mAttributes.at( index ); }
185
191 const QgsPointCloudAttribute *find( const QString &attributeName, int &offset ) const;
192
198 int indexOf( const QString &name ) const;
199
201 int pointRecordSize() const { return mSize; }
202
206 QgsFields toFields() const;
207
208 private:
209 int mSize = 0;
210 QVector<QgsPointCloudAttribute> mAttributes;
211
212 struct CachedAttributeData
213 {
214 int index;
215 int offset;
216 CachedAttributeData( int index, int offset )
217 : index( index )
218 , offset( offset )
219 {}
220 };
221
222 QMap< QString, CachedAttributeData > mCachedAttributes;
223};
224
225#endif // QGSPOINTCLOUDATTRIBUTE_H
Container of fields for a vector layer.
Definition qgsfields.h:46
A collection of point cloud attributes.
void push_back(const QgsPointCloudAttribute &attribute)
Adds extra attribute.
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.
void extend(const QgsPointCloudAttributeCollection &otherCollection, const QSet< QString > &matchingNames)
Adds specific missing attributes from another QgsPointCloudAttributeCollection.
QVector< QgsPointCloudAttribute > attributes() const
Returns all attributes.
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.
A 3D vector (similar to QVector3D) with the difference that it uses double precision instead of singl...
Definition qgsvector3d.h:33
#define SIP_SKIP
Definition qgis_sip.h:133