Skip to content

Commit 904cef0

Browse files
committed
[FEATURE] Add WMTS support
2 parents 5ebdbe3 + f276fde commit 904cef0

25 files changed

+2454
-1085
lines changed

scripts/prepare-commit.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ fi
3434
# save original changes
3535
if [ -d .svn ]; then
3636
REV=r$(svn info | sed -ne "s/Revision: //p")
37-
svn diff >$REV.diff
37+
svn diff >rev-$REV.diff
3838
elif [ -d .git ]; then
3939
REV=$(git log -n1 --pretty=%H)
40-
git diff >$REV.diff
40+
git diff >sha-$REV.diff
4141
fi
4242

4343
ASTYLEDIFF=astyle.$REV.diff

src/app/CMakeLists.txt

-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ SET(QGIS_APP_SRCS
9595
qgssinglesymboldialog.cpp
9696
qgssnappingdialog.cpp
9797
qgsundowidget.cpp
98-
qgstilescalewidget.cpp
9998
qgstipgui.cpp
10099
qgstipfactory.cpp
101100
qgsuniquevaluedialog.cpp
@@ -232,7 +231,6 @@ SET (QGIS_APP_MOC_HDRS
232231
qgssnappingdialog.h
233232
qgssponsors.h
234233
qgstextannotationdialog.h
235-
qgstilescalewidget.h
236234
qgstipgui.h
237235
qgstipfactory.h
238236
qgsundowidget.h

src/app/qgisapp.cpp

+2-46
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@
165165
#include "qgssnappingdialog.h"
166166
#include "qgssponsors.h"
167167
#include "qgstextannotationitem.h"
168-
#include "qgstilescalewidget.h"
169168
#include "qgstipgui.h"
170169
#include "qgsundowidget.h"
171170
#include "qgsvectordataprovider.h"
@@ -407,7 +406,6 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
407406
, mSplash( splash )
408407
, mShowProjectionTab( false )
409408
, mPythonUtils( NULL )
410-
, mpTileScaleWidget( NULL )
411409
#ifdef Q_OS_WIN
412410
, mSkipNextContextMenuEvent( 0 )
413411
#endif
@@ -655,6 +653,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
655653
// request notification of FileOpen events (double clicking a file icon in Mac OS X Finder)
656654
QgsApplication::setFileOpenEventReceiver( this );
657655

656+
QgsProviderRegistry::instance()->registerGuis( this );
657+
658658
// update windows
659659
qApp->processEvents();
660660

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

793793
// Add the recently accessed project file paths to the File menu
794794
mRecentProjectPaths = settings.value( "/UI/recentProjectsList" ).toStringList();
795-
796-
// Restore state of tile scale widget
797-
if ( settings.value( "/UI/tileScaleEnabled", false ).toBool() )
798-
{
799-
showTileScale();
800-
}
801795
}
802796

803797

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

2088-
// Persist state of tile scale slider
2089-
if ( mpTileScaleWidget )
2090-
{
2091-
settings.setValue( "/UI/tileScaleEnabled", true );
2092-
delete mpTileScaleWidget;
2093-
}
2094-
else
2095-
{
2096-
settings.setValue( "/UI/tileScaleEnabled", false );
2097-
}
2098-
20992081
QgsPluginRegistry::instance()->unloadAll();
21002082
}
21012083

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

