Skip to content
Permalink
Browse files

add support for optional wm(t)s axis inversion

  • Loading branch information
jef-n committed Jun 4, 2012
1 parent e7af002 commit 08a712a5f04be32961fcd58a25781af6eabe4983
@@ -306,6 +306,7 @@ QDomDocument QgsManageConnectionsDialog::saveWMSConnections( const QStringList &
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() );
@@ -493,6 +494,7 @@ void QgsManageConnectionsDialog::loadWMSConnections( const QDomDocument &doc, co
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() )
@@ -53,12 +53,14 @@ 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() );
@@ -124,6 +126,7 @@ void QgsNewHttpConnection::accept()
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() );
@@ -63,28 +63,38 @@ QgsWMSConnection::QgsWMSConnection( QString theConnName ) :
bool ignoreGetMap = settings.value( key + "/ignoreGetMapURI", false ).toBool();
bool ignoreGetFeatureInfo = settings.value( key + "/ignoreGetFeatureInfoURI", false ).toBool();
bool ignoreAxisOrientation = settings.value( key + "/ignoreAxisOrientation", false ).toBool();
if ( ignoreGetMap || ignoreGetFeatureInfo || ignoreAxisOrientation )
bool invertAxisOrientation = settings.value( key + "/invertAxisOrientation", false ).toBool();

QString connArgs, delim;


if ( ignoreGetMap )
{
QString connArgs = "ignoreUrl=";
connArgs += delim + "GetMap";
delim = ";";
}

if ( ignoreGetMap )
{
connArgs += "GetMap";
}
if ( ignoreGetFeatureInfo )
{
connArgs += delim + "GetFeatureInfo";
delim = ";";
}

if ( ignoreGetFeatureInfo )
{
if ( !connArgs.endsWith( "=" ) )
connArgs += ";";
connArgs += "GetFeatureInfo";
}
if ( ignoreAxisOrientation )
{
connArgs += delim + "AxisOrientation";
delim = ";";
}

if ( ignoreAxisOrientation )
{
if ( !connArgs.endsWith( "=" ) )
connArgs += ";";
connArgs += "AxisOrientation";
}
if ( invertAxisOrientation )
{
connArgs += delim + "InvertAxisOrientation";
delim = ";";
}

if( !connArgs.isEmpty() )
{
connArgs.prepend( "ignoreUrl=" );

if ( mConnectionInfo.startsWith( "username=" ) )
{
@@ -130,6 +130,7 @@ void QgsWmsProvider::parseUri( QString uri )
mIgnoreGetMapUrl = false;
mIgnoreGetFeatureInfoUrl = false;
mIgnoreAxisOrientation = false;
mInvertAxisOrientation = false;

QString layer;

@@ -179,6 +180,10 @@ void QgsWmsProvider::parseUri( QString uri )
{
mIgnoreAxisOrientation = true;
}
else if ( param == "InvertAxisOrientation" )
{
mInvertAxisOrientation = true;
}
}
}
else if ( item.startsWith( "tileMatrixSet=" ) )
@@ -550,6 +555,9 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, i
}
}

if ( mInvertAxisOrientation )
changeXY = !changeXY;

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

s.crs = crs.authid();

bool invert = !mIgnoreAxisOrientation && crs.axisInverted();
if ( mInvertAxisOrientation )
invert = !invert;

QgsDebugMsg( QString( "tilematrix set: %1 (supportedCRS:%2 crs:%3; metersPerUnit:%4 axisInverted:%5)" )
.arg( s.identifier )
.arg( supportedCRS )
.arg( s.crs )
.arg( metersPerUnit, 0, 'f' )
.arg( !mIgnoreAxisOrientation && crs.axisInverted() ? "yes" : "no" )
.arg( invert ? "yes" : "no" )
);

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

if ( mInvertAxisOrientation )
changeXY = !changeXY;

// compose the URL query string for the WMS server.
QString crsKey = "SRS"; //SRS in 1.1.1 and CRS in 1.3.0
if ( mCapabilities.version == "1.3.0" || mCapabilities.version == "1.3" )
@@ -1098,6 +1098,7 @@ class QgsWmsProvider : public QgsRasterDataProvider
bool mIgnoreGetMapUrl;
bool mIgnoreGetFeatureInfoUrl;
bool mIgnoreAxisOrientation;
bool mInvertAxisOrientation;

//! supported formats for GetFeatureInfo in order of preference
QStringList mSupportedGetFeatureFormats;
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>507</width>
<height>322</height>
<width>475</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle">
@@ -48,6 +48,12 @@
</item>
<item row="4" column="0" colspan="3">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>If the service requires basic authentication, enter a user name and optional password</string>
</property>
@@ -149,6 +155,13 @@
</property>
</widget>
</item>
<item row="11" column="0" colspan="2">
<widget class="QCheckBox" name="cbxInvertAxisOrientation">
<property name="text">
<string>Invert axis orientation</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

0 comments on commit 08a712a

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