Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix loading of file-based mbtiles vector MVT package via Data Source Manager (fix #36449) #47028

Merged
merged 2 commits into from
Jan 30, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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