Skip to content
Permalink
Browse files

[FEATURE] Add WMTS support

  • Loading branch information
jef-n committed Jun 13, 2012
2 parents 5ebdbe3 + f276fde commit 904cef013114c93691d1ab9ed2079b2c3dcf35d1
@@ -34,10 +34,10 @@ fi
# save original changes
if [ -d .svn ]; then
REV=r$(svn info | sed -ne "s/Revision: //p")
svn diff >$REV.diff
svn diff >rev-$REV.diff
elif [ -d .git ]; then
REV=$(git log -n1 --pretty=%H)
git diff >$REV.diff
git diff >sha-$REV.diff
fi

ASTYLEDIFF=astyle.$REV.diff
@@ -95,7 +95,6 @@ SET(QGIS_APP_SRCS
qgssinglesymboldialog.cpp
qgssnappingdialog.cpp
qgsundowidget.cpp
qgstilescalewidget.cpp
qgstipgui.cpp
qgstipfactory.cpp
qgsuniquevaluedialog.cpp
@@ -232,7 +231,6 @@ SET (QGIS_APP_MOC_HDRS
qgssnappingdialog.h
qgssponsors.h
qgstextannotationdialog.h
qgstilescalewidget.h
qgstipgui.h
qgstipfactory.h
qgsundowidget.h
@@ -165,7 +165,6 @@
#include "qgssnappingdialog.h"
#include "qgssponsors.h"
#include "qgstextannotationitem.h"
#include "qgstilescalewidget.h"
#include "qgstipgui.h"
#include "qgsundowidget.h"
#include "qgsvectordataprovider.h"
@@ -407,7 +406,6 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
, mSplash( splash )
, mShowProjectionTab( false )
, mPythonUtils( NULL )
, mpTileScaleWidget( NULL )
#ifdef Q_OS_WIN
, mSkipNextContextMenuEvent( 0 )
#endif
@@ -655,6 +653,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
// request notification of FileOpen events (double clicking a file icon in Mac OS X Finder)
QgsApplication::setFileOpenEventReceiver( this );

QgsProviderRegistry::instance()->registerGuis( this );

// update windows
qApp->processEvents();

@@ -792,12 +792,6 @@ void QgisApp::readSettings()

// Add the recently accessed project file paths to the File menu
mRecentProjectPaths = settings.value( "/UI/recentProjectsList" ).toStringList();

// Restore state of tile scale widget
if ( settings.value( "/UI/tileScaleEnabled", false ).toBool() )
{
showTileScale();
}
}


@@ -903,7 +897,6 @@ void QgisApp::createActions()
connect( mActionRemoveLayer, SIGNAL( triggered() ), this, SLOT( removeLayer() ) );
connect( mActionSetLayerCRS, SIGNAL( triggered() ), this, SLOT( setLayerCRS() ) );
connect( mActionSetProjectCRSFromLayer, SIGNAL( triggered() ), this, SLOT( setProjectCRSFromLayer() ) );
connect( mActionTileScale, SIGNAL( triggered() ), this, SLOT( showTileScale() ) );
connect( mActionLayerProperties, SIGNAL( triggered() ), this, SLOT( layerProperties() ) );
connect( mActionLayerSubsetString, SIGNAL( triggered() ), this, SLOT( layerSubsetString() ) );
connect( mActionAddToOverview, SIGNAL( triggered() ), this, SLOT( isInOverview() ) );
@@ -2085,17 +2078,6 @@ void QgisApp::saveWindowState()
// store window geometry
settings.setValue( "/UI/geometry", saveGeometry() );

// Persist state of tile scale slider
if ( mpTileScaleWidget )
{
settings.setValue( "/UI/tileScaleEnabled", true );
delete mpTileScaleWidget;
}
else
{
settings.setValue( "/UI/tileScaleEnabled", false );
}

QgsPluginRegistry::instance()->unloadAll();
}

@@ -4867,32 +4849,6 @@ void QgisApp::setProjectCRSFromLayer()
mMapCanvas->refresh();
}

