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 committed Jan 27, 2022
1 parent 80f2443 commit f5f4349
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/core/vectortile/qgsvectortileconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,25 @@
#include "qgssettings.h"
#include "qgshttpheaders.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 @@ -82,7 +95,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 f5f4349

Please sign in to comment.