Opened 11 years ago

Closed 11 years ago

#4286 closed defect (fixed)

GeoTIFF CRS handling can create invalid WKT

Reported by: mpd Owned by: warmerdam
Priority: normal Milestone: 1.9.0
Component: GDAL_Raster Version: svn-trunk
Severity: normal Keywords:
Cc:

Description

From frmts/gtiff/gt_wkt_srs.cpp (starting at line 588 in the trunk, rev 23234):

if(!pszGeogName
strlen(pszGeogName) == 0)

{

CPLFree(pszGeogName); pszGeogName = CPLStrdup( pszDatumName );

}

if pszDatum name is NULL, or blank, then pszGeogName will in turn be a blank string. This blank string is then duplicated by SetGeogCS, instead of using "unnamed". The blank string is then skipped when writing WKT, leading to something like:

PROJCS[... , GEOGCS[, SPHEROID[...

i.e. square bracket followed by comma, which is not valid BNF.

Attachments (1)

2038-0-1pc.tif (3.7 KB ) - added by mpd 11 years ago.

Download all attachments as: .zip

Change History (4)

comment:1 by Even Rouault, 11 years ago

Could you attach a small file that demonstrates the issue ?

in reply to:  1 comment:2 by mpd, 11 years ago

Could you attach a small file that demonstrates the issue ?

I have attached the sample we were sent, but at 1% of the original resolution. The same problem occurs with this file.

Here is a snippet of the gdalinfo output:

Size is 33, 50
Coordinate System is:
PROJCS["Transverse Mercator",
    GEOGCS[,
        DATUM["unknown",
            SPHEROID["unnamed",6378137,298.257223563]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433],
        AUTHORITY["EPSG","4258"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",-1.325],
    PARAMETER["scale_factor",1],
    PARAMETER["false_easting",0],
    PARAMETER["false_northing",0],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]]]
Origin = (-5081.922073724641500,5639173.510509637200000)
Pixel Size = (305.259710425942560,-300.000273147858710)

Please note is that the problem only occurs if either the EPSG csv files are not available (which is what happens in our case), or if the datum is not found (which could theoretically happen in other cases).

by mpd, 11 years ago

Attachment: 2038-0-1pc.tif added

comment:3 by Even Rouault, 11 years ago

Component: defaultGDAL_Raster
Milestone: 1.9.0
Resolution: fixed
Status: newclosed

r23238 /trunk/gdal/frmts/gtiff/ (gt_citation.cpp gt_wkt_srs.cpp): GTiff: avoid setting empty GEOGCS citation in some cases (missing EPSG CSV files) (#4286)

Note: See TracTickets for help on using tickets.