36 case DataType::UShort:
41 case DataType::Double:
42 return QVariant::Double;
44 return QVariant::Invalid;
52 return QObject::tr(
"Character" );
54 return QObject::tr(
"Short" );
55 case DataType::UShort:
56 return QObject::tr(
"Unsigned Short" );
58 return QObject::tr(
"Float" );
60 return QObject::tr(
"Integer" );
61 case DataType::Double:
62 return QObject::tr(
"Double" );
74 case DataType::UShort:
77 case DataType::Double:
83 void QgsPointCloudAttribute::updateSize()
91 case DataType::UShort:
100 case DataType::Double:
121 mCachedAttributes.insert( attribute.
name(), CachedAttributeData( mAttributes.size(), mSize ) );
122 mAttributes.push_back( attribute );
123 mSize += attribute.
size();
133 auto it = mCachedAttributes.constFind( attributeName );
134 if ( it != mCachedAttributes.constEnd() )
137 return &mAttributes.at( it->index );
146 auto it = mCachedAttributes.constFind( name );
147 if ( it != mCachedAttributes.constEnd() )
161 fields.
append(
QgsField( attribute.name(), attribute.variantType(), attribute.displayType() ) );
166 template <
typename T>
172 value = *( data + offset );
176 value = *
reinterpret_cast< const qint32 *
>( data + offset );
181 value = *
reinterpret_cast< const short *
>( data + offset );
186 value = *
reinterpret_cast< const unsigned short *
>( data + offset );
190 value =
static_cast< T
>( *
reinterpret_cast< const float *
>( data + offset ) );
194 value = *
reinterpret_cast< const double *
>( data + offset );
204 _attribute( ptr, i * pointRecordSize + xOffset, xType, x );
205 x = indexOffset.
x() + indexScale.
x() * x;
207 _attribute( ptr, i * pointRecordSize + yOffset, yType, y );
208 y = indexOffset.
y() + indexScale.
y() * y;
210 _attribute( ptr, i * pointRecordSize + zOffset, zType, z );
211 z = indexOffset.
z() + indexScale.
z() * z;
217 const QVector<QgsPointCloudAttribute> attributes = attributeCollection.
attributes();
220 QString attributeName = attr.name();
222 attributeCollection.
find( attributeName, attributeOffset );
223 switch ( attr.type() )
227 const char value = *( data + recordOffset + attributeOffset );
228 map[ attributeName ] = value;
234 const qint32 value = *
reinterpret_cast< const qint32 *
>( data + recordOffset + attributeOffset );
235 map[ attributeName ] = value;
241 const short value = *
reinterpret_cast< const short *
>( data + recordOffset + attributeOffset );
242 map[ attributeName ] = value;
248 const unsigned short value = *
reinterpret_cast< const unsigned short *
>( data + recordOffset + attributeOffset );
249 map[ attributeName ] = value;
255 const float value = *
reinterpret_cast< const float *
>( data + recordOffset + attributeOffset );
256 map[ attributeName ] = value;
262 const double value = *
reinterpret_cast< const double *
>( data + recordOffset + attributeOffset );
263 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.
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)