Skip to content
Permalink
Browse files

Merge pull request #1081 from ahuarte47/Issue_9345

Bug #9345: fix calculation of axis ordering of CRS
  • Loading branch information
jef-n committed Jan 16, 2014
2 parents 2db44a5 + 2af29d1 commit e8b8e3a47feea3dcda0ca58cd81158aef726c0ae
Showing with 14 additions and 7 deletions.
  1. +14 −7 src/core/qgscoordinatereferencesystem.cpp
@@ -404,13 +404,20 @@ 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 ) );
Q_UNUSED( axis0 );
mAxisInverted = mGeoFlag ? OSREPSGTreatsAsLatLong( mCRS ) : OSREPSGTreatsAsNorthingEasting( mCRS );

// See GDAL-OGR: https://github.com/OSGeo/gdal/blob/trunk/gdal/ogr/ogrsf_frmts/gml/gmlutils.cpp#L322
if ( !mAxisInverted )
{
OGRSpatialReferenceH crs = OSRNewSpatialReference( NULL );

if ( OSRImportFromEPSGA( crs, mSRID ) == OGRERR_NONE )
{
mAxisInverted = mGeoFlag ? OSREPSGTreatsAsLatLong( crs ) : OSREPSGTreatsAsNorthingEasting( crs );
}
OSRDestroySpatialReference( crs );
}
QgsDebugMsg( QString( "srid:%1 inverted:%2" ).arg( mSRID ).arg( mAxisInverted ) );
}

return mAxisInverted != 0;

0 comments on commit e8b8e3a

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