Skip to content

Commit 2af29d1

Browse files
committed
#9345: fix axis invert calculation
1 parent a31ebb4 commit 2af29d1

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/core/qgscoordinatereferencesystem.cpp

+14-7
Original file line numberDiff line numberDiff line change
@@ -404,13 +404,20 @@ bool QgsCoordinateReferenceSystem::axisInverted() const
404404
{
405405
if ( mAxisInverted == -1 )
406406
{
407-
OGRAxisOrientation orientation;
408-
const char *axis0 = OSRGetAxis( mCRS, mGeoFlag ? "GEOGCS" : "PROJCS", 0, &orientation );
409-
mAxisInverted = mGeoFlag
410-
? ( orientation == OAO_East || orientation == OAO_West || orientation == OAO_Other )
411-
: ( orientation == OAO_North || orientation == OAO_South );
412-
QgsDebugMsg( QString( "srid:%1 axis0:%2 orientation:%3 inverted:%4" ).arg( mSRID ).arg( axis0 ).arg( OSRAxisEnumToName( orientation ) ).arg( mAxisInverted ) );
413-
Q_UNUSED( axis0 );
407+
mAxisInverted = mGeoFlag ? OSREPSGTreatsAsLatLong( mCRS ) : OSREPSGTreatsAsNorthingEasting( mCRS );
408+
409+
// See GDAL-OGR: https://github.com/OSGeo/gdal/blob/trunk/gdal/ogr/ogrsf_frmts/gml/gmlutils.cpp#L322
410+
if ( !mAxisInverted )
411+
{
412+
OGRSpatialReferenceH crs = OSRNewSpatialReference( NULL );
413+
414+
if ( OSRImportFromEPSGA( crs, mSRID ) == OGRERR_NONE )
415+
{
416+
mAxisInverted = mGeoFlag ? OSREPSGTreatsAsLatLong( crs ) : OSREPSGTreatsAsNorthingEasting( crs );
417+
}
418+
OSRDestroySpatialReference( crs );
419+
}
420+
QgsDebugMsg( QString( "srid:%1 inverted:%2" ).arg( mSRID ).arg( mAxisInverted ) );
414421
}
415422

416423
return mAxisInverted != 0;

0 commit comments

Comments
 (0)