4870-
void QgisApp::showTileScale()
4871-
{
4872-
if ( !mpTileScaleWidget )
4873-
{
4874-
mpTileScaleWidget = new QgsTileScaleWidget( mMapCanvas );
4875-
//create the dock widget
4876-
mpTileScaleDock = new QDockWidget( tr( "Tile scale" ), this );
4877-
mpTileScaleDock->setObjectName( "TileScale" );
4878-
mpTileScaleDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
4879-
addDockWidget( Qt::RightDockWidgetArea, mpTileScaleDock );
4880-
// add to the Panel submenu
4881-
mPanelMenu->addAction( mpTileScaleDock->toggleViewAction() );
4882-
// now add our widget to the dock - ownership of the widget is passed to the dock
4883-
mpTileScaleDock->setWidget( mpTileScaleWidget );
4884-
mpTileScaleDock->show();
4885-
4886-
connect( mMapLegend, SIGNAL( currentLayerChanged( QgsMapLayer* ) ),
4887-
mpTileScaleWidget, SLOT( layerChanged( QgsMapLayer* ) ) );
4888-
4889-
}
4890-
else
4891-
{
4892-
mpTileScaleDock->setVisible( mpTileScaleDock->isHidden() );
4893-
}
4894-
}
4895-
48964852
void QgisApp::zoomToLayerExtent()
48974853
{
48984854
mMapLegend->legendLayerZoom();

src/app/qgisapp.h

-8
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ class QgsRasterLayer;
5858
class QgsRectangle;
5959
class QgsUndoWidget;
6060
class QgsVectorLayer;
61-
class QgsTileScaleWidget;
6261

6362
class QDomDocument;
6463
class QNetworkReply;
@@ -289,7 +288,6 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
289288
QAction *actionRemoveLayer() { return mActionRemoveLayer; }
290289
QAction *actionSetLayerCRS() { return mActionSetLayerCRS; }
291290
QAction *actionSetProjectCRSFromLayer() { return mActionSetProjectCRSFromLayer; }
292-
QAction *actionTileScale() { return mActionTileScale; }
293291
QAction *actionLayerProperties() { return mActionLayerProperties; }
294292
QAction *actionLayerSubsetString() { return mActionLayerSubsetString; }
295293
QAction *actionAddToOverview() { return mActionAddToOverview; }
@@ -544,8 +542,6 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
544542
void setLayerCRS();
545543
//! Assign layer CRS to project
546544
void setProjectCRSFromLayer();
547-
//! Show tile scale slider
548-
void showTileScale();
549545
//! zoom to extent of layer
550546
void zoomToLayerExtent();
551547
//! zoom to actual size of raster layer
@@ -1005,7 +1001,6 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
10051001
QDockWidget *mLegendDock;
10061002
QDockWidget *mLayerOrderDock;
10071003
QDockWidget *mOverviewDock;
1008-
QDockWidget *mpTileScaleDock;
10091004
QDockWidget *mpGpsDock;
10101005
QDockWidget *mLogDock;
10111006

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

11741169
QgsSnappingDialog* mSnappingDialog;
11751170

1176-
//! Persistent tile scale slider
1177-
QgsTileScaleWidget * mpTileScaleWidget;
1178-
11791171
QgsDecorationCopyright* mDecorationCopyright;
11801172
QgsDecorationNorthArrow* mDecorationNorthArrow;
11811173
QgsDecorationScaleBar* mDecorationScaleBar;

src/core/qgscoordinatereferencesystem.cpp

+33-6
Original file line numberDiff line numberDiff line change
@@ -181,19 +181,46 @@ void QgsCoordinateReferenceSystem::setupESRIWktFix( )
181181

182182
bool QgsCoordinateReferenceSystem::createFromOgcWmsCrs( QString theCrs )
183183
{
184-
QRegExp re( "(user|custom|qgis):(\\d+)", Qt::CaseInsensitive );
185-
if ( re.exactMatch( theCrs ) && createFromSrsId( re.cap( 2 ).toInt() ) )
184+
QRegExp re( "urn:ogc:def:crs:([^:]+).+([^:]+)", Qt::CaseInsensitive );
185+
if ( re.exactMatch( theCrs ) )
186186
{
187-
return true;
187+
theCrs = re.cap( 1 ) + ":" + re.cap( 2 );
188+
}
189+
else
190+
{
191+
re.setPattern( "(user|custom|qgis):(\\d+)" );
192+
if ( re.exactMatch( theCrs ) && createFromSrsId( re.cap( 2 ).toInt() ) )
193+
{
194+
return true;
195+
}
188196
}
189197

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

193-
if ( theCrs.compare( "CRS:84", Qt::CaseInsensitive ) == 0 )
201+
// NAD27
202+
if ( theCrs.compare( "CRS:27", Qt::CaseInsensitive ) == 0 ||
203+
theCrs.compare( "OGC:CRS27", Qt::CaseInsensitive ) == 0 )
194204
{
195-
createFromSrsId( GEOCRS_ID );
196-
return true;
205+
// TODO: verify same axis orientation
206+
return createFromOgcWmsCrs( "EPSG:4267" );
207+
}
208+
209+
// NAD83
210+
if ( theCrs.compare( "CRS:83", Qt::CaseInsensitive ) == 0 ||
211+
theCrs.compare( "OGC:CRS83", Qt::CaseInsensitive ) == 0 )
212+
{
213+
// TODO: verify same axis orientation
214+
return createFromOgcWmsCrs( "EPSG:4269" );
215+
}
216+
217+
// WGS84
218+
if ( theCrs.compare( "CRS:84", Qt::CaseInsensitive ) == 0 ||
219+
theCrs.compare( "OGC:CRS84", Qt::CaseInsensitive ) == 0 )
220+
{
221+
createFromOgcWmsCrs( "EPSG:4326" );
222+
mAxisInverted = 0;
223+
return mIsValidFlag;
197224
}
198225

199226
return false;

src/core/qgsproviderregistry.cpp

+16-6
Original file line numberDiff line numberDiff line change
@@ -438,20 +438,15 @@ typedef QWidget * selectFactoryFunction_t( QWidget * parent, Qt::WFlags fl );
438438
QWidget* QgsProviderRegistry::selectWidget( const QString & providerKey,
439439
QWidget * parent, Qt::WFlags fl )
440440
{
441-
QLibrary *myLib = providerLibrary( providerKey );
442-
if ( !myLib )
443-
return 0;
444-
445441
selectFactoryFunction_t * selectFactory =
446-
( selectFactoryFunction_t * ) cast_to_fptr( myLib->resolve( "selectWidget" ) );
442+
( selectFactoryFunction_t * ) cast_to_fptr( function( providerKey, "selectWidget" ) );
447443

448444
if ( !selectFactory )
449445
return 0;
450446

451447
return selectFactory( parent, fl );
452448
}
453449

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

489+
void QgsProviderRegistry::registerGuis( QWidget *parent )
490+
{
491+
typedef void registerGui_function( QWidget * parent );
492+
493+
foreach( const QString &provider, providerList() )
494+
{
495+
registerGui_function *registerGui = ( registerGui_function * ) cast_to_fptr( function( provider, "registerGui" ) );
496+
497+
if ( !registerGui )
498+
continue;
499+
500+
registerGui( parent );
501+
}
502+
}
503+
494504
QString QgsProviderRegistry::fileVectorFilters() const
495505
{
496506
return mVectorFileFilters;

src/core/qgsproviderregistry.h

+2
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ class CORE_EXPORT QgsProviderRegistry
140140
/** type for data provider metadata associative container */
141141
typedef std::map<QString, QgsProviderMetadata*> Providers;
142142

143+
void registerGuis( QWidget *widget );
144+
143145
private:
144146

145147
/** ctor private since instance() creates it */

src/gui/qgsmanageconnectionsdialog.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,8 @@ QDomDocument QgsManageConnectionsDialog::saveWMSConnections( const QStringList &
305305
el.setAttribute( "url", settings.value( path + connections[ i ] + "/url", "" ).toString() );
306306
el.setAttribute( "ignoreGetMapURI", settings.value( path + connections[i] + "/ignoreGetMapURI", false ).toBool() ? "true" : "false" );
307307
el.setAttribute( "ignoreGetFeatureInfoURI", settings.value( path + connections[i] + "/ignoreGetFeatureInfoURI", false ).toBool() ? "true" : "false" );
308+
el.setAttribute( "ignoreAxisOrientation", settings.value( path + connections[i] + "/ignoreAxisOrientation", false ).toBool() ? "true" : "false" );
309+
el.setAttribute( "invertAxisOrientation", settings.value( path + connections[i] + "/invertAxisOrientation", false ).toBool() ? "true" : "false" );
308310

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

496500
if ( !child.attribute( "username" ).isEmpty() )

src/gui/qgsmapcanvas.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ QgsMapCanvas::QgsMapCanvas( QWidget * parent, const char *name )
8383
, mPainting( false )
8484
, mAntiAliasing( false )
8585
{
86-
Q_UNUSED( name );
86+
setObjectName( name );
8787
//disable the update that leads to the resize crash
8888
if ( viewport() )
8989
{

src/gui/qgsnewhttpconnection.cpp

+16-9
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,15 @@ QgsNewHttpConnection::QgsNewHttpConnection(
5252
{
5353
cbxIgnoreGetMapURI->setChecked( settings.value( key + "/ignoreGetMapURI", false ).toBool() );
5454
cbxIgnoreGetFeatureInfoURI->setChecked( settings.value( key + "/ignoreGetFeatureInfoURI", false ).toBool() );
55+
cbxIgnoreAxisOrientation->setChecked( settings.value( key + "/ignoreAxisOrientation", false ).toBool() );
56+
cbxInvertAxisOrientation->setChecked( settings.value( key + "/invertAxisOrientation", false ).toBool() );
5557
}
5658
else
5759
{
5860
cbxIgnoreGetMapURI->setVisible( false );
5961
cbxIgnoreGetFeatureInfoURI->setVisible( false );
62+
cbxIgnoreAxisOrientation->setVisible( false );
63+
cbxInvertAxisOrientation->setVisible( false );
6064
}
6165

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

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

104-
QList< QPair<QByteArray, QByteArray> > params = url.encodedQueryItems();
105-
for ( int i = 0; i < params.size(); i++ )
114+
if ( params["SERVICE"].second.toUpper() == "WMS" )
106115
{
107-
if ( params[i].first.toUpper() == "SERVICE" ||
108-
params[i].first.toUpper() == "REQUEST" ||
109-
params[i].first.toUpper() == "FORMAT" )
110-
{
111-
params.removeAt( i-- );
112-
}
116+
url.removeEncodedQueryItem( params["SERVICE"].first );
117+
url.removeEncodedQueryItem( params["REQUEST"].first );
118+
url.removeEncodedQueryItem( params["FORMAT"].first );
113119
}
114-
url.setEncodedQueryItems( params );
115120

116121
settings.setValue( key + "/url", url.toString() );
117122
if ( mBaseKey == "/Qgis/connections-wms/" )
118123
{
119124
settings.setValue( key + "/ignoreGetMapURI", cbxIgnoreGetMapURI->isChecked() );
120125
settings.setValue( key + "/ignoreGetFeatureInfoURI", cbxIgnoreGetFeatureInfoURI->isChecked() );
126+
settings.setValue( key + "/ignoreAxisOrientation", cbxIgnoreAxisOrientation->isChecked() );
127+
settings.setValue( key + "/invertAxisOrientation", cbxInvertAxisOrientation->isChecked() );
121128
}
122129

123130
settings.setValue( credentialsKey + "/username", txtUserName->text() );

src/providers/wms/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ SET (WMS_SRCS
44
qgswmssourceselect.cpp
55
qgswmsconnection.cpp
66
qgswmsdataitems.cpp
7+
qgstilescalewidget.cpp
8+
qgswmtsdimensions.cpp
79
)
810
SET (WMS_MOC_HDRS
911
qgswmsprovider.h
1012
qgswmssourceselect.h
1113
qgswmsconnection.h
1214
qgswmsdataitems.h
15+
qgstilescalewidget.h
16+
qgswmtsdimensions.h
1317
)
1418

1519
QT4_WRAP_CPP (WMS_MOC_SRCS ${WMS_MOC_HDRS})

0 commit comments

Comments
 (0)