Opened 11 years ago

Closed 11 years ago

#2132 closed defect (fixed)

Golden Software Surfer 7 Georeferencing is incorrect

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

Description

Last year, a changeset was submitted which fixed the golden software 6 file formats (10814), but unfortunately it wasn't applied to the surfer 7 file format which has the exact same issue.

This can be fixed by replacing the GetGeoTransform? method in frmts/gsg/gs7bgdataset.cpp with the following snippet:

/************************************************************************/
/*                          GetGeoTransform()                           */
/************************************************************************/

CPLErr GS7BGDataset::GetGeoTransform( double *padfGeoTransform )
{
    if( padfGeoTransform == NULL )
        return CE_Failure;

    GS7BGRasterBand *poGRB = (GS7BGRasterBand *)GetRasterBand( 1 );

    if( poGRB == NULL )
    {
        padfGeoTransform[0] = 0;
        padfGeoTransform[1] = 1;
        padfGeoTransform[2] = 0;
        padfGeoTransform[3] = 0;
        padfGeoTransform[4] = 0;
        padfGeoTransform[5] = 1;
        return CE_Failure;
    }

    /* check if we have a PAM GeoTransform stored */
    CPLPushErrorHandler( CPLQuietErrorHandler );
    CPLErr eErr = GDALPamDataset::GetGeoTransform( padfGeoTransform );
    CPLPopErrorHandler();

    if( eErr == CE_None )
        return CE_None;

    /* calculate pixel size first */
    padfGeoTransform[1] = (poGRB->dfMaxX - poGRB->dfMinX)/(nRasterXSize - 1);
    padfGeoTransform[5] = (poGRB->dfMinY - poGRB->dfMaxY)/(nRasterYSize - 1);

    /* then calculate image origin */
    padfGeoTransform[0] = poGRB->dfMinX - padfGeoTransform[1] / 2;
    padfGeoTransform[3] = poGRB->dfMaxY - padfGeoTransform[5] / 2;

    /* tilt/rotation does not supported by the GS grids */
    padfGeoTransform[4] = 0.0;
    padfGeoTransform[2] = 0.0;


    return CE_None;
}

Attachments (1)

geogeotransform.cpp (1.5 KB) - added by ReedC 11 years ago.
Code to fix issue

Download all attachments as: .zip

Change History (2)

Changed 11 years ago by ReedC

Attachment: geogeotransform.cpp added

Code to fix issue

comment:1 Changed 11 years ago by dron

Cc: dron added
Resolution: fixed
Status: newclosed

Thanks for the patch, I have applied the fix both in trunk (r13479) and 1.5 branches (r13480).

Best regards, Andrey

Note: See TracTickets for help on using tickets.