Skip to content
Permalink
Browse files

wmts: use QObject property to make tile resolutions available to tile…

…scalewidget
  • Loading branch information
jef-n committed May 22, 2012
1 parent dfb8fcb commit e7af002b538234fff2cb467f047245c470dcd802
Showing with 20 additions and 26 deletions.
  1. +11 −16 src/providers/wms/qgstilescalewidget.cpp
  2. +9 −0 src/providers/wms/qgswmsprovider.cpp
  3. +0 −10 src/providers/wms/qgswmsprovider.h
@@ -18,7 +18,6 @@
#include "qgstilescalewidget.h"
#include "qgsmapcanvas.h"
#include "qgsrasterlayer.h"
#include "qgswmsprovider.h"
#include "qgsmessagelog.h"
#include "qgslogger.h"

@@ -46,28 +45,24 @@ QgsTileScaleWidget::~QgsTileScaleWidget()

void QgsTileScaleWidget::layerChanged( QgsMapLayer *layer )
{
QgsRasterLayer *rl = qobject_cast<QgsRasterLayer *>( layer );
if ( !rl )
return;
mSlider->setDisabled( true );

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

QgsWmtsTileMatrixSet *tileMatrixSet = wms->tileMatrixSet();
if ( !tileMatrixSet )
return;
QVariant res = rl->dataProvider()->property( "resolutions" );

mSlider->setDisabled( true );

mResolutions = tileMatrixSet->tileMatrices.keys();
qSort( mResolutions );

for ( int i = 0; i < mResolutions.size(); i++ )
mResolutions.clear();
foreach( QVariant r, res.toList() )
{
QgsDebugMsg( QString( "found resolution %1: %2" ).arg( i ).arg( mResolutions[i] ) );
QgsDebugMsg( QString( "found resolution: %1" ).arg( r.toDouble() ) );
mResolutions << r.toDouble();
}

if ( mResolutions.size() == 0 )
return;

mSlider->setRange( 0, mResolutions.size() - 1 );
mSlider->setTickInterval( 1 );
mSlider->setInvertedAppearance( true );
@@ -410,15 +410,24 @@ void QgsWmsProvider::addLayers( QStringList const &layers,
}
}

QList<QVariant> resolutions;
if ( mTileMatrixSets.contains( mTileMatrixSetId ) )
{
mTileMatrixSet = &mTileMatrixSets[ mTileMatrixSetId ];
QList<double> keys = mTileMatrixSet->tileMatrices.keys();
qSort( keys );
foreach( double key, keys )
{
resolutions << key;
}
}
else
{
mTileMatrixSet = 0;
}

setProperty( "resolutions", resolutions );

mValid = mTileLayer != 0 && mTileMatrixSet != 0;
}

@@ -742,16 +742,6 @@ class QgsWmsProvider : public QgsRasterDataProvider

static QVector<QgsWmsSupportedFormat> supportedFormats();

/**
returns the current tile layer (if any)
*/
QgsWmtsTileLayer *tileLayer() { return mTileLayer; }

/**
returns the current tile matrix set (if any)
*/
QgsWmtsTileMatrixSet *tileMatrixSet() { return mTileMatrixSet; }

signals:

/** \brief emit a signal to notify of a progress event */

0 comments on commit e7af002

Please sign in to comment.
You can’t perform that action at this time.