Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Skip indexing empty point clouds instead of returning error
  • Loading branch information
uclaros authored and wonder-sk committed May 13, 2023
1 parent 24b4ffd commit 3fcf0fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/core/pointcloud/qgspointcloudlayer.cpp
Expand Up @@ -435,12 +435,19 @@ void QgsPointCloudLayer::setDataSourcePrivate( const QString &dataSource, const
loadDefaultStyleFlag = true;
}

if ( !mLayerOptions.skipIndexGeneration && mDataProvider && mDataProvider->indexingState() != QgsPointCloudDataProvider::PointCloudIndexGenerationState::Indexed )
if ( !mLayerOptions.skipIndexGeneration &&
mDataProvider &&
mDataProvider->indexingState() != QgsPointCloudDataProvider::PointCloudIndexGenerationState::Indexed &&
mDataProvider->pointCount() > 0 )
{
mDataProvider->generateIndex();
}

if ( !mLayerOptions.skipStatisticsCalculation && mDataProvider && !mDataProvider->hasStatisticsMetadata() && mDataProvider->indexingState() == QgsPointCloudDataProvider::PointCloudIndexGenerationState::Indexed )
if ( !mLayerOptions.skipStatisticsCalculation &&
mDataProvider &&
!mDataProvider->hasStatisticsMetadata() &&
mDataProvider->indexingState() == QgsPointCloudDataProvider::PointCloudIndexGenerationState::Indexed &&
mDataProvider->pointCount() > 0 )
{
calculateStatistics();
}
Expand Down
2 changes: 0 additions & 2 deletions src/providers/pdal/qgspdalprovider.cpp
Expand Up @@ -312,8 +312,6 @@ bool QgsPdalProvider::load( const QString &uri )
mExtent = QgsRectangle( xmin, ymin, xmax, ymax );

mPointCount = quickInfo.m_pointCount;
if ( mPointCount == 0 )
throw pdal::pdal_error( "File contains no points" );

// projection
const QString wkt = QString::fromStdString( quickInfo.m_srs.getWKT() );
Expand Down

0 comments on commit 3fcf0fc

Please sign in to comment.