Skip to content
Permalink
Browse files

When reading laz files, gracefully handle requested attributes which …

…are not available
  • Loading branch information
nyalldawson authored and wonder-sk committed Jan 4, 2021
1 parent 1f0b931 commit 28dc2a7625bae76d395940afcac7f5aebaa1ff86
Showing with 8 additions and 2 deletions.
  1. +8 −2 src/core/pointcloud/qgseptdecoder.cpp
@@ -301,7 +301,8 @@ QgsPointCloudBlock *QgsEptDecoder::decompressLaz( const QString &filename,
PointSourceId,
Red,
Green,
Blue
Blue,
MissingOrUnknown
};

struct RequestedAttributeDetails
@@ -383,7 +384,8 @@ QgsPointCloudBlock *QgsEptDecoder::decompressLaz( const QString &filename,
}
else
{
// what to do here? store 0?
// this can possibly happen -- e.g. if a style built using a different point cloud format references an attribute which isn't available from the laz file
requestedAttributeDetails.emplace_back( RequestedAttributeDetails( LazAttribute::MissingOrUnknown, QgsPointCloudAttribute::Char, 1 ) );
}
}

@@ -442,6 +444,10 @@ QgsPointCloudBlock *QgsEptDecoder::decompressLaz( const QString &filename,
case LazAttribute::Blue:
_storeToStream<unsigned short>( dataBuffer, outputOffset, requestedAttribute.type, rgb.b );
break;
case LazAttribute::MissingOrUnknown:
// just store 0 for unknown/missing attributes
dataBuffer[ outputOffset ] = 0;
break;
}

outputOffset += requestedAttribute.size;

0 comments on commit 28dc2a7

Please sign in to comment.
You can’t perform that action at this time.