Skip to content

Commit

Permalink
[wms] Allow type=wmts param in layer uri to request wmts handling
Browse files Browse the repository at this point in the history
If no explicit tileMatrixSet is requested, and no other wmts
specific params are specified (eg tileDimensions), then allow
use of a "type=wmts" param to explicitly indicate that the layer's
URI should be treated as a wmts source.
  • Loading branch information
nyalldawson committed Jul 23, 2024
1 parent 3120d62 commit b47243e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/providers/wms/qgswmscapabilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ bool QgsWmsSettings::parseUri( const QString &uriString )
mInterpretation = uri.param( QStringLiteral( "interpretation" ) );
}

mTiled = false;
if ( uri.param( QStringLiteral( "type" ) ) == QLatin1String( "xyz" ) ||
uri.param( QStringLiteral( "type" ) ) == QLatin1String( "mbtiles" ) )
{
Expand Down Expand Up @@ -100,8 +101,7 @@ bool QgsWmsSettings::parseUri( const QString &uriString )

return true;
}

if ( uri.param( QStringLiteral( "type" ) ) == QLatin1String( "wmst" ) )
else if ( uri.param( QStringLiteral( "type" ) ) == QLatin1String( "wmst" ) )
{
mIsTemporal = true;
mTemporalExtent = uri.param( QStringLiteral( "timeDimensionExtent" ) );
Expand Down Expand Up @@ -172,8 +172,11 @@ bool QgsWmsSettings::parseUri( const QString &uriString )
mIsBiTemporal = true;
}
}
else if ( uri.param( QStringLiteral( "type" ) ) == QLatin1String( "wmts" ) )
{
mTiled = true;
}

mTiled = false;
mTileDimensionValues.clear();

mHttpUri = uri.param( QStringLiteral( "url" ) );
Expand Down
11 changes: 11 additions & 0 deletions tests/src/providers/testqgswmsprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,20 +157,31 @@ class TestQgsWmsProvider: public QgsTest
// explicitly state crs and format
{
QgsWmsProvider provider( "contextualWMSLegend=0&crs=EPSG:4326&dpiMode=7&featureCount=10&format=image/jpg&layers=CountryGroup&styles=default&tileMatrixSet=standard&tilePixelRatio=0&url=http://localhost:8380/mapserv?xxx", QgsDataProvider::ProviderOptions(), &cap );
QVERIFY( provider.mSettings.mTiled );
QCOMPARE( provider.mSettings.mTileMatrixSetId, QStringLiteral( "standard" ) );
QCOMPARE( provider.crs().authid(), QStringLiteral( "EPSG:4326" ) );
QCOMPARE( provider.mSettings.mImageMimeType, QStringLiteral( "image/jpg" ) );
}
// no crs or format specified, should use tile matrix crs
{
QgsWmsProvider provider( "contextualWMSLegend=0&dpiMode=7&featureCount=10&layers=CountryGroup&styles=default&tileMatrixSet=standard&tilePixelRatio=0&url=http://localhost:8380/mapserv?xxx", QgsDataProvider::ProviderOptions(), &cap );
QVERIFY( provider.mSettings.mTiled );
QCOMPARE( provider.mSettings.mTileMatrixSetId, QStringLiteral( "standard" ) );
QCOMPARE( provider.crs().authid(), QStringLiteral( "EPSG:3857" ) );
QCOMPARE( provider.mSettings.mImageMimeType, QStringLiteral( "image/png" ) );
}
// no tileMatrixSet specified, should use first listed
{
QgsWmsProvider provider( "layers=CountryGroup&styles=default&tileDimensions=&url=http://localhost:8380/mapserv?xxx", QgsDataProvider::ProviderOptions(), &cap );
QVERIFY( provider.mSettings.mTiled );
QCOMPARE( provider.mSettings.mTileMatrixSetId, QStringLiteral( "standard" ) );
QCOMPARE( provider.crs().authid(), QStringLiteral( "EPSG:3857" ) );
QCOMPARE( provider.mSettings.mImageMimeType, QStringLiteral( "image/png" ) );
}
// no tileMatrixSet specified, using type=wmts to request wmts
{
QgsWmsProvider provider( "layers=CountryGroup&styles=default&type=wmts&url=http://localhost:8380/mapserv?xxx", QgsDataProvider::ProviderOptions(), &cap );
QVERIFY( provider.mSettings.mTiled );
QCOMPARE( provider.mSettings.mTileMatrixSetId, QStringLiteral( "standard" ) );
QCOMPARE( provider.crs().authid(), QStringLiteral( "EPSG:3857" ) );
QCOMPARE( provider.mSettings.mImageMimeType, QStringLiteral( "image/png" ) );
Expand Down

0 comments on commit b47243e

Please sign in to comment.