Skip to content

Commit

Permalink
Remove no longer required special handling for mbtile files
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Apr 4, 2023
1 parent 3c98201 commit 54e8097
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 70 deletions.
39 changes: 0 additions & 39 deletions src/app/layers/qgsapplayerhandling.cpp
Expand Up @@ -845,45 +845,6 @@ QList< QgsMapLayer * > QgsAppLayerHandling::openLayer( const QString &fileName,
}
}

if ( fileName.endsWith( QStringLiteral( ".mbtiles" ), Qt::CaseInsensitive ) )
{
QgsMbTiles reader( fileName );
if ( reader.open() )
{
if ( reader.metadataValue( "format" ) == QLatin1String( "pbf" ) )
{
// these are vector tiles
QUrlQuery uq;
uq.addQueryItem( QStringLiteral( "type" ), QStringLiteral( "mbtiles" ) );
uq.addQueryItem( QStringLiteral( "url" ), fileName );
const QgsVectorTileLayer::LayerOptions options( QgsProject::instance()->transformContext() );
std::unique_ptr<QgsVectorTileLayer> vtLayer( new QgsVectorTileLayer( uq.toString(), fileInfo.completeBaseName(), options ) );
if ( vtLayer->isValid() )
{
openedLayers << vtLayer.get();
QgsProject::instance()->addMapLayer( vtLayer.release(), addToLegend );
postProcessAddedLayers();
ok = true;
return openedLayers;
}
}
else // raster tiles
{
// prefer to use WMS provider's implementation to open MBTiles rasters
QUrlQuery uq;
uq.addQueryItem( QStringLiteral( "type" ), QStringLiteral( "mbtiles" ) );
uq.addQueryItem( QStringLiteral( "url" ), QUrl::fromLocalFile( fileName ).toString() );
if ( QgsRasterLayer *rasterLayer = addRasterLayer( uq.toString(), fileInfo.completeBaseName(), QStringLiteral( "wms" ), addToLegend ) )
{
openedLayers << rasterLayer;
postProcessAddedLayers();
ok = true;
return openedLayers;
}
}
}
}

QList< QgsProviderSublayerModel::NonLayerItem > nonLayerItems;
if ( QgsProjectStorage *ps = QgsApplication::projectStorageRegistry()->projectStorageFromUri( fileName ) )
{
Expand Down
31 changes: 0 additions & 31 deletions src/core/browser/qgsfilebaseddataitemprovider.cpp
Expand Up @@ -464,37 +464,6 @@ QgsDataItem *QgsFileBasedDataItemProvider::createDataItem( const QString &path,
{
suffix = QStringLiteral( "shp.zip" );
}
// special handling for mbtiles files
else if ( suffix == QLatin1String( "mbtiles" ) )
{
QgsMbTiles reader( path );
if ( reader.open() )
{
if ( reader.metadataValue( QStringLiteral( "format" ) ) == QLatin1String( "pbf" ) )
{
// these are vector tiles
QUrlQuery uq;
uq.addQueryItem( QStringLiteral( "type" ), QStringLiteral( "mbtiles" ) );
uq.addQueryItem( QStringLiteral( "url" ), path );
const QString encodedUri = uq.toString();
QgsVectorTileLayerItem *item = new QgsVectorTileLayerItem( parentItem, name, path, encodedUri );
item->setCapabilities( item->capabilities2() | Qgis::BrowserItemCapability::ItemRepresentsFile );
return item;
}
else
{
// handled by WMS provider
QUrlQuery uq;
uq.addQueryItem( QStringLiteral( "type" ), QStringLiteral( "mbtiles" ) );
uq.addQueryItem( QStringLiteral( "url" ), QUrl::fromLocalFile( path ).toString() );
const QString encodedUri = uq.toString();
QgsLayerItem *item = new QgsLayerItem( parentItem, name, path, encodedUri, Qgis::BrowserLayerType::Raster, QStringLiteral( "wms" ) );
item->setState( Qgis::BrowserItemState::Populated );
item->setCapabilities( item->capabilities2() | Qgis::BrowserItemCapability::ItemRepresentsFile );
return item;
}
}
}

// hide blocklisted URIs, such as .aux.xml files
if ( QgsProviderRegistry::instance()->uriIsBlocklisted( path ) )
Expand Down

0 comments on commit 54e8097

Please sign in to comment.