Skip to content

Commit

Permalink
Report native resolution from mapserver layers, allow use with tile s…
Browse files Browse the repository at this point in the history
…cale widget
  • Loading branch information
nyalldawson committed Jun 6, 2019
1 parent 94bc003 commit 55311c2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/providers/arcgisrest/qgsamsprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,19 @@ QgsAmsProvider::QgsAmsProvider( const QString &uri, const ProviderOptions &optio
contact.role = QStringLiteral( "author" );
mLayerMetadata.addContact( contact );
}

if ( mTiled )
{
const QVariantMap tileInfo = mServiceInfo.value( QStringLiteral( "tileInfo" ) ).toMap();
const QList<QVariant> lodEntries = tileInfo[QStringLiteral( "lods" )].toList();
for ( const QVariant &lodEntry : lodEntries )
{
const QVariantMap lodEntryMap = lodEntry.toMap();
mResolutions << lodEntryMap[QStringLiteral( "resolution" )].toDouble();
}
std::sort( mResolutions.begin(), mResolutions.end() );
setProperty( "resolutions", mResolutions );
}
}

QgsAmsProvider::QgsAmsProvider( const QgsAmsProvider &other, const QgsDataProvider::ProviderOptions &providerOptions )
Expand All @@ -251,6 +264,7 @@ QgsAmsProvider::QgsAmsProvider( const QgsAmsProvider &other, const QgsDataProvid
, mRequestHeaders( other.mRequestHeaders )
, mTiled( other.mTiled )
, mLayerMetadata( other.mLayerMetadata )
, mResolutions( other.mResolutions )
// intentionally omitted:
// - mErrorTitle
// - mError
Expand All @@ -261,6 +275,7 @@ QgsAmsProvider::QgsAmsProvider( const QgsAmsProvider &other, const QgsDataProvid

// is this needed?
mTimestamp = QDateTime::currentDateTime();
setProperty( "resolutions", mResolutions );
}

QgsRasterDataProvider::ProviderCapabilities QgsAmsProvider::providerCapabilities() const
Expand Down
1 change: 1 addition & 0 deletions src/providers/arcgisrest/qgsamsprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class QgsAmsProvider : public QgsRasterDataProvider
int mTileReqNo = 0;
bool mTiled = false;
QgsLayerMetadata mLayerMetadata;
QVariantList mResolutions;
};

//! Handler for tiled MapServer requests, the data are written to the given image
Expand Down
6 changes: 4 additions & 2 deletions src/providers/wms/qgstilescalewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ void QgsTileScaleWidget::layerChanged( QgsMapLayer *layer )
mSlider->setDisabled( true );

QgsRasterLayer *rl = qobject_cast<QgsRasterLayer *>( layer );
if ( !rl || rl->providerType() != QLatin1String( "wms" ) || !rl->dataProvider() )
if ( !rl || !rl->dataProvider() )
return;

QVariant res = rl->dataProvider()->property( "resolutions" );
const QVariant res = rl->dataProvider()->property( "resolutions" );
if ( res.toList().isEmpty() )
return;

mResolutions.clear();
const auto constToList = res.toList();
Expand Down

0 comments on commit 55311c2

Please sign in to comment.