Skip to content
Permalink
Browse files

Clean up handling of inverted axis for CRS, fix detachment issue

(cherry-picked from 6dac8e1)
  • Loading branch information
nyalldawson committed Jul 26, 2016
1 parent 17d5ffc commit e27d30fa0e2138a0d971fd170740c7d6373a717a
Showing with 15 additions and 6 deletions.
  1. +9 −5 src/core/qgscoordinatereferencesystem.cpp
  2. +6 −1 src/core/qgscoordinatereferencesystem_p.h
@@ -238,9 +238,12 @@ bool QgsCoordinateReferenceSystem::createFromOgcWmsCrs( const QString& theCrs )
if ( wmsCrs.compare( "CRS:84", Qt::CaseInsensitive ) == 0 ||
wmsCrs.compare( "OGC:CRS84", Qt::CaseInsensitive ) == 0 )
{
d.detach();
createFromOgcWmsCrs( "EPSG:4326" );
d->mAxisInverted = 0;

d.detach();
d->mAxisInverted = false;
d->mAxisInvertedDirty = false;

return d->mIsValid;
}

@@ -337,7 +340,7 @@ bool QgsCoordinateReferenceSystem::loadFromDb( const QString& db, const QString&
d->mSRID = QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( myPreparedStatement, 5 ) ) ).toLong() ;
d->mAuthId = QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( myPreparedStatement, 6 ) ) );
d->mIsGeographic = QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( myPreparedStatement, 7 ) ) ).toInt() != 0;
d->mAxisInverted = -1;
d->mAxisInvertedDirty = true;

if ( d->mSrsId >= USER_CRS_START_ID && d->mAuthId.isEmpty() )
{
@@ -367,7 +370,7 @@ bool QgsCoordinateReferenceSystem::loadFromDb( const QString& db, const QString&

bool QgsCoordinateReferenceSystem::axisInverted() const
{
if ( d->mAxisInverted == -1 )
if ( d->mAxisInvertedDirty )
{
OGRAxisOrientation orientation;
OSRGetAxis( d->mCRS, OSRIsGeographic( d->mCRS ) ? "GEOGCS" : "PROJCS", 0, &orientation );
@@ -386,9 +389,10 @@ bool QgsCoordinateReferenceSystem::axisInverted() const
}

d->mAxisInverted = orientation == OAO_North;
d->mAxisInvertedDirty = false;
}

return d->mAxisInverted != 0;
return d->mAxisInverted;
}

bool QgsCoordinateReferenceSystem::createFromWkt( const QString &theWkt )
@@ -49,6 +49,7 @@ class QgsCoordinateReferenceSystemPrivate : public QSharedData
, mSRID( 0 )
, mIsValid( 0 )
, mCRS( OSRNewSpatialReference( nullptr ) )
, mAxisInvertedDirty( false )
, mAxisInverted( false )
{
}
@@ -68,6 +69,7 @@ class QgsCoordinateReferenceSystemPrivate : public QSharedData
, mValidationHint( other.mValidationHint )
, mWkt( other.mWkt )
, mProj4( other.mProj4 )
, mAxisInvertedDirty( other.mAxisInvertedDirty )
, mAxisInverted( other.mAxisInverted )
{
if ( mIsValid )
@@ -114,8 +116,11 @@ class QgsCoordinateReferenceSystemPrivate : public QSharedData
mutable QString mWkt;
mutable QString mProj4;

//! True if presence of an inverted axis needs to be recaculated
mutable bool mAxisInvertedDirty;

//! Whether this is a coordinate system has inverted axis
mutable int mAxisInverted;
mutable bool mAxisInverted;

};

0 comments on commit e27d30f

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