Skip to content

Commit

Permalink
fix loading of file-based mbtiles vector MVT package via Data Source
Browse files Browse the repository at this point in the history
Manager (fix #36449)
  • Loading branch information
alexbruy authored and github-actions[bot] committed Jan 30, 2022
1 parent 600ab80 commit 7f51841
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/core/vectortile/qgsvectortileconnection.cpp
Expand Up @@ -19,12 +19,25 @@
#include "qgsdatasourceuri.h"
#include "qgssettings.h"

#include <QFileInfo>

///@cond PRIVATE

QString QgsVectorTileProviderConnection::encodedUri( const QgsVectorTileProviderConnection::Data &conn )
{
QgsDataSourceUri uri;
uri.setParam( QStringLiteral( "type" ), QStringLiteral( "xyz" ) );

const QFileInfo info( conn.url );
QString suffix = info.suffix().toLower();
if ( suffix.startsWith( QStringLiteral( "mbtiles" ) ) )
{
uri.setParam( QStringLiteral( "type" ), QStringLiteral( "mbtiles" ) );
}
else
{
uri.setParam( QStringLiteral( "type" ), QStringLiteral( "xyz" ) );
}

uri.setParam( QStringLiteral( "url" ), conn.url );
if ( conn.zMin != -1 )
uri.setParam( QStringLiteral( "zmin" ), QString::number( conn.zMin ) );
Expand Down Expand Up @@ -81,7 +94,18 @@ QString QgsVectorTileProviderConnection::encodedLayerUri( const QgsVectorTilePro
{
// compared to encodedUri() this one also adds type=xyz to the URI
QgsDataSourceUri uri;
uri.setParam( QStringLiteral( "type" ), QStringLiteral( "xyz" ) );

const QFileInfo info( conn.url );
QString suffix = info.suffix().toLower();
if ( suffix.startsWith( QStringLiteral( "mbtiles" ) ) )
{
uri.setParam( QStringLiteral( "type" ), QStringLiteral( "mbtiles" ) );
}
else
{
uri.setParam( QStringLiteral( "type" ), QStringLiteral( "xyz" ) );
}

uri.setParam( QStringLiteral( "url" ), conn.url );
if ( conn.zMin != -1 )
uri.setParam( QStringLiteral( "zmin" ), QString::number( conn.zMin ) );
Expand Down

0 comments on commit 7f51841

Please sign in to comment.