Skip to content
Permalink
Browse files
Fix some ArcGis VectorTileServer urls cannot be directly loaded
Some services don't default to returning JSON for the capabilities,
so explicitly request it

Fixes #42314

(cherry picked from commit 87c7c46)
  • Loading branch information
nyalldawson committed Apr 17, 2021
1 parent 0c8aebe commit e8b7c9e21b3b4308a839f987a4d31d15ecbb6d36
Showing with 12 additions and 2 deletions.
  1. +12 −2 src/core/vectortile/qgsvectortilelayer.cpp
@@ -31,6 +31,9 @@
#include "qgsmapboxglstyleconverter.h"
#include "qgsjsonutils.h"

#include <QUrl>
#include <QUrlQuery>

QgsVectorTileLayer::QgsVectorTileLayer( const QString &uri, const QString &baseName )
: QgsMapLayer( QgsMapLayerType::VectorTileLayer, baseName )
{
@@ -119,9 +122,16 @@ bool QgsVectorTileLayer::loadDataSource()

bool QgsVectorTileLayer::setupArcgisVectorTileServiceConnection( const QString &uri, const QgsDataSourceUri &dataSourceUri )
{
QNetworkRequest request = QNetworkRequest( QUrl( uri ) );
QUrl url( uri );
// some services don't default to json format, while others do... so let's explicitly request it!
// (refs https://github.com/qgis/QGIS/issues/4231)
QUrlQuery query;
query.addQueryItem( QStringLiteral( "f" ), QStringLiteral( "pjson" ) );
url.setQuery( query );

QNetworkRequest request = QNetworkRequest( url );

QgsSetRequestInitiatorClass( request, QStringLiteral( "QgsVectorTileLayer" ) );
QgsSetRequestInitiatorClass( request, QStringLiteral( "QgsVectorTileLayer" ) )

QgsBlockingNetworkRequest networkRequest;
switch ( networkRequest.get( request ) )

0 comments on commit e8b7c9e

Please sign in to comment.