Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport release/3.6] GTiff: SRS reader: do not emit warning when reading a projected CRS… #6913

Merged
merged 1 commit into from Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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
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