Skip to content
Permalink
Browse files

Use nice new API to handle loading of point cloud layers which are

dragged and dropped onto QGIS, with absolutely no hardcoded logic
in qgisapp at all - win!

(Now las/laz files can be dropped onto QGIS to open them, if the pdal
provider is available)
  • Loading branch information
nyalldawson committed Nov 6, 2020
1 parent bf32b71 commit 1220c1069b613414dbafe0375fa87ebcc23a5618
Showing with 27 additions and 8 deletions.
  1. +27 −8 src/app/qgisapp.cpp
@@ -7559,8 +7559,33 @@ void QgisApp::openProject( const QString &fileName )

bool QgisApp::openLayer( const QString &fileName, bool allowInteractive )
{
QFileInfo fileInfo( fileName );
bool ok( false );
bool ok = false;
const QFileInfo fileInfo( fileName );

// highest priority = delegate to provider registry to handle
const QList< QgsProviderRegistry::ProviderCandidateDetails > candidateProviders = QgsProviderRegistry::instance()->preferredProvidersForUri( fileName );
if ( candidateProviders.size() == 1 && candidateProviders.at( 0 ).layerTypes().size() == 1 )
{
// one good candidate provider and possible layer type -- that makes things nice and easy!
switch ( candidateProviders.at( 0 ).layerTypes().at( 0 ) )
{
case QgsMapLayerType::VectorLayer:
case QgsMapLayerType::RasterLayer:
case QgsMapLayerType::MeshLayer:
case QgsMapLayerType::AnnotationLayer:
case QgsMapLayerType::PluginLayer:
case QgsMapLayerType::VectorTileLayer:
// not supported here yet!
break;

case QgsMapLayerType::PointCloudLayer:
ok = static_cast< bool >( addPointCloudLayerPrivate( fileName, fileInfo.completeBaseName(), candidateProviders.at( 0 ).metadata()->key(), false ) );
break;
}
}

if ( ok )
return true;

CPLPushErrorHandler( CPLQuietErrorHandler );

@@ -7640,12 +7665,6 @@ bool QgisApp::openLayer( const QString &fileName, bool allowInteractive )
ok = static_cast< bool >( addMeshLayerPrivate( fileName, fileInfo.completeBaseName(), QStringLiteral( "mdal" ), false ) );
}

// Try to load as point cloud layer after raster & vector & mesh
if ( !ok )
{
ok = static_cast< bool >( addPointCloudLayerPrivate( fileName, fileInfo.completeBaseName(), QStringLiteral( "ept" ), false ) );
}

if ( !ok )
{
// we have no idea what this file is...

0 comments on commit 1220c10

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