37 case DataType::UShort:
38 case DataType::UInt32:
42 case DataType::UInt64:
44 return QVariant::LongLong;
46 case DataType::Double:
47 return QVariant::Double;
49 return QVariant::Invalid;
57 return QObject::tr(
"Unsigned Character" );
59 return QObject::tr(
"Character" );
61 return QObject::tr(
"Short" );
62 case DataType::UShort:
63 return QObject::tr(
"Unsigned Short" );
65 return QObject::tr(
"Float" );
67 return QObject::tr(
"Integer" );
68 case DataType::UInt32:
69 return QObject::tr(
"Unsigned Integer" );
71 return QObject::tr(
"Long Integer" );
72 case DataType::UInt64:
73 return QObject::tr(
"Unsigned Long Integer" );
74 case DataType::Double:
75 return QObject::tr(
"Double" );
88 case DataType::UShort:
90 case DataType::UInt32:
92 case DataType::UInt64:
94 case DataType::Double:
100 void QgsPointCloudAttribute::updateSize()
104 case DataType::UChar:
108 case DataType::Short:
109 case DataType::UShort:
112 case DataType::Float:
115 case DataType::Int32:
116 case DataType::UInt32:
119 case DataType::Int64:
120 case DataType::UInt64:
123 case DataType::Double:
144 mCachedAttributes.insert( attribute.
name(), CachedAttributeData( mAttributes.size(), mSize ) );
145 mAttributes.push_back( attribute );
146 mSize += attribute.
size();
156 const auto it = mCachedAttributes.constFind( attributeName );
157 if ( it != mCachedAttributes.constEnd() )
160 return &mAttributes.at( it->index );
169 const auto it = mCachedAttributes.constFind( name );
170 if ( it != mCachedAttributes.constEnd() )
184 fields.
append(
QgsField( attribute.name(), attribute.variantType(), attribute.displayType() ) );
189 template <
typename T>
196 value = *( data + offset );
200 value = *
reinterpret_cast< const quint32 *
>( data + offset );
203 value = *
reinterpret_cast< const qint32 *
>( data + offset );
207 value = *
reinterpret_cast< const quint64 *
>( data + offset );
210 value = *
reinterpret_cast< const qint64 *
>( data + offset );
215 value = *
reinterpret_cast< const short *
>( data + offset );
220 value = *
reinterpret_cast< const unsigned short *
>( data + offset );
224 value =
static_cast< T
>( *
reinterpret_cast< const float *
>( data + offset ) );
228 value = *
reinterpret_cast< const double *
>( data + offset );
238 _attribute( ptr, i * pointRecordSize + xOffset, xType, x );
239 x = indexOffset.
x() + indexScale.
x() * x;
241 _attribute( ptr, i * pointRecordSize + yOffset, yType, y );
242 y = indexOffset.
y() + indexScale.
y() * y;
244 _attribute( ptr, i * pointRecordSize + zOffset, zType, z );
245 z = indexOffset.
z() + indexScale.
z() * z;
251 const QVector<QgsPointCloudAttribute> attributes = attributeCollection.
attributes();
254 const QString attributeName = attr.name();
256 attributeCollection.
find( attributeName, attributeOffset );
257 switch ( attr.type() )
262 const char value = *( data + recordOffset + attributeOffset );
263 map[ attributeName ] = value;
269 const quint32 value = *
reinterpret_cast< const quint32 *
>( data + recordOffset + attributeOffset );
270 map[ attributeName ] = value;
275 const qint32 value = *
reinterpret_cast< const qint32 *
>( data + recordOffset + attributeOffset );
276 map[ attributeName ] = value;
282 const quint64 value = *
reinterpret_cast< const quint64 *
>( data + recordOffset + attributeOffset );
283 map[ attributeName ] = value;
288 const qint64 value = *
reinterpret_cast< const qint64 *
>( data + recordOffset + attributeOffset );
289 map[ attributeName ] = value;
295 const short value = *
reinterpret_cast< const short *
>( data + recordOffset + attributeOffset );
296 map[ attributeName ] = value;
302 const unsigned short value = *
reinterpret_cast< const unsigned short *
>( data + recordOffset + attributeOffset );
303 map[ attributeName ] = value;
309 const float value = *
reinterpret_cast< const float *
>( data + recordOffset + attributeOffset );
310 map[ attributeName ] = value;
316 const double value = *
reinterpret_cast< const double *
>( data + recordOffset + attributeOffset );
317 map[ attributeName ] = value;
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
bool append(const QgsField &field, FieldOrigin origin=OriginProvider, int originIndex=-1)
Appends a field. The field must have unique name, otherwise it is rejected (returns false)
Collection of point cloud attributes.
void push_back(const QgsPointCloudAttribute &attribute)
Adds extra attribute.
QgsPointCloudAttributeCollection()
Ctor.
const QgsPointCloudAttribute * find(const QString &attributeName, int &offset) const
Finds the attribute with the name.
QgsFields toFields() const
Converts the attribute collection to an equivalent QgsFields collection.
QVector< QgsPointCloudAttribute > attributes() const
Returns all attributes.
int indexOf(const QString &name) const
Returns the index of the attribute with the specified name.
Attribute for point cloud data pair of name and size in bytes.
DataType
Systems of unit measurement.
@ UShort
Unsigned short int 2 bytes.
@ Short
Short int 2 bytes.
@ UChar
Unsigned char 1 byte.
@ UInt32
Unsigned int32 4 bytes.
@ UInt64
Unsigned int64 8 bytes.
QVariant::Type variantType() const
Returns the most suitable equivalent QVariant data type to this attribute type.
static void getPointXYZ(const char *ptr, int i, std::size_t pointRecordSize, int xOffset, QgsPointCloudAttribute::DataType xType, int yOffset, QgsPointCloudAttribute::DataType yType, int zOffset, QgsPointCloudAttribute::DataType zType, const QgsVector3D &indexScale, const QgsVector3D &indexOffset, double &x, double &y, double &z)
Retrieves the x, y, z values for the point at index i.
static bool isNumeric(DataType type)
Returns true if the specified data type is numeric.
static QVariantMap getAttributeMap(const char *data, std::size_t recordOffset, const QgsPointCloudAttributeCollection &attributeCollection)
Retrieves all the attributes of a point.
QgsPointCloudAttribute()
Ctor.
QString displayType() const
Returns the type to use when displaying this field.
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.
double y() const
Returns Y coordinate.
double z() const
Returns Z coordinate.
double x() const
Returns X coordinate.
void _attribute(const char *data, std::size_t offset, QgsPointCloudAttribute::DataType type, T &value)