Skip to content
Permalink
Browse files
don't load bad layers, report their error
  • Loading branch information
uclaros authored and nyalldawson committed Oct 4, 2022
1 parent c55a71e commit ffbd8a8be938d71a342332584bc23a96c40a2a33
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
@@ -749,11 +749,16 @@ QList< QgsMapLayer * > QgsAppLayerHandling::openLayer( const QString &fileName,

case QgsMapLayerType::PointCloudLayer:
{
if ( QgsPointCloudLayer *layer = addPointCloudLayer( fileName, fileInfo.completeBaseName(), candidateProviders.at( 0 ).metadata()->key(), false ) )
if ( QgsPointCloudLayer *layer = addPointCloudLayer( fileName, fileInfo.completeBaseName(), candidateProviders.at( 0 ).metadata()->key(), true ) )
{
ok = true;
openedLayers << layer;
}
else
{
// The layer could not be loaded and the reason has been reported by the provider, we can exit now
return {};
}
break;
}
}
@@ -22,6 +22,7 @@
#include "qgslogger.h"
#include "qgsmessagelog.h"
#include "qgsjsonutils.h"
#include "json.hpp"
#include "qgspdalindexingtask.h"
#include "qgseptpointcloudindex.h"
#include "qgstaskmanager.h"
@@ -268,6 +269,8 @@ 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() );
@@ -279,12 +282,21 @@ bool QgsPdalProvider::load( const QString &uri )
throw pdal::pdal_error( "No reader for " + driver );
}
}
catch ( json::exception &error )
{
const QString errorString = QStringLiteral( "Error parsing table metadata: %1" ).arg( error.what() );
QgsDebugMsg( errorString );
appendError( errorString );
return false;
}
catch ( pdal::pdal_error &error )
{
QgsDebugMsg( QStringLiteral( "Error loading PDAL data source %1" ).arg( error.what() ) );
QgsMessageLog::logMessage( tr( "Data source is invalid (%1)" ).arg( error.what() ), QStringLiteral( "PDAL" ) );
const QString errorString = QString::fromStdString( error.what() );
QgsDebugMsg( errorString );
appendError( errorString );
return false;
}

}

QString QgsPdalProviderMetadata::sFilterString;

0 comments on commit ffbd8a8

Please sign in to comment.