Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mitab/mitab.h
Original file line number Diff line number Diff line change
Expand Up @@ -1894,6 +1894,7 @@ GBool MITABExtractCoordSysBounds( const char * pszCoordSys,
int MITABCoordSys2TABProjInfo(const char * pszCoordSys, TABProjInfo *psProj);

typedef struct {
int nDatumEPSGCode;
int nMapInfoDatumID;
const char *pszOGCDatumName;
int nEllipsoid;
Expand Down
19 changes: 15 additions & 4 deletions mitab/mitab_coordsys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,15 @@ char *MITABSpatialRef2CoordSys( OGRSpatialReference * poSR )
double adfDatumParm[8] = {0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
int nEllipsoid=0;

int nDatumEPSGCode = -1;
const char *pszDatumAuthority = poSR->GetAuthorityName("DATUM");
const char *pszDatumCode = poSR->GetAuthorityCode("DATUM");

if (pszDatumCode && pszDatumAuthority && EQUAL(pszDatumAuthority, "EPSG"))
{
nDatumEPSGCode = atoi(pszDatumCode);
}

const char *pszWKTDatum = poSR->GetAttrValue("DATUM");

if( pszWKTDatum == NULL )
Expand Down Expand Up @@ -1202,16 +1211,18 @@ char *MITABSpatialRef2CoordSys( OGRSpatialReference * poSR )
}

/*-----------------------------------------------------------------
* We have a "real" datum name. Try to look it up and get the
* parameters. If we don't find it just use WGS84.
* We have a "real" datum name, and possibly an EPSG code for the
* datum. Try to look it up (using EPSG code first) and get the
* parameters. If we don't find it with either just use WGS84.
*----------------------------------------------------------------*/
else
{
int i;

for( i = 0; asDatumInfoList[i].nMapInfoDatumID != -1; i++ )
{
if( EQUAL(pszWKTDatum,asDatumInfoList[i].pszOGCDatumName) )
if ( (nDatumEPSGCode > 0 && asDatumInfoList[i].nDatumEPSGCode == nDatumEPSGCode) ||
EQUAL(pszWKTDatum,asDatumInfoList[i].pszOGCDatumName) )
{
nDatum = asDatumInfoList[i].nMapInfoDatumID;
break;
Expand All @@ -1221,7 +1232,7 @@ char *MITABSpatialRef2CoordSys( OGRSpatialReference * poSR )
if( nDatum == 0 )
nDatum = 104; /* WGS84 */
}

/*-----------------------------------------------------------------
* Translate the units
*----------------------------------------------------------------*/
Expand Down
Loading