44 return QVariant::LongLong;
47 return QVariant::Double;
49 return QVariant::Invalid;
57 return QObject::tr(
"Unsigned Character" );
59 return QObject::tr(
"Character" );
61 return QObject::tr(
"Short" );
63 return QObject::tr(
"Unsigned Short" );
65 return QObject::tr(
"Float" );
67 return QObject::tr(
"Integer" );
69 return QObject::tr(
"Unsigned Integer" );
71 return QObject::tr(
"Long Integer" );
73 return QObject::tr(
"Unsigned Long Integer" );
75 return QObject::tr(
"Double" );
100void QgsPointCloudAttribute::updateSize()
144 mCachedAttributes.insert( attribute.
name().toUpper(), CachedAttributeData( mAttributes.size(), mSize ) );
145 mAttributes.push_back( attribute );
146 mSize += attribute.
size();
151 for (
const auto &attributeName : matchingNames )
153 if (
indexOf( attributeName ) == -1 )
156 const auto attr = otherCollection.
find( attributeName, offset );
170 const auto it = mCachedAttributes.constFind( attributeName.toUpper() );
171 if ( it != mCachedAttributes.constEnd() )
174 return &mAttributes.at( it->index );
183 const auto it = mCachedAttributes.constFind( name.toUpper() );
184 if ( it != mCachedAttributes.constEnd() )
198 fields.
append(
QgsField( attribute.name(), attribute.variantType(), attribute.displayType() ) );
209 value = *
reinterpret_cast< const unsigned char *
>( data + offset );
213 value = *( data + offset );
217 value = *
reinterpret_cast< const quint32 *
>( data + offset );
221 value = *
reinterpret_cast< const qint32 *
>( data + offset );
225 value = *
reinterpret_cast< const quint64 *
>( data + offset );
229 value = *
reinterpret_cast< const qint64 *
>( data + offset );
233 value = *
reinterpret_cast< const short *
>( data + offset );
237 value = *
reinterpret_cast< const unsigned short *
>( data + offset );
241 value =
static_cast< T
>( *
reinterpret_cast< const float *
>( data + offset ) );
245 value = *
reinterpret_cast< const double *
>( data + offset );
263 _attribute( ptr, i * pointRecordSize + xOffset, xType, x );
264 x = indexOffset.
x() + indexScale.
x() * x;
266 _attribute( ptr, i * pointRecordSize + yOffset, yType, y );
267 y = indexOffset.
y() + indexScale.
y() * y;
269 _attribute( ptr, i * pointRecordSize + zOffset, zType, z );
270 z = indexOffset.
z() + indexScale.
z() * z;
276 const QVector<QgsPointCloudAttribute> attributes = attributeCollection.
attributes();
279 const QString attributeName = attr.name();
281 attributeCollection.
find( attributeName, attributeOffset );
282 switch ( attr.type() )
286 const unsigned char value = *
reinterpret_cast< const unsigned char *
>( data + recordOffset + attributeOffset );
287 map[ attributeName ] = value;
293 const char value = *( data + recordOffset + attributeOffset );
294 map[ attributeName ] = value;
300 const quint32 value = *
reinterpret_cast< const quint32 *
>( data + recordOffset + attributeOffset );
301 map[ attributeName ] = value;
306 const qint32 value = *
reinterpret_cast< const qint32 *
>( data + recordOffset + attributeOffset );
307 map[ attributeName ] = value;
313 const quint64 value = *
reinterpret_cast< const quint64 *
>( data + recordOffset + attributeOffset );
314 map[ attributeName ] = value;
319 const qint64 value = *
reinterpret_cast< const qint64 *
>( data + recordOffset + attributeOffset );
320 map[ attributeName ] = value;
326 const short value = *
reinterpret_cast< const short *
>( data + recordOffset + attributeOffset );
327 map[ attributeName ] = value;
333 const unsigned short value = *
reinterpret_cast< const unsigned short *
>( data + recordOffset + attributeOffset );
334 map[ attributeName ] = value;
340 const float value = *
reinterpret_cast< const float *
>( data + recordOffset + attributeOffset );
341 map[ attributeName ] = value;
347 const double value = *
reinterpret_cast< const double *
>( data + recordOffset + attributeOffset );
348 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.
void extend(const QgsPointCloudAttributeCollection &otherCollection, const QSet< QString > &matchingNames)
Adds specific missing attributes from another QgsPointCloudAttributeCollection.
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 convertValueToDouble(const char *ptr) const
Returns the attribute's value as a double for data pointed to by ptr.
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
double y() const
Returns Y coordinate.
double z() const
Returns Z coordinate.
double x() const
Returns X coordinate.
#define BUILTIN_UNREACHABLE
void _attribute(const char *data, std::size_t offset, QgsPointCloudAttribute::DataType type, T &value)