Skip to content

Commit

Permalink
gdalsrsinfo: emit message when replacement of deprecated CRS occurs, …
Browse files Browse the repository at this point in the history
…with hint to set OSR_USE_NON_DEPRECATED=NO configuration option to avoid that (fixes #5106)
  • Loading branch information
rouault committed Jan 14, 2022
1 parent d27ed96 commit be52265
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion apps/gdalsrsinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,12 +379,33 @@ bool FindSRS( const char *pszInput, OGRSpatialReference &oSRS )

const OGRErr eErr = oSRS.SetFromUserInput( pszInput );

if( eErr != OGRERR_NONE ) {
if( eErr != OGRERR_NONE ) {
CPLDebug( "gdalsrsinfo", "did not get SRS from user input" );
}
else {
CPLDebug( "gdalsrsinfo", "got SRS from user input" );
bGotSRS = true;

if( CPLGetConfigOption("OSR_USE_NON_DEPRECATED", nullptr) == nullptr )
{
const char* pszAuthName = oSRS.GetAuthorityName(nullptr);
const char* pszAuthCode = oSRS.GetAuthorityCode(nullptr);

CPLConfigOptionSetter oSetter("OSR_USE_NON_DEPRECATED", "NO", false);
OGRSpatialReference oSRS2;
oSRS2.SetFromUserInput( pszInput );
const char* pszAuthCode2 = oSRS2.GetAuthorityCode(nullptr);
if( pszAuthName && pszAuthCode &&
pszAuthCode2 &&
!EQUAL(pszAuthCode, pszAuthCode2) )
{
printf("CRS %s is deprecated, and the following output "
"will use its non-deprecated replacement %s:%s.\n"
"To use the original CRS, set the OSR_USE_NON_DEPRECATED "
"configuration option to NO.\n",
pszInput, pszAuthName, pszAuthCode);
}
}
}
}

Expand Down

0 comments on commit be52265

Please sign in to comment.