Skip to content

Commit 08a712a

Browse files
committed
add support for optional wm(t)s axis inversion
1 parent e7af002 commit 08a712a

6 files changed

+66
-22
lines changed

src/gui/qgsmanageconnectionsdialog.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ QDomDocument QgsManageConnectionsDialog::saveWMSConnections( const QStringList &
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" );
308308
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" );
309310

310311
path = "/Qgis/WMS/";
311312
el.setAttribute( "username", settings.value( path + connections[ i ] + "/username", "" ).toString() );
@@ -493,6 +494,7 @@ void QgsManageConnectionsDialog::loadWMSConnections( const QDomDocument &doc, co
493494
settings.setValue( QString( "/" + connectionName + "/ignoreGetMapURI" ), child.attribute( "ignoreGetMapURI" ) == "true" );
494495
settings.setValue( QString( "/" + connectionName + "/ignoreGetFeatureInfoURI" ), child.attribute( "ignoreGetFeatureInfoURI" ) == "true" );
495496
settings.setValue( QString( "/" + connectionName + "/ignoreAxisOrientation" ), child.attribute( "ignoreAxisOrientation" ) == "true" );
497+
settings.setValue( QString( "/" + connectionName + "/invertAxisOrientation" ), child.attribute( "invertAxisOrientation" ) == "true" );
496498
settings.endGroup();
497499

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

src/gui/qgsnewhttpconnection.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,14 @@ QgsNewHttpConnection::QgsNewHttpConnection(
5353
cbxIgnoreGetMapURI->setChecked( settings.value( key + "/ignoreGetMapURI", false ).toBool() );
5454
cbxIgnoreGetFeatureInfoURI->setChecked( settings.value( key + "/ignoreGetFeatureInfoURI", false ).toBool() );
5555
cbxIgnoreAxisOrientation->setChecked( settings.value( key + "/ignoreAxisOrientation", false ).toBool() );
56+
cbxInvertAxisOrientation->setChecked( settings.value( key + "/invertAxisOrientation", false ).toBool() );
5657
}
5758
else
5859
{
5960
cbxIgnoreGetMapURI->setVisible( false );
6061
cbxIgnoreGetFeatureInfoURI->setVisible( false );
6162
cbxIgnoreAxisOrientation->setVisible( false );
63+
cbxInvertAxisOrientation->setVisible( false );
6264
}
6365

6466
txtUserName->setText( settings.value( credentialsKey + "/username" ).toString() );
@@ -124,6 +126,7 @@ void QgsNewHttpConnection::accept()
124126
settings.setValue( key + "/ignoreGetMapURI", cbxIgnoreGetMapURI->isChecked() );
125127
settings.setValue( key + "/ignoreGetFeatureInfoURI", cbxIgnoreGetFeatureInfoURI->isChecked() );
126128
settings.setValue( key + "/ignoreAxisOrientation", cbxIgnoreAxisOrientation->isChecked() );
129+
settings.setValue( key + "/invertAxisOrientation", cbxInvertAxisOrientation->isChecked() );
127130
}
128131

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

src/providers/wms/qgswmsconnection.cpp

+28-18
Original file line numberDiff line numberDiff line change
@@ -63,28 +63,38 @@ QgsWMSConnection::QgsWMSConnection( QString theConnName ) :
6363
bool ignoreGetMap = settings.value( key + "/ignoreGetMapURI", false ).toBool();
6464
bool ignoreGetFeatureInfo = settings.value( key + "/ignoreGetFeatureInfoURI", false ).toBool();
6565
bool ignoreAxisOrientation = settings.value( key + "/ignoreAxisOrientation", false ).toBool();
66-
if ( ignoreGetMap || ignoreGetFeatureInfo || ignoreAxisOrientation )
66+
bool invertAxisOrientation = settings.value( key + "/invertAxisOrientation", false ).toBool();
67+
68+
QString connArgs, delim;
69+
70+
71+
if ( ignoreGetMap )
6772
{
68-
QString connArgs = "ignoreUrl=";
73+
connArgs += delim + "GetMap";
74+
delim = ";";
75+
}
6976

70-
if ( ignoreGetMap )
71-
{
72-
connArgs += "GetMap";
73-
}
77+
if ( ignoreGetFeatureInfo )
78+
{
79+
connArgs += delim + "GetFeatureInfo";
80+
delim = ";";
81+
}
7482

75-
if ( ignoreGetFeatureInfo )
76-
{
77-
if ( !connArgs.endsWith( "=" ) )
78-
connArgs += ";";
79-
connArgs += "GetFeatureInfo";
80-
}
83+
if ( ignoreAxisOrientation )
84+
{
85+
connArgs += delim + "AxisOrientation";
86+
delim = ";";
87+
}
8188

82-
if ( ignoreAxisOrientation )
83-
{
84-
if ( !connArgs.endsWith( "=" ) )
85-
connArgs += ";";
86-
connArgs += "AxisOrientation";
87-
}
89+
if ( invertAxisOrientation )
90+
{
91+
connArgs += delim + "InvertAxisOrientation";
92+
delim = ";";
93+
}
94+
95+
if( !connArgs.isEmpty() )
96+
{
97+
connArgs.prepend( "ignoreUrl=" );
8898

8999
if ( mConnectionInfo.startsWith( "username=" ) )
90100
{

src/providers/wms/qgswmsprovider.cpp

+17-2
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ void QgsWmsProvider::parseUri( QString uri )
130130
mIgnoreGetMapUrl = false;
131131
mIgnoreGetFeatureInfoUrl = false;
132132
mIgnoreAxisOrientation = false;
133+
mInvertAxisOrientation = false;
133134

134135
QString layer;
135136

@@ -179,6 +180,10 @@ void QgsWmsProvider::parseUri( QString uri )
179180
{
180181
mIgnoreAxisOrientation = true;
181182
}
183+
else if ( param == "InvertAxisOrientation" )
184+
{
185+
mInvertAxisOrientation = true;
186+
}
182187
}
183188
}
184189
else if ( item.startsWith( "tileMatrixSet=" ) )
@@ -550,6 +555,9 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, i
550555
}
551556
}
552557

