Opened 14 years ago

Closed 5 years ago

#3648 closed defect (wontfix)

Empty ESRI datum names in gdal_datum.csv produce morphed values of "D"

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

Description

There are a few datums (rows) for which the ESRI_DATUM_NAME entry is empty in gdal_datum.csv. For these values, the datum name remapping in morphToESRI produces null strings which are eventually morphed to "D" (the truncated result of prepending "D_" to nothing).

I was able to resolve this by modifying the InitDatumMappingTable function (within ogr_srs_esri.cpp) to detect this case and supply an ESRI-style name by copying the EPSG name and massaging it to replace invalid chars with underbars. After subsequent morph code prepends "D_" the resulting names can be read by ArcMap. The modified code within InitDatumMappingTable reads as follows:

if( MAX(nEPSGNameField,MAX(nDatumCodeField,nESRINameField))

< nFieldCount

&& nMaxDatumMappings > nMappingCount+1 )

{

papszDatumMapping[nMappingCount*3+0] =

CPLStrdup( papszFields[nDatumCodeField] );

if ( (0 == papszFields[nESRINameField])

('\0' == *(papszFields[nESRINameField])) )

{

/* There are some rows in gdal_datum.csv that have */

/* no entry for ESRI_DATUM_NAME. For them, copy */

/* the EPSG datum name and massage it appropriately. */

/* Without this hack, datum name remapping will produce */

/* empty names that are eventually morphed into "D". */

papszDatumMapping[nMappingCount*3+1] =

CPLStrdup( papszFields[nEPSGNameField] );

OGREPSGDatumNameMassage( &(papszDatumMapping[nMappingCount*3+1]) );

}

else

{

/* Use table value if present */

papszDatumMapping[nMappingCount*3+1] =

CPLStrdup( papszFields[nESRINameField] );

}

papszDatumMapping[nMappingCount*3+2] =

CPLStrdup( papszFields[nEPSGNameField] );

OGREPSGDatumNameMassage( &(papszDatumMapping[nMappingCount*3+2]) );

nMappingCount++;

}

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, 5 years ago

Milestone: closed_because_of_github_migration
Resolution: wontfix
Status: newclosed

This ticket has been automatically closed because Trac is no longer used for GDAL bug tracking, since the project has migrated to GitHub. If you believe this ticket is still valid, you may file it to https://github.com/OSGeo/gdal/issues if it is not already reported there.

Note: See TracTickets for help on using tickets.