Opened 14 years ago

Closed 6 years ago

#3652 closed defect (fixed)

GEOGCS name should morph for geographic as well as projected systems

Reported by: johncz711 Owned by: warmerdam
Priority: normal Milestone:
Component: OGR_SRS Version: 1.7.2
Severity: normal Keywords:
Cc:

Description

Within morphToESRI in ogr_srs_esri.cpp, the morphing/remapping of GEOGCS name values currently occurs only for GEOGCS found within PROJCS definitions. GEOGCS name morphing should occur for non-projected systems as well. Also (as with datum names in ticket 3651), the GEOGCS name morph needs to include the standard name morphing of extraneous characters to underbars.

These problems may be resolved by replacing the existing GEOGCS name morph/remap (found in the "final check names" section) with an expanded section located just prior to the current PROJCS-dependent case, as in the following example:

/* ------------------------------------------------------------ */

/* GEOGCS name should begin with "GCS_" and should use underscores */

/* instead of spaces. */

/* ------------------------------------------------------------ */

char* newGcsName = 0;

pszGcsName = GetAttrValue( "GEOGCS" );

if ( pszGcsName )

{

if( !EQUALN( pszGcsName, "GCS_", 4 ) )

{

newGcsName = (char *) CPLMalloc(strlen(pszGcsName) + 5);

if ( newGcsName )

{

strcpy( newGcsName, "GCS_" );

strcat( newGcsName, pszGcsName );

}

} /* end if need to add "GCS_" */

else

{

newGcsName = CPLStrdup( pszGcsName );

}

if ( newGcsName )

{

MorphNameToESRI( &newGcsName );

SetNewName( this, "GEOGCS", newGcsName );

CPLFree( newGcsName );

}

pszGcsName = GetAttrValue("GEOGCS" );

RemapGeogCSName(this, pszGcsName);

} /* end if GEOGCS found */

/* ------------------------------------------------------------ */

/* final check names */

/* ------------------------------------------------------------ */

if( poProjCSNodeChild )

pszProjCSName = poProjCSNodeChild->GetValue();

if( pszProjCSName )

{

pszProjection = GetAttrValue("PROJECTION");

if(pszProjection)

{

...

For this fix to work, an additional small change must also be made in the RemapGeogCSName function, so that its final section that morphs a GEOGCS name based on PROJCS name will operate only when a PROJCS exists. This change is in the final section of RemapGeogCSName:

if(ret < 0)

{

const char* pszProjCS = pOgr->GetAttrValue( "PROJCS" );

if ( pszProjCS ) /* can now be called within SRS with no PROJCS */

{

ret = RemapNamesBasedOnTwo( pOgr, pszProjCS, pszGeogCSName, (char)apszGcsNameMappingBasedOnProjCS, 3, (char)keyNamesG, 1);

}

}

A suitably modified copy of ogr_srs_esri.cpp is in the attached zip.

I have successfully used this suggested fix in a subset of OGR code recently added to my (non-ESRI-based) platform for the sole purpose of creating WKT and writing it as .prj files.

Attachments (1)

MOD_ogr_srs_esri.zip (13.8 KB ) - added by johncz711 14 years ago.

Download all attachments as: .zip

Change History (2)

by johncz711, 14 years ago

Attachment: MOD_ogr_srs_esri.zip added

comment:1 by Even Rouault, 6 years ago

Resolution: fixed
Status: newclosed

I assume this ticket is no longer valid

Note: See TracTickets for help on using tickets.