558+
if ( mInvertAxisOrientation )
559+
changeXY = !changeXY;
560+
553561
// compose the URL query string for the WMS server.
554562
QString crsKey = "SRS"; //SRS in 1.1.1 and CRS in 1.3.0
555563
if ( mCapabilities.version == "1.3.0" || mCapabilities.version == "1.3" )
@@ -2529,12 +2537,16 @@ void QgsWmsProvider::parseWMTSContents( QDomElement const &e )
25292537

25302538
s.crs = crs.authid();
25312539

2540+
bool invert = !mIgnoreAxisOrientation && crs.axisInverted();
2541+
if ( mInvertAxisOrientation )
2542+
invert = !invert;
2543+
25322544
QgsDebugMsg( QString( "tilematrix set: %1 (supportedCRS:%2 crs:%3; metersPerUnit:%4 axisInverted:%5)" )
25332545
.arg( s.identifier )
25342546
.arg( supportedCRS )
25352547
.arg( s.crs )
25362548
.arg( metersPerUnit, 0, 'f' )
2537-
.arg( !mIgnoreAxisOrientation && crs.axisInverted() ? "yes" : "no" )
2549+
.arg( invert ? "yes" : "no" )
25382550
);
25392551

25402552
for ( QDomNode n1 = n0.firstChildElement( "TileMatrix" );
@@ -2553,7 +2565,7 @@ void QgsWmsProvider::parseWMTSContents( QDomElement const &e )
25532565
QStringList topLeft = n1.firstChildElement( "TopLeftCorner" ).text().split( " " );
25542566
if ( topLeft.size() == 2 )
25552567
{
2556-
if ( !mIgnoreAxisOrientation && crs.axisInverted() )
2568+
if ( invert )
25572569
{
25582570
m.topLeft.set( topLeft[1].toDouble(), topLeft[0].toDouble() );
25592571
}
@@ -3733,6 +3745,9 @@ QStringList QgsWmsProvider::identifyAs( const QgsPoint& point, QString format )
37333745
}
37343746
}
37353747

3748+
if ( mInvertAxisOrientation )
3749+
changeXY = !changeXY;
3750+
37363751
// compose the URL query string for the WMS server.
37373752
QString crsKey = "SRS"; //SRS in 1.1.1 and CRS in 1.3.0
37383753
if ( mCapabilities.version == "1.3.0" || mCapabilities.version == "1.3" )

src/providers/wms/qgswmsprovider.h

+1
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,7 @@ class QgsWmsProvider : public QgsRasterDataProvider
10981098
bool mIgnoreGetMapUrl;
10991099
bool mIgnoreGetFeatureInfoUrl;
11001100
bool mIgnoreAxisOrientation;
1101+
bool mInvertAxisOrientation;
11011102

11021103
//! supported formats for GetFeatureInfo in order of preference
11031104
QStringList mSupportedGetFeatureFormats;

src/ui/qgsnewhttpconnectionbase.ui

+15-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>507</width>
10-
<height>322</height>
9+
<width>475</width>
10+
<height>400</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -48,6 +48,12 @@
4848
</item>
4949
<item row="4" column="0" colspan="3">
5050
<widget class="QLabel" name="label">
51+
<property name="sizePolicy">
52+
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
53+
<horstretch>0</horstretch>
54+
<verstretch>0</verstretch>
55+
</sizepolicy>
56+
</property>
5157
<property name="text">
5258
<string>If the service requires basic authentication, enter a user name and optional password</string>
5359
</property>
@@ -149,6 +155,13 @@
149155
</property>
150156
</widget>
151157
</item>
158+
<item row="11" column="0" colspan="2">
159+
<widget class="QCheckBox" name="cbxInvertAxisOrientation">
160+
<property name="text">
161+
<string>Invert axis orientation</string>
162+
</property>
163+
</widget>
164+
</item>
152165
</layout>
153166
</widget>
154167
</item>

0 commit comments

Comments
 (0)