104
104
105
105
CPL_INLINE static void CPL_IGNORE_RET_VAL_INT (CPL_UNUSED int unused ) {}
106
106
107
+ /************************************************************************/
108
+ /* GTIFKeyGetSSHORT() */
109
+ /************************************************************************/
110
+
111
+ // Geotiff SHORT keys are supposed to be unsigned, but geo_normalize interface
112
+ // uses signed short...
113
+ static int GTIFKeyGetSSHORT ( GTIF * gtif , geokey_t key , short * pnVal )
114
+ {
115
+ unsigned short sVal ;
116
+ if ( GTIFKeyGetSHORT (gtif , key , & sVal , 0 , 1 ) == 1 )
117
+ {
118
+ memcpy (pnVal , & sVal , 2 );
119
+ return 1 ;
120
+ }
121
+ return 0 ;
122
+ }
123
+
107
124
/************************************************************************/
108
125
/* GTIFGetPCSInfo() */
109
126
/************************************************************************/
@@ -1641,59 +1658,6 @@ int GTIFGetProjTRFInfo( /* Conversion code */
1641
1658
return ret ;
1642
1659
}
1643
1660
1644
- /************************************************************************/
1645
- /* GTIFKeyGetInternal() */
1646
- /************************************************************************/
1647
-
1648
- static int GTIFKeyGetInternal ( GTIF * psGTIF , geokey_t key ,
1649
- void * pData ,
1650
- int nIndex ,
1651
- int nCount ,
1652
- tagtype_t expected_tagtype )
1653
- {
1654
- tagtype_t tagtype ;
1655
- if ( !GTIFKeyInfo (psGTIF , key , NULL , & tagtype ) )
1656
- return 0 ;
1657
- if ( tagtype != expected_tagtype )
1658
- {
1659
- if ( psGTIF -> gt_error_callback )
1660
- {
1661
- psGTIF -> gt_error_callback (
1662
- psGTIF ,
1663
- LIBGEOTIFF_WARNING ,
1664
- "Expected key %s to be of type %s. Got %s" ,
1665
- GTIFKeyName (key ), GTIFTypeName (expected_tagtype ),
1666
- GTIFTypeName (tagtype ));
1667
- }
1668
- return 0 ;
1669
- }
1670
- return GTIFKeyGet ( psGTIF , key , pData , nIndex , nCount );
1671
- }
1672
-
1673
- /************************************************************************/
1674
- /* GTIFKeyGetSHORT() */
1675
- /************************************************************************/
1676
-
1677
- static int GTIFKeyGetSHORT ( GTIF * psGTIF , geokey_t key ,
1678
- short * pnVal ,
1679
- int nIndex ,
1680
- int nCount )
1681
- {
1682
- return GTIFKeyGetInternal (psGTIF , key , pnVal , nIndex , nCount , TYPE_SHORT );
1683
- }
1684
-
1685
- /************************************************************************/
1686
- /* GDALGTIFKeyGetDOUBLE() */
1687
- /************************************************************************/
1688
-
1689
- static int GTIFKeyGetDOUBLE ( GTIF * psGTIF , geokey_t key ,
1690
- double * pdfVal ,
1691
- int nIndex ,
1692
- int nCount )
1693
- {
1694
- return GTIFKeyGetInternal (psGTIF , key , pdfVal , nIndex , nCount , TYPE_DOUBLE );
1695
- }
1696
-
1697
1661
/************************************************************************/
1698
1662
/* GTIFFetchProjParms() */
1699
1663
/* */
@@ -2488,21 +2452,21 @@ int GTIFGetDefn( GTIF * psGTIF, GTIFDefn * psDefn )
2488
2452
/* -------------------------------------------------------------------- */
2489
2453
/* Try to get the overall model type. */
2490
2454
/* -------------------------------------------------------------------- */
2491
- GTIFKeyGetSHORT (psGTIF ,GTModelTypeGeoKey ,& (psDefn -> Model ), 0 , 1 );
2455
+ GTIFKeyGetSSHORT (psGTIF ,GTModelTypeGeoKey ,& (psDefn -> Model ));
2492
2456
2493
2457
/* -------------------------------------------------------------------- */
2494
2458
/* Extract the Geog units. */
2495
2459
/* -------------------------------------------------------------------- */
2496
2460
nGeogUOMLinear = 9001 ; /* Linear_Meter */
2497
- if ( GTIFKeyGetSHORT (psGTIF , GeogLinearUnitsGeoKey , & nGeogUOMLinear , 0 , 1 ) == 1 )
2461
+ if ( GTIFKeyGetSSHORT (psGTIF , GeogLinearUnitsGeoKey , & nGeogUOMLinear ) == 1 )
2498
2462
{
2499
2463
psDefn -> UOMLength = nGeogUOMLinear ;
2500
2464
}
2501
2465
2502
2466
/* -------------------------------------------------------------------- */
2503
2467
/* Try to get a PCS. */
2504
2468
/* -------------------------------------------------------------------- */
2505
- if ( GTIFKeyGetSHORT (psGTIF ,ProjectedCSTypeGeoKey , & (psDefn -> PCS ), 0 , 1 ) == 1
2469
+ if ( GTIFKeyGetSSHORT (psGTIF ,ProjectedCSTypeGeoKey , & (psDefn -> PCS )) == 1
2506
2470
&& psDefn -> PCS != KvUserDefined )
2507
2471
{
2508
2472
/*
@@ -2535,7 +2499,7 @@ int GTIFGetDefn( GTIF * psGTIF, GTIFDefn * psDefn )
2535
2499
/* If the Proj_ code is specified directly, use that. */
2536
2500
/* -------------------------------------------------------------------- */
2537
2501
if ( psDefn -> ProjCode == KvUserDefined )
2538
- GTIFKeyGetSHORT (psGTIF , ProjectionGeoKey , & (psDefn -> ProjCode ), 0 , 1 );
2502
+ GTIFKeyGetSSHORT (psGTIF , ProjectionGeoKey , & (psDefn -> ProjCode ));
2539
2503
2540
2504
if ( psDefn -> ProjCode != KvUserDefined )
2541
2505
{
@@ -2566,7 +2530,7 @@ int GTIFGetDefn( GTIF * psGTIF, GTIFDefn * psDefn )
2566
2530
/* Try to get a GCS. If found, it will override any implied by */
2567
2531
/* the PCS. */
2568
2532
/* -------------------------------------------------------------------- */
2569
- GTIFKeyGetSHORT (psGTIF , GeographicTypeGeoKey , & (psDefn -> GCS ), 0 , 1 );
2533
+ GTIFKeyGetSSHORT (psGTIF , GeographicTypeGeoKey , & (psDefn -> GCS ));
2570
2534
if ( psDefn -> GCS < 1 || psDefn -> GCS >= KvUserDefined )
2571
2535
psDefn -> GCS = KvUserDefined ;
2572
2536
@@ -2584,7 +2548,7 @@ int GTIFGetDefn( GTIF * psGTIF, GTIFDefn * psDefn )
2584
2548
/* Handle the GCS angular units. GeogAngularUnitsGeoKey */
2585
2549
/* overrides the GCS or PCS setting. */
2586
2550
/* -------------------------------------------------------------------- */
2587
- GTIFKeyGetSHORT (psGTIF , GeogAngularUnitsGeoKey , & (psDefn -> UOMAngle ), 0 , 1 );
2551
+ GTIFKeyGetSSHORT (psGTIF , GeogAngularUnitsGeoKey , & (psDefn -> UOMAngle ));
2588
2552
if ( psDefn -> UOMAngle != KvUserDefined )
2589
2553
{
2590
2554
GTIFGetUOMAngleInfoEx ( psGTIF -> pj_context ,
@@ -2596,7 +2560,7 @@ int GTIFGetDefn( GTIF * psGTIF, GTIFDefn * psDefn )
2596
2560
/* Check for a datum setting, and then use the datum to derive */
2597
2561
/* an ellipsoid. */
2598
2562
/* -------------------------------------------------------------------- */
2599
- GTIFKeyGetSHORT (psGTIF , GeogGeodeticDatumGeoKey , & (psDefn -> Datum ), 0 , 1 );
2563
+ GTIFKeyGetSSHORT (psGTIF , GeogGeodeticDatumGeoKey , & (psDefn -> Datum ));
2600
2564
2601
2565
if ( psDefn -> Datum != KvUserDefined )
2602
2566
{
@@ -2608,7 +2572,7 @@ int GTIFGetDefn( GTIF * psGTIF, GTIFDefn * psDefn )
2608
2572
/* Check for an explicit ellipsoid. Use the ellipsoid to */
2609
2573
/* derive the ellipsoid characteristics, if possible. */
2610
2574
/* -------------------------------------------------------------------- */
2611
- GTIFKeyGetSHORT (psGTIF , GeogEllipsoidGeoKey , & (psDefn -> Ellipsoid ), 0 , 1 );
2575
+ GTIFKeyGetSSHORT (psGTIF , GeogEllipsoidGeoKey , & (psDefn -> Ellipsoid ));
2612
2576
2613
2577
if ( psDefn -> Ellipsoid != KvUserDefined )
2614
2578
{
@@ -2638,7 +2602,7 @@ int GTIFGetDefn( GTIF * psGTIF, GTIFDefn * psDefn )
2638
2602
/* -------------------------------------------------------------------- */
2639
2603
/* Get the prime meridian info. */
2640
2604
/* -------------------------------------------------------------------- */
2641
- GTIFKeyGetSHORT (psGTIF , GeogPrimeMeridianGeoKey , & (psDefn -> PM ), 0 , 1 );
2605
+ GTIFKeyGetSSHORT (psGTIF , GeogPrimeMeridianGeoKey , & (psDefn -> PM ));
2642
2606
2643
2607
if ( psDefn -> PM != KvUserDefined )
2644
2608
{
@@ -2669,7 +2633,7 @@ int GTIFGetDefn( GTIF * psGTIF, GTIFDefn * psDefn )
2669
2633
/* but these are very rarely not decimal degrees for actual */
2670
2634
/* file coordinates. */
2671
2635
/* -------------------------------------------------------------------- */
2672
- GTIFKeyGetSHORT (psGTIF ,ProjLinearUnitsGeoKey ,& (psDefn -> UOMLength ), 0 , 1 );
2636
+ GTIFKeyGetSSHORT (psGTIF ,ProjLinearUnitsGeoKey ,& (psDefn -> UOMLength ));
2673
2637
2674
2638
if ( psDefn -> UOMLength != KvUserDefined )
2675
2639
{
@@ -2685,8 +2649,8 @@ int GTIFGetDefn( GTIF * psGTIF, GTIFDefn * psDefn )
2685
2649
/* -------------------------------------------------------------------- */
2686
2650
/* Handle a variety of user defined transform types. */
2687
2651
/* -------------------------------------------------------------------- */
2688
- if ( GTIFKeyGetSHORT (psGTIF ,ProjCoordTransGeoKey ,
2689
- & (psDefn -> CTProjection ), 0 , 1 ) == 1 )
2652
+ if ( GTIFKeyGetSSHORT (psGTIF ,ProjCoordTransGeoKey ,
2653
+ & (psDefn -> CTProjection )) == 1 )
2690
2654
{
2691
2655
GTIFFetchProjParms ( psGTIF , psDefn );
2692
2656
}
0 commit comments