Opened 15 years ago

Closed 15 years ago

#2787 closed defect (fixed)

GTIFGetOGISDefn() doesn't retrieve the official value for the inverse flattening for WGS84

Reported by: Even Rouault Owned by: warmerdam
Priority: normal Milestone: 1.7.0
Component: OGR_SRS Version: unspecified
Severity: normal Keywords: geotiff wgs84 inverse flattening
Cc:

Description

Currently, the inverse flattening in the WKT for a WGS84 based projection from a GeoTIFF is not the official value of 298.257223563, but a computed value from the semi major and semi minor axes, whose value is 298.2572235629972 due to imprecision in numerical computation.

The commit to follow will add a test after the computation of the inverse flattening to detect if it is very close to the SRS_WGS84_INVFLATTENING value, in which case it returns it.

I also see that since r15993, we have the following snippet at line 350 of gt_wkt_srs.cpp :

    if( !pszSpheroidName )
      GTIFGetEllipsoidInfo( psDefn->Ellipsoid, &pszSpheroidName, NULL, NULL );
    else
    {
      GTIFKeyGet(hGTIF, GeogSemiMajorAxisGeoKey, &(psDefn->SemiMajor), 0, 1 );
      GTIFKeyGet(hGTIF, GeogInvFlatteningGeoKey, &dfInvFlattening, 0, 1 );
    }

I think this could be simplified like this :

    if( !pszSpheroidName )
      GTIFGetEllipsoidInfo( psDefn->Ellipsoid, &pszSpheroidName, NULL, NULL );

    GTIFKeyGet(hGTIF, GeogInvFlatteningGeoKey, &dfInvFlattening, 0, 1 );

as psDefn->SemiMajor is already set by GTIFGetDefn(), and I don't see any harm in retrieving the inverse flattening if it is set, but I won't change that as I may miss some subtelties.

Change History (1)

comment:1 by Even Rouault, 15 years ago

Milestone: 1.7.0
Resolution: fixed
Status: newclosed

Correction to make GeoTIFF driver return the official value of the inverse flattening of the WGS84 ellipsoid commited in trunk in r16109. Correction in gdal2tiles.py documentation in r16110. Corrections of WGS84 inverse flattening value in autotest suite in r16111. Test added in r16112

Note: See TracTickets for help on using tickets.