Skip to content
Permalink
Browse files
PROJ6: msOGRSpatialRef2ProjectionObj: avoid going through potentially…
… lossy PROJ4 strings
  • Loading branch information
rouault committed Oct 1, 2019
1 parent b22b085 commit 75860fd4ce207cec550977041c06425ad96b1b39
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
@@ -974,6 +974,26 @@ static int msOGRSpatialRef2ProjectionObj(OGRSpatialReferenceH hSRS,
return MS_SUCCESS;
}

#if PROJ_VERSION_MAJOR >= 6
// This could be done also in the < 6 case, but would be useless.
// Here this helps avoiding going through potentially lossy PROJ4 strings
const char* pszAuthName = OSRGetAuthorityName(hSRS, NULL);
if( pszAuthName && EQUAL(pszAuthName, "EPSG") )
{
const char* pszAuthCode = OSRGetAuthorityCode(hSRS, NULL);
if( pszAuthCode )
{
char szInitStr[32];
sprintf(szInitStr, "init=epsg:%d", atoi(pszAuthCode));

if( debug_flag )
msDebug( "AUTO = %s\n", szInitStr );

return msLoadProjectionString(proj, szInitStr) == 0 ? MS_SUCCESS : MS_FAILURE;
}
}
#endif

// Export OGR SRS to a PROJ4 string
char *pszProj = NULL;

@@ -324,8 +324,7 @@ def testESRIWKT(self):
def testWellKnownGEOGCS(self):
self.map.setWKTProjection('WGS84')
proj4 = self.map.getProjection()
assert proj4.find('+proj=longlat') != -1, proj4
assert proj4.find('+datum=WGS84') != -1, proj4
assert ('+proj=longlat' in proj4 and '+datum=WGS84' in proj4) or proj4 == '+init=epsg:4326', proj4
assert (mapscript.projectionObj(proj4)).getUnits() != mapscript.MS_METERS


0 comments on commit 75860fd

Please sign in to comment.