void QgisApp::showTileScale()
{
if ( !mpTileScaleWidget )
{
mpTileScaleWidget = new QgsTileScaleWidget( mMapCanvas );
//create the dock widget
mpTileScaleDock = new QDockWidget( tr( "Tile scale" ), this );
mpTileScaleDock->setObjectName( "TileScale" );
mpTileScaleDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
addDockWidget( Qt::RightDockWidgetArea, mpTileScaleDock );
// add to the Panel submenu
mPanelMenu->addAction( mpTileScaleDock->toggleViewAction() );
// now add our widget to the dock - ownership of the widget is passed to the dock
mpTileScaleDock->setWidget( mpTileScaleWidget );
mpTileScaleDock->show();

connect( mMapLegend, SIGNAL( currentLayerChanged( QgsMapLayer* ) ),
mpTileScaleWidget, SLOT( layerChanged( QgsMapLayer* ) ) );

}
else
{
mpTileScaleDock->setVisible( mpTileScaleDock->isHidden() );
}
}

void QgisApp::zoomToLayerExtent()
{
mMapLegend->legendLayerZoom();
@@ -58,7 +58,6 @@ class QgsRasterLayer;
class QgsRectangle;
class QgsUndoWidget;
class QgsVectorLayer;
class QgsTileScaleWidget;

class QDomDocument;
class QNetworkReply;
@@ -289,7 +288,6 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
QAction *actionRemoveLayer() { return mActionRemoveLayer; }
QAction *actionSetLayerCRS() { return mActionSetLayerCRS; }
QAction *actionSetProjectCRSFromLayer() { return mActionSetProjectCRSFromLayer; }
QAction *actionTileScale() { return mActionTileScale; }
QAction *actionLayerProperties() { return mActionLayerProperties; }
QAction *actionLayerSubsetString() { return mActionLayerSubsetString; }
QAction *actionAddToOverview() { return mActionAddToOverview; }
@@ -544,8 +542,6 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
void setLayerCRS();
//! Assign layer CRS to project
void setProjectCRSFromLayer();
//! Show tile scale slider
void showTileScale();
//! zoom to extent of layer
void zoomToLayerExtent();
//! zoom to actual size of raster layer
@@ -1005,7 +1001,6 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
QDockWidget *mLegendDock;
QDockWidget *mLayerOrderDock;
QDockWidget *mOverviewDock;
QDockWidget *mpTileScaleDock;
QDockWidget *mpGpsDock;
QDockWidget *mLogDock;

@@ -1173,9 +1168,6 @@ class QgisApp : public QMainWindow, private Ui::MainWindow

QgsSnappingDialog* mSnappingDialog;

//! Persistent tile scale slider
QgsTileScaleWidget * mpTileScaleWidget;

QgsDecorationCopyright* mDecorationCopyright;
QgsDecorationNorthArrow* mDecorationNorthArrow;
QgsDecorationScaleBar* mDecorationScaleBar;
@@ -181,19 +181,46 @@ void QgsCoordinateReferenceSystem::setupESRIWktFix( )

bool QgsCoordinateReferenceSystem::createFromOgcWmsCrs( QString theCrs )
{
QRegExp re( "(user|custom|qgis):(\\d+)", Qt::CaseInsensitive );
if ( re.exactMatch( theCrs ) && createFromSrsId( re.cap( 2 ).toInt() ) )
QRegExp re( "urn:ogc:def:crs:([^:]+).+([^:]+)", Qt::CaseInsensitive );
if ( re.exactMatch( theCrs ) )
{
return true;
theCrs = re.cap( 1 ) + ":" + re.cap( 2 );
}
else
{
re.setPattern( "(user|custom|qgis):(\\d+)" );
if ( re.exactMatch( theCrs ) && createFromSrsId( re.cap( 2 ).toInt() ) )
{
return true;
}
}

if ( loadFromDb( QgsApplication::srsDbFilePath(), "lower(auth_name||':'||auth_id)", theCrs.toLower() ) )
return true;

if ( theCrs.compare( "CRS:84", Qt::CaseInsensitive ) == 0 )
// NAD27
if ( theCrs.compare( "CRS:27", Qt::CaseInsensitive ) == 0 ||
theCrs.compare( "OGC:CRS27", Qt::CaseInsensitive ) == 0 )
{
createFromSrsId( GEOCRS_ID );
return true;
// TODO: verify same axis orientation
return createFromOgcWmsCrs( "EPSG:4267" );
}

// NAD83
if ( theCrs.compare( "CRS:83", Qt::CaseInsensitive ) == 0 ||
theCrs.compare( "OGC:CRS83", Qt::CaseInsensitive ) == 0 )
{
// TODO: verify same axis orientation
return createFromOgcWmsCrs( "EPSG:4269" );
}

// WGS84
if ( theCrs.compare( "CRS:84", Qt::CaseInsensitive ) == 0 ||
theCrs.compare( "OGC:CRS84", Qt::CaseInsensitive ) == 0 )
{
createFromOgcWmsCrs( "EPSG:4326" );
mAxisInverted = 0;
return mIsValidFlag;
}

return false;
@@ -438,20 +438,15 @@ typedef QWidget * selectFactoryFunction_t( QWidget * parent, Qt::WFlags fl );
QWidget* QgsProviderRegistry::selectWidget( const QString & providerKey,
QWidget * parent, Qt::WFlags fl )
{
QLibrary *myLib = providerLibrary( providerKey );
if ( !myLib )
return 0;

selectFactoryFunction_t * selectFactory =
( selectFactoryFunction_t * ) cast_to_fptr( myLib->resolve( "selectWidget" ) );
( selectFactoryFunction_t * ) cast_to_fptr( function( providerKey, "selectWidget" ) );

if ( !selectFactory )
return 0;

return selectFactory( parent, fl );
}


void * QgsProviderRegistry::function( QString const & providerKey,
QString const & functionName )
{
@@ -491,6 +486,21 @@ QLibrary *QgsProviderRegistry::providerLibrary( QString const & providerKey ) co
return 0;
}

void QgsProviderRegistry::registerGuis( QWidget *parent )
{
typedef void registerGui_function( QWidget * parent );

foreach( const QString &provider, providerList() )
{
registerGui_function *registerGui = ( registerGui_function * ) cast_to_fptr( function( provider, "registerGui" ) );

if ( !registerGui )
continue;

registerGui( parent );
}
}

QString QgsProviderRegistry::fileVectorFilters() const
{
return mVectorFileFilters;
@@ -140,6 +140,8 @@ class CORE_EXPORT QgsProviderRegistry
/** type for data provider metadata associative container */
typedef std::map<QString, QgsProviderMetadata*> Providers;

void registerGuis( QWidget *widget );

private:

/** ctor private since instance() creates it */
@@ -305,6 +305,8 @@ QDomDocument QgsManageConnectionsDialog::saveWMSConnections( const QStringList &
el.setAttribute( "url", settings.value( path + connections[ i ] + "/url", "" ).toString() );
el.setAttribute( "ignoreGetMapURI", settings.value( path + connections[i] + "/ignoreGetMapURI", false ).toBool() ? "true" : "false" );
el.setAttribute( "ignoreGetFeatureInfoURI", settings.value( path + connections[i] + "/ignoreGetFeatureInfoURI", false ).toBool() ? "true" : "false" );
el.setAttribute( "ignoreAxisOrientation", settings.value( path + connections[i] + "/ignoreAxisOrientation", false ).toBool() ? "true" : "false" );
el.setAttribute( "invertAxisOrientation", settings.value( path + connections[i] + "/invertAxisOrientation", false ).toBool() ? "true" : "false" );

path = "/Qgis/WMS/";
el.setAttribute( "username", settings.value( path + connections[ i ] + "/username", "" ).toString() );
@@ -491,6 +493,8 @@ void QgsManageConnectionsDialog::loadWMSConnections( const QDomDocument &doc, co
settings.setValue( QString( "/" + connectionName + "/url" ) , child.attribute( "url" ) );
settings.setValue( QString( "/" + connectionName + "/ignoreGetMapURI" ), child.attribute( "ignoreGetMapURI" ) == "true" );
settings.setValue( QString( "/" + connectionName + "/ignoreGetFeatureInfoURI" ), child.attribute( "ignoreGetFeatureInfoURI" ) == "true" );
settings.setValue( QString( "/" + connectionName + "/ignoreAxisOrientation" ), child.attribute( "ignoreAxisOrientation" ) == "true" );
settings.setValue( QString( "/" + connectionName + "/invertAxisOrientation" ), child.attribute( "invertAxisOrientation" ) == "true" );
settings.endGroup();

if ( !child.attribute( "username" ).isEmpty() )
@@ -83,7 +83,7 @@ QgsMapCanvas::QgsMapCanvas( QWidget * parent, const char *name )
, mPainting( false )
, mAntiAliasing( false )
{
Q_UNUSED( name );
setObjectName( name );
//disable the update that leads to the resize crash
if ( viewport() )
{
@@ -52,11 +52,15 @@ QgsNewHttpConnection::QgsNewHttpConnection(
{
cbxIgnoreGetMapURI->setChecked( settings.value( key + "/ignoreGetMapURI", false ).toBool() );
cbxIgnoreGetFeatureInfoURI->setChecked( settings.value( key + "/ignoreGetFeatureInfoURI", false ).toBool() );
cbxIgnoreAxisOrientation->setChecked( settings.value( key + "/ignoreAxisOrientation", false ).toBool() );
cbxInvertAxisOrientation->setChecked( settings.value( key + "/invertAxisOrientation", false ).toBool() );
}
else
{
cbxIgnoreGetMapURI->setVisible( false );
cbxIgnoreGetFeatureInfoURI->setVisible( false );
cbxIgnoreAxisOrientation->setVisible( false );
cbxInvertAxisOrientation->setVisible( false );
}

txtUserName->setText( settings.value( credentialsKey + "/username" ).toString() );
@@ -100,24 +104,27 @@ void QgsNewHttpConnection::accept()
}

QUrl url( txtUrl->text().trimmed() );
const QList< QPair<QByteArray, QByteArray> > &items = url.encodedQueryItems();
QHash< QString, QPair<QByteArray, QByteArray> > params;
for ( QList< QPair<QByteArray, QByteArray> >::const_iterator it = items.constBegin(); it != items.constEnd(); ++it )
{
params.insert( QString( it->first ).toUpper(), *it );
}

QList< QPair<QByteArray, QByteArray> > params = url.encodedQueryItems();
for ( int i = 0; i < params.size(); i++ )
if ( params["SERVICE"].second.toUpper() == "WMS" )
{
if ( params[i].first.toUpper() == "SERVICE" ||
params[i].first.toUpper() == "REQUEST" ||
params[i].first.toUpper() == "FORMAT" )
{
params.removeAt( i-- );
}
url.removeEncodedQueryItem( params["SERVICE"].first );
url.removeEncodedQueryItem( params["REQUEST"].first );
url.removeEncodedQueryItem( params["FORMAT"].first );
}
url.setEncodedQueryItems( params );

settings.setValue( key + "/url", url.toString() );
if ( mBaseKey == "/Qgis/connections-wms/" )
{
settings.setValue( key + "/ignoreGetMapURI", cbxIgnoreGetMapURI->isChecked() );
settings.setValue( key + "/ignoreGetFeatureInfoURI", cbxIgnoreGetFeatureInfoURI->isChecked() );
settings.setValue( key + "/ignoreAxisOrientation", cbxIgnoreAxisOrientation->isChecked() );
settings.setValue( key + "/invertAxisOrientation", cbxInvertAxisOrientation->isChecked() );
}

settings.setValue( credentialsKey + "/username", txtUserName->text() );
@@ -4,12 +4,16 @@ SET (WMS_SRCS
qgswmssourceselect.cpp
qgswmsconnection.cpp
qgswmsdataitems.cpp
qgstilescalewidget.cpp
qgswmtsdimensions.cpp
)
SET (WMS_MOC_HDRS
qgswmsprovider.h
qgswmssourceselect.h
qgswmsconnection.h
qgswmsdataitems.h
qgstilescalewidget.h
qgswmtsdimensions.h
)

QT4_WRAP_CPP (WMS_MOC_SRCS ${WMS_MOC_HDRS})

0 comments on commit 904cef0

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