Skip to content

Commit

Permalink
Merge pull request #6913 from OSGeo/backport-6906-to-release/3.6
Browse files Browse the repository at this point in the history
[Backport release/3.6] GTiff: SRS reader: do not emit warning when reading a projected CRS…
  • Loading branch information
rouault authored Dec 13, 2022
2 parents 532dfdc + 5def4c9 commit f25aee2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
Binary file added autotest/gcore/data/gtiff/epsg_2193_override.tif
Binary file not shown.
9 changes: 9 additions & 0 deletions autotest/gcore/tiff_srs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1203,3 +1203,12 @@ def test_tiff_srs_try_write_derived_projected():
ds = None

gdal.Unlink(tmpfile)


def test_tiff_srs_epsg_2193_override():

ds = gdal.Open("data/gtiff/epsg_2193_override.tif")
gdal.ErrorReset()
srs = ds.GetSpatialRef()
assert gdal.GetLastErrorMsg() == "", srs.ExportToWkt(["FORMAT=WKT2_2019"])
assert srs.GetAuthorityCode(None) == "2193"
7 changes: 7 additions & 0 deletions frmts/gtiff/gt_wkt_srs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1518,9 +1518,16 @@ OGRSpatialReferenceH GTIFGetOGISDefnAsOSR( GTIF *hGTIF, GTIFDefn * psDefn )
if( psDefn->Model == ModelTypeProjected && psDefn->PCS != KvUserDefined &&
!bGotFromEPSG )
{
OGRSpatialReference oSRSTest(oSRS);
OGRSpatialReference oSRSTmp;

const bool bPCSCodeValid = oSRSTmp.importFromEPSG(psDefn->PCS) == OGRERR_NONE;
oSRSTmp.SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);

// Force axis to avoid issues with SRS with northing, easting order
oSRSTest.SetAxes(nullptr, "X", OAO_East, "Y", OAO_North);
oSRSTmp.SetAxes(nullptr, "X", OAO_East, "Y", OAO_North);

const std::string osGTiffSRSSource = CPLGetConfigOption("GTIFF_SRS_SOURCE", "");
const char* const apszOptions[] = { "IGNORE_DATA_AXIS_TO_SRS_AXIS_MAPPING=YES", nullptr };
if( !bHasWarnedInconsistentGeogCRSEPSG &&
Expand Down

0 comments on commit f25aee2

Please sign in to comment.