[SCM] qgis branch, master, updated. a2ee769957385f4e084c5e8b6ba178a8c877d1db
Juergen E. Fischer
jef at norbit.de
Tue Mar 20 13:43:40 UTC 2012
The following commit has been merged in the master branch:
commit 949b2f0179f7d4fd1ef61856fd8ed9dc366a87ae
Author: Juergen E. Fischer <jef at norbit.de>
Date: Thu Mar 15 23:59:33 2012 +0100
WMS 1.3: better detection of inverted axis
diff --git a/src/core/qgscoordinatereferencesystem.cpp b/src/core/qgscoordinatereferencesystem.cpp
index 5fb2631..4a0fbc9 100644
--- a/src/core/qgscoordinatereferencesystem.cpp
+++ b/src/core/qgscoordinatereferencesystem.cpp
@@ -166,6 +166,7 @@ QgsCoordinateReferenceSystem& QgsCoordinateReferenceSystem::operator=( const Qgs
mProjectionAcronym = srs.mProjectionAcronym;
mEllipsoidAcronym = srs.mEllipsoidAcronym;
mGeoFlag = srs.mGeoFlag;
+ mAxisInverted = srs.mAxisInverted;
mMapUnits = srs.mMapUnits;
mSRID = srs.mSRID;
mAuthId = srs.mAuthId;
@@ -264,6 +265,7 @@ bool QgsCoordinateReferenceSystem::loadFromDb( QString db, QString expression, Q
mSRID = QString::fromUtf8(( char * )sqlite3_column_text( myPreparedStatement, 5 ) ).toLong();
mAuthId = QString::fromUtf8(( char * )sqlite3_column_text( myPreparedStatement, 6 ) );
mGeoFlag = QString::fromUtf8(( char * )sqlite3_column_text( myPreparedStatement, 7 ) ).toInt() != 0;
+ mAxisInverted = -1;
if ( mSrsId >= USER_CRS_START_ID && mAuthId.isEmpty() )
{
@@ -291,6 +293,21 @@ bool QgsCoordinateReferenceSystem::loadFromDb( QString db, QString expression, Q
return mIsValidFlag;
}
+bool QgsCoordinateReferenceSystem::axisInverted() const
+{
+ if ( mAxisInverted == -1 )
+ {
+ OGRAxisOrientation orientation;
+ const char *axis0 = OSRGetAxis( mCRS, mGeoFlag ? "GEOGCS" : "PROJCS", 0, &orientation );
+ mAxisInverted = mGeoFlag
+ ? (orientation == OAO_East || orientation == OAO_West || orientation == OAO_Other )
+ : (orientation == OAO_North || orientation == OAO_South );
+ QgsDebugMsg( QString( "srid:%1 axis0:%2 orientation:%3 inverted:%4" ).arg( mSRID ).arg( axis0 ).arg( OSRAxisEnumToName( orientation ) ).arg( mAxisInverted ) );
+ }
+
+ return mAxisInverted != 0;
+}
+
bool QgsCoordinateReferenceSystem::createFromWkt( QString theWkt )
{
mIsValidFlag = false;
diff --git a/src/core/qgscoordinatereferencesystem.h b/src/core/qgscoordinatereferencesystem.h
index b40e490..91965e1 100644
--- a/src/core/qgscoordinatereferencesystem.h
+++ b/src/core/qgscoordinatereferencesystem.h
@@ -308,6 +308,12 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
*/
bool geographicFlag() const;
+ /*! return if axis is inverted (eg. for WMS 1.3)
+ * @return bool Whether this is crs axis is inverted
+ * @note added in 1.9.90
+ */
+ bool axisInverted() const;
+
/*! Get the units that the projection is in
* @return QGis::UnitType that gives the units for the coordinate system
*/
@@ -434,6 +440,9 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
QString mValidationHint;
mutable QString mWkt;
+ //!Whether this is a coordinate system has inverted axis
+ mutable int mAxisInverted;
+
static CUSTOM_CRS_VALIDATION mCustomSrsValidation;
};
diff --git a/src/mapserver/qgsconfigparser.cpp b/src/mapserver/qgsconfigparser.cpp
index a726210..0d2ec15 100644
--- a/src/mapserver/qgsconfigparser.cpp
+++ b/src/mapserver/qgsconfigparser.cpp
@@ -444,11 +444,11 @@ QgsComposition* QgsConfigParser::createPrintComposition( const QString& composer
c->removeItem( currentMap ); delete currentMap; continue;
}
- //Change x- and y- of extent for WMS 1.3.0 and geographic coordinate systems
+ //Change x- and y- of extent for WMS 1.3.0 if axis inverted
QString version = parameterMap.value( "VERSION" );
if ( !version.isEmpty() )
{
- if ( mapRenderer && version == "1.3.0" && mapRenderer->destinationCrs().geographicFlag() )
+ if ( mapRenderer && version == "1.3.0" && mapRenderer->destinationCrs().axisInverted() )
{
//switch coordinates of extent
double tmp;
diff --git a/src/mapserver/qgswmsserver.cpp b/src/mapserver/qgswmsserver.cpp
index 637c02a..1de6a91 100644
--- a/src/mapserver/qgswmsserver.cpp
+++ b/src/mapserver/qgswmsserver.cpp
@@ -1120,9 +1120,9 @@ int QgsWMSServer::configureMapRender( const QPaintDevice* paintDevice ) const
}
mMapRenderer->setMapUnits( mapUnits );
- // Change x- and y- of BBOX for WMS 1.3.0 and geographic coordinate systems
+ // Change x- and y- of BBOX for WMS 1.3.0 if axis inverted
QString version = mParameterMap.value( "VERSION", "1.3.0" );
- if ( version == "1.3.0" && outputCRS.geographicFlag() )
+ if ( version == "1.3.0" && outputCRS.axisInverted() )
{
//switch coordinates of extent
double tmp;
diff --git a/src/providers/wms/qgswmsprovider.cpp b/src/providers/wms/qgswmsprovider.cpp
index d50ff57..671f79e 100644
--- a/src/providers/wms/qgswmsprovider.cpp
+++ b/src/providers/wms/qgswmsprovider.cpp
@@ -415,13 +415,13 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, i
cacheReply = 0;
}
- //according to the WMS spec for 1.3, the order of x - and y - coordinates is inverted for geographical CRS
+ //according to the WMS spec for 1.3, some CRS have inverted axis
bool changeXY = false;
if ( mCapabilities.version == "1.3.0" || mCapabilities.version == "1.3" )
{
//create CRS from string
QgsCoordinateReferenceSystem theSrs;
- if ( theSrs.createFromOgcWmsCrs( imageCrs ) && theSrs.geographicFlag() )
+ if ( theSrs.createFromOgcWmsCrs( imageCrs ) && theSrs.axisInverted() )
{
changeXY = true;
}
@@ -2908,7 +2908,7 @@ QStringList QgsWmsProvider::identifyAs( const QgsPoint& point, QString format )
{
//create CRS from string
QgsCoordinateReferenceSystem theSrs;
- if ( theSrs.createFromOgcWmsCrs( imageCrs ) && theSrs.geographicFlag() )
+ if ( theSrs.createFromOgcWmsCrs( imageCrs ) && theSrs.axisInverted() )
{
changeXY = true;
}
--
The Quantum GIS in Debian project
More information about the Pkg-grass-devel
mailing list