Skip to content

Commit cdea40e

Browse files
committed
Internal libgeotiff: resync with OSGeo/libgeotiff#118
1 parent 05a70ea commit cdea40e

File tree

4 files changed

+55
-9
lines changed

4 files changed

+55
-9
lines changed

frmts/gtiff/gt_wkt_srs.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1397,7 +1397,8 @@ OGRSpatialReferenceH GTIFGetOGISDefnAsOSR(GTIF *hGTIF, GTIFDefn *psDefn)
13971397
for (; i < 10; i++)
13981398
adfParam[i] = 0.0;
13991399

1400-
// libgeotiff is unfortunately inconsistent. When it synthetizes the
1400+
#if LIBGEOTIFF_VERSION <= 1730
1401+
// libgeotiff <= 1.7.3 is unfortunately inconsistent. When it synthetizes the
14011402
// projection parameters from the EPSG ProjectedCRS code, it returns
14021403
// them normalized in degrees. But when it gets them from
14031404
// ProjCoordTransGeoKey and other Proj....GeoKey's it return them in
@@ -1418,6 +1419,20 @@ OGRSpatialReferenceH GTIFGetOGISDefnAsOSR(GTIF *hGTIF, GTIFDefn *psDefn)
14181419
adfParam[2] *= psDefn->UOMAngleInDegrees;
14191420
adfParam[3] *= psDefn->UOMAngleInDegrees;
14201421
}
1422+
#else
1423+
// If GTIFF_READ_ANGULAR_PARAMS_IN_DEGREE=YES (non-nominal case), undo
1424+
// the conversion to degrees, that has been done by libgeotiff > 1.7.3
1425+
if (GDALGTIFKeyGetSHORT(hGTIF, ProjCoordTransGeoKey, &tmp, 0, 1) &&
1426+
psDefn->UOMAngleInDegrees != 0 && psDefn->UOMAngleInDegrees != 1 &&
1427+
CPLTestBool(CPLGetConfigOption(
1428+
"GTIFF_READ_ANGULAR_PARAMS_IN_DEGREE", "NO")))
1429+
{
1430+
adfParam[0] /= psDefn->UOMAngleInDegrees;
1431+
adfParam[1] /= psDefn->UOMAngleInDegrees;
1432+
adfParam[2] /= psDefn->UOMAngleInDegrees;
1433+
adfParam[3] /= psDefn->UOMAngleInDegrees;
1434+
}
1435+
#endif
14211436

14221437
/* --------------------------------------------------------------------
14231438
*/

frmts/gtiff/libgeotiff/geo_normalize.c

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,15 +2241,16 @@ static void GTIFFetchProjParms( GTIF * psGTIF, GTIFDefn * psDefn )
22412241
break;
22422242
}
22432243

2244+
for( int iParam = 0; iParam < psDefn->nParms; iParam++ )
2245+
{
2246+
switch( psDefn->ProjParmId[iParam] )
2247+
{
2248+
22442249
/* -------------------------------------------------------------------- */
22452250
/* Normalize any linear parameters into meters. In GeoTIFF */
22462251
/* the linear projection parameter tags are normally in the */
22472252
/* units of the coordinate system described. */
22482253
/* -------------------------------------------------------------------- */
2249-
for( int iParam = 0; iParam < psDefn->nParms; iParam++ )
2250-
{
2251-
switch( psDefn->ProjParmId[iParam] )
2252-
{
22532254
case ProjFalseEastingGeoKey:
22542255
case ProjFalseNorthingGeoKey:
22552256
case ProjFalseOriginEastingGeoKey:
@@ -2263,6 +2264,30 @@ static void GTIFFetchProjParms( GTIF * psGTIF, GTIFDefn * psDefn )
22632264
}
22642265
break;
22652266

2267+
/* -------------------------------------------------------------------- */
2268+
/* Normalize any angular parameters into degrees. In GeoTIFF */
2269+
/* the angular projection parameter tags are normally in the */
2270+
/* units of GeogAngularUnit. Note: this conversion is only done */
2271+
/* since libgeotiff 1.7.4 */
2272+
/* -------------------------------------------------------------------- */
2273+
2274+
case ProjStdParallel1GeoKey:
2275+
case ProjStdParallel2GeoKey:
2276+
case ProjNatOriginLongGeoKey:
2277+
case ProjNatOriginLatGeoKey:
2278+
case ProjFalseOriginLongGeoKey:
2279+
case ProjFalseOriginLatGeoKey:
2280+
case ProjCenterLongGeoKey:
2281+
case ProjCenterLatGeoKey:
2282+
case ProjStraightVertPoleLongGeoKey:
2283+
case ProjRectifiedGridAngleGeoKey:
2284+
if( psDefn->UOMAngleInDegrees != 0
2285+
&& psDefn->UOMAngleInDegrees != 1.0 )
2286+
{
2287+
psDefn->ProjParm[iParam] *= psDefn->UOMAngleInDegrees;
2288+
}
2289+
break;
2290+
22662291
default:
22672292
break;
22682293
}

frmts/gtiff/libgeotiff/geo_normalize.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,15 @@ typedef struct {
121121
int nParms;
122122

123123
/** Projection parameter value. The identify of this parameter
124-
is established from the corresponding entry in ProjParmId. The
125-
value will be measured in meters, or decimal degrees if it is a
126-
linear or angular measure. */
124+
is established from the corresponding entry in ProjParmId.
125+
In GeoTIFF keys, the values of the projection parameters are expressed
126+
in the units of ProjLinearUnitsGeoKey (for linear measures) or
127+
GeogAngularUnitsGeoKey (for angular measures).
128+
However, the value returned in ProjParam[] will be normalized to meters
129+
or decimal degrees.
130+
Note: until libgeotiff 1.7.3, the conversion to degrees for angular
131+
measures was *not* done when ProjCoordTransGeoKey is present.
132+
*/
127133
double ProjParm[MAX_GTIF_PROJPARMS];
128134

129135
/** Projection parameter identifier. For example ProjFalseEastingGeoKey.

frmts/gtiff/libgeotiff/geotiff.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
#define GEOTIFF_SPEC_1_1_MINOR_REVISION 1
4848

4949
/* Library version */
50-
#define LIBGEOTIFF_VERSION 1710
50+
#define LIBGEOTIFF_VERSION 1740
5151

5252
#include "geo_config.h"
5353
#include "geokeys.h"

0 commit comments

Comments
 (0)