@@ -404,20 +404,23 @@ bool QgsCoordinateReferenceSystem::axisInverted() const
404
404
{
405
405
if ( mAxisInverted == -1 )
406
406
{
407
- mAxisInverted = mGeoFlag ? OSREPSGTreatsAsLatLong ( mCRS ) : OSREPSGTreatsAsNorthingEasting ( mCRS );
407
+ OGRAxisOrientation orientation;
408
+ OSRGetAxis ( mCRS , OSRIsGeographic ( mCRS ) ? " GEOGCS" : " PROJCS" , 0 , &orientation );
408
409
409
- // See GDAL-OGR: https://github.com/OSGeo/gdal/blob/trunk/gdal/ogr/ogrsf_frmts/gml/gmlutils.cpp#L322
410
- if ( ! mAxisInverted )
410
+ // If axis orientation is unknown, try again with OSRImportFromEPSGA for EPSG crs
411
+ if ( orientation == OAO_Other && mAuthId . startsWith ( " EPSG: " , Qt::CaseInsensitive ) )
411
412
{
412
413
OGRSpatialReferenceH crs = OSRNewSpatialReference ( NULL );
413
414
414
- if ( OSRImportFromEPSGA ( crs, mSRID ) == OGRERR_NONE )
415
+ if ( OSRImportFromEPSGA ( crs, mAuthId . mid ( 5 ). toInt () ) == OGRERR_NONE )
415
416
{
416
- mAxisInverted = mGeoFlag ? OSREPSGTreatsAsLatLong ( crs ) : OSREPSGTreatsAsNorthingEasting ( crs );
417
+ OSRGetAxis ( crs, OSRIsGeographic ( crs ) ? " GEOGCS " : " PROJCS " , 0 , &orientation );
417
418
}
419
+
418
420
OSRDestroySpatialReference ( crs );
419
421
}
420
- QgsDebugMsg ( QString ( " srid:%1 inverted:%2" ).arg ( mSRID ).arg ( mAxisInverted ) );
422
+
423
+ mAxisInverted = orientation == OAO_North;
421
424
}
422
425
423
426
return mAxisInverted != 0 ;
@@ -822,9 +825,7 @@ long QgsCoordinateReferenceSystem::srsid() const
822
825
823
826
long QgsCoordinateReferenceSystem::postgisSrid () const
824
827
{
825
-
826
828
return mSRID ;
827
-
828
829
}
829
830
830
831
QString QgsCoordinateReferenceSystem::authid () const
@@ -1731,9 +1732,7 @@ int QgsCoordinateReferenceSystem::syncDb()
1731
1732
char *psz = ba.data ();
1732
1733
OGRErr ogrErr = OSRImportFromWkt ( crs, &psz );
1733
1734
if ( ogrErr != OGRERR_NONE )
1734
- {
1735
1735
continue ;
1736
- }
1737
1736
1738
1737
if ( OSRExportToProj4 ( crs, &psz ) != OGRERR_NONE )
1739
1738
continue ;
@@ -1744,9 +1743,7 @@ int QgsCoordinateReferenceSystem::syncDb()
1744
1743
CPLFree ( psz );
1745
1744
1746
1745
if ( proj4.isEmpty () )
1747
- {
1748
1746
continue ;
1749
- }
1750
1747
1751
1748
sql = QString ( " SELECT parameters,noupdate FROM tbl_srs WHERE auth_name='EPSG' AND auth_id='%1'" ).arg ( it.key () );
1752
1749
if ( sqlite3_prepare ( database, sql.toAscii (), sql.size (), &select, &tail ) != SQLITE_OK )
0 commit comments