LCOV - code coverage report
Current view: top level - frmts/gtiff/libgeotiff - geo_extra.c (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 69 137 50.4 %
Date: 2024-11-21 22:18:42 Functions: 2 4 50.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  * $Id$
       3             :  *
       4             :  * Project:  libgeotiff
       5             :  * Purpose:  Code to normalize a few common PCS values
       6             :  * Author:   Frank Warmerdam, warmerda@home.com
       7             :  *
       8             :  ******************************************************************************
       9             :  * Copyright (c) 1999, Frank Warmerdam
      10             :  *
      11             :  * SPDX-License-Identifier: MIT
      12             :  *****************************************************************************/
      13             : 
      14             : #include <stddef.h>
      15             : 
      16             : #include "geo_normalize.h"
      17             : #include "geovalues.h"
      18             : 
      19             : static const int StatePlaneTable[] =
      20             : {
      21             :     PCS_NAD83_Alabama_East,   Proj_Alabama_CS83_East,
      22             :     PCS_NAD83_Alabama_West,   Proj_Alabama_CS83_West,
      23             : 
      24             :     PCS_NAD83_Alaska_zone_1,    Proj_Alaska_CS83_1,
      25             :     PCS_NAD83_Alaska_zone_2,    Proj_Alaska_CS83_2,
      26             :     PCS_NAD83_Alaska_zone_3,    Proj_Alaska_CS83_3,
      27             :     PCS_NAD83_Alaska_zone_4,    Proj_Alaska_CS83_4,
      28             :     PCS_NAD83_Alaska_zone_5,    Proj_Alaska_CS83_5,
      29             :     PCS_NAD83_Alaska_zone_6,    Proj_Alaska_CS83_6,
      30             :     PCS_NAD83_Alaska_zone_7,    Proj_Alaska_CS83_7,
      31             :     PCS_NAD83_Alaska_zone_8,    Proj_Alaska_CS83_8,
      32             :     PCS_NAD83_Alaska_zone_9,    Proj_Alaska_CS83_9,
      33             :     PCS_NAD83_Alaska_zone_10,   Proj_Alaska_CS83_10,
      34             : 
      35             :     PCS_NAD83_California_1,   Proj_California_CS83_1,
      36             :     PCS_NAD83_California_2,   Proj_California_CS83_2,
      37             :     PCS_NAD83_California_3,   Proj_California_CS83_3,
      38             :     PCS_NAD83_California_4,   Proj_California_CS83_4,
      39             :     PCS_NAD83_California_5,   Proj_California_CS83_5,
      40             :     PCS_NAD83_California_6,   Proj_California_CS83_6,
      41             : 
      42             :     PCS_NAD83_Arizona_East,   Proj_Arizona_CS83_east,
      43             :     PCS_NAD83_Arizona_Central,    Proj_Arizona_CS83_Central,
      44             :     PCS_NAD83_Arizona_West,   Proj_Arizona_CS83_west,
      45             : 
      46             :     PCS_NAD83_Arkansas_North,   Proj_Arkansas_CS83_North,
      47             :     PCS_NAD83_Arkansas_South,   Proj_Arkansas_CS83_South,
      48             : 
      49             :     PCS_NAD83_Colorado_North,   Proj_Colorado_CS83_North,
      50             :     PCS_NAD83_Colorado_Central,   Proj_Colorado_CS83_Central,
      51             :     PCS_NAD83_Colorado_South,   Proj_Colorado_CS83_South,
      52             : 
      53             :     PCS_NAD83_Connecticut,    Proj_Connecticut_CS83,
      54             : 
      55             :     PCS_NAD83_Delaware,     Proj_Delaware_CS83,
      56             : 
      57             :     PCS_NAD83_Florida_East,   Proj_Florida_CS83_East,
      58             :     PCS_NAD83_Florida_North,    Proj_Florida_CS83_North,
      59             :     PCS_NAD83_Florida_West,   Proj_Florida_CS83_West,
      60             : 
      61             :     PCS_NAD83_Hawaii_zone_1,    Proj_Hawaii_CS83_1,
      62             :     PCS_NAD83_Hawaii_zone_2,    Proj_Hawaii_CS83_2,
      63             :     PCS_NAD83_Hawaii_zone_3,    Proj_Hawaii_CS83_3,
      64             :     PCS_NAD83_Hawaii_zone_4,    Proj_Hawaii_CS83_4,
      65             :     PCS_NAD83_Hawaii_zone_5,    Proj_Hawaii_CS83_5,
      66             : 
      67             :     PCS_NAD83_Georgia_East,   Proj_Georgia_CS83_East,
      68             :     PCS_NAD83_Georgia_West,   Proj_Georgia_CS83_West,
      69             : 
      70             :     PCS_NAD83_Idaho_East,   Proj_Idaho_CS83_East,
      71             :     PCS_NAD83_Idaho_Central,    Proj_Idaho_CS83_Central,
      72             :     PCS_NAD83_Idaho_West,   Proj_Idaho_CS83_West,
      73             : 
      74             :     PCS_NAD83_Illinois_East,    Proj_Illinois_CS83_East,
      75             :     PCS_NAD83_Illinois_West,    Proj_Illinois_CS83_West,
      76             : 
      77             :     PCS_NAD83_Indiana_East,   Proj_Indiana_CS83_East,
      78             :     PCS_NAD83_Indiana_West,   Proj_Indiana_CS83_West,
      79             : 
      80             :     PCS_NAD83_Iowa_North,         Proj_Iowa_CS83_North,
      81             :     PCS_NAD83_Iowa_South,         Proj_Iowa_CS83_South,
      82             : 
      83             :     PCS_NAD83_Kansas_North,   Proj_Kansas_CS83_North,
      84             :     PCS_NAD83_Kansas_South,   Proj_Kansas_CS83_South,
      85             : 
      86             :     PCS_NAD83_Kentucky_North,   Proj_Kentucky_CS83_North,
      87             :     PCS_NAD83_Kentucky_South,   Proj_Kentucky_CS83_South,
      88             : 
      89             :     PCS_NAD83_Louisiana_North,    Proj_Louisiana_CS83_North,
      90             :     PCS_NAD83_Louisiana_South,    Proj_Louisiana_CS83_South,
      91             : 
      92             :     PCS_NAD83_Maine_East,   Proj_Maine_CS83_East,
      93             :     PCS_NAD83_Maine_West,   Proj_Maine_CS83_West,
      94             : 
      95             :     PCS_NAD83_Maryland,     Proj_Maryland_CS83,
      96             : 
      97             :     PCS_NAD83_Massachusetts,    Proj_Massachusetts_CS83_Mainland,
      98             :     PCS_NAD83_Massachusetts_Is,   Proj_Massachusetts_CS83_Island,
      99             : 
     100             :     PCS_NAD83_Michigan_North,   Proj_Michigan_CS83_North,
     101             :     PCS_NAD83_Michigan_Central,   Proj_Michigan_CS83_Central,
     102             :     PCS_NAD83_Michigan_South,   Proj_Michigan_CS83_South,
     103             : 
     104             :     PCS_NAD83_Minnesota_North,    Proj_Minnesota_CS83_North,
     105             :     PCS_NAD83_Minnesota_Cent,   Proj_Minnesota_CS83_Central,
     106             :     PCS_NAD83_Minnesota_South,    Proj_Minnesota_CS83_South,
     107             : 
     108             :     PCS_NAD83_Mississippi_East,   Proj_Mississippi_CS83_East,
     109             :     PCS_NAD83_Mississippi_West,   Proj_Mississippi_CS83_West,
     110             : 
     111             :     PCS_NAD83_Missouri_East,    Proj_Missouri_CS83_East,
     112             :     PCS_NAD83_Missouri_Central,   Proj_Missouri_CS83_Central,
     113             :     PCS_NAD83_Missouri_West,    Proj_Missouri_CS83_West,
     114             : 
     115             :     PCS_NAD83_Montana,      Proj_Montana_CS83,
     116             : 
     117             :     PCS_NAD83_Nebraska,     Proj_Nebraska_CS83,
     118             : 
     119             :     PCS_NAD83_Nevada_East,    Proj_Nevada_CS83_East,
     120             :     PCS_NAD83_Nevada_Central,   Proj_Nevada_CS83_Central,
     121             :     PCS_NAD83_Nevada_West,    Proj_Nevada_CS83_West,
     122             : 
     123             :     PCS_NAD83_New_Hampshire,    Proj_New_Hampshire_CS83,
     124             : 
     125             :     PCS_NAD83_New_Jersey,   Proj_New_Jersey_CS83,
     126             : 
     127             :     PCS_NAD83_New_Mexico_East,    Proj_New_Mexico_CS83_East,
     128             :     PCS_NAD83_New_Mexico_Cent,    Proj_New_Mexico_CS83_Central,
     129             :     PCS_NAD83_New_Mexico_West,    Proj_New_Mexico_CS83_West,
     130             : 
     131             :     PCS_NAD83_New_York_East,    Proj_New_York_CS83_East,
     132             :     PCS_NAD83_New_York_Central,   Proj_New_York_CS83_Central,
     133             :     PCS_NAD83_New_York_West,    Proj_New_York_CS83_West,
     134             :     PCS_NAD83_New_York_Long_Is,   Proj_New_York_CS83_Long_Island,
     135             : 
     136             :     PCS_NAD83_North_Carolina,         Proj_North_Carolina_CS83,
     137             : 
     138             :     PCS_NAD83_North_Dakota_N,   Proj_North_Dakota_CS83_North,
     139             :     PCS_NAD83_North_Dakota_S,   Proj_North_Dakota_CS83_South,
     140             : 
     141             :     PCS_NAD83_Ohio_North,   Proj_Ohio_CS83_North,
     142             :     PCS_NAD83_Ohio_South,   Proj_Ohio_CS83_South,
     143             : 
     144             :     PCS_NAD83_Oklahoma_North,   Proj_Oklahoma_CS83_North,
     145             :     PCS_NAD83_Oklahoma_South,   Proj_Oklahoma_CS83_South,
     146             : 
     147             :     PCS_NAD83_Oregon_North,   Proj_Oregon_CS83_North,
     148             :     PCS_NAD83_Oregon_South,   Proj_Oregon_CS83_South,
     149             : 
     150             :     PCS_NAD83_Pennsylvania_N,   Proj_Pennsylvania_CS83_North,
     151             :     PCS_NAD83_Pennsylvania_S,   Proj_Pennsylvania_CS83_South,
     152             : 
     153             :     PCS_NAD83_Rhode_Island,   Proj_Rhode_Island_CS83,
     154             : 
     155             :     PCS_NAD83_South_Carolina,   Proj_South_Carolina_CS83,
     156             : 
     157             :     PCS_NAD83_South_Dakota_N,   Proj_South_Dakota_CS83_North,
     158             :     PCS_NAD83_South_Dakota_S,   Proj_South_Dakota_CS83_South,
     159             : 
     160             :     PCS_NAD83_Tennessee,    Proj_Tennessee_CS83,
     161             : 
     162             :     PCS_NAD83_Texas_North,    Proj_Texas_CS83_North,
     163             :     PCS_NAD83_Texas_North_Cen,    Proj_Texas_CS83_North_Central,
     164             :     PCS_NAD83_Texas_Central,    Proj_Texas_CS83_Central,
     165             :     PCS_NAD83_Texas_South_Cen,    Proj_Texas_CS83_South_Central,
     166             :     PCS_NAD83_Texas_South,    Proj_Texas_CS83_South,
     167             : 
     168             :     PCS_NAD83_Utah_North,   Proj_Utah_CS83_North,
     169             :     PCS_NAD83_Utah_Central,   Proj_Utah_CS83_Central,
     170             :     PCS_NAD83_Utah_South,   Proj_Utah_CS83_South,
     171             : 
     172             :     PCS_NAD83_Vermont,      Proj_Vermont_CS83,
     173             : 
     174             :     PCS_NAD83_Virginia_North,   Proj_Virginia_CS83_North,
     175             :     PCS_NAD83_Virginia_South,   Proj_Virginia_CS83_South,
     176             : 
     177             :     PCS_NAD83_Washington_North,   Proj_Washington_CS83_North,
     178             :     PCS_NAD83_Washington_South,   Proj_Washington_CS83_South,
     179             : 
     180             :     PCS_NAD83_West_Virginia_N,    Proj_West_Virginia_CS83_North,
     181             :     PCS_NAD83_West_Virginia_S,    Proj_West_Virginia_CS83_South,
     182             : 
     183             :     PCS_NAD83_Wisconsin_North,    Proj_Wisconsin_CS83_North,
     184             :     PCS_NAD83_Wisconsin_Cen,    Proj_Wisconsin_CS83_Central,
     185             :     PCS_NAD83_Wisconsin_South,    Proj_Wisconsin_CS83_South,
     186             : 
     187             :     PCS_NAD83_Wyoming_East,   Proj_Wyoming_CS83_East,
     188             :     PCS_NAD83_Wyoming_E_Cen,    Proj_Wyoming_CS83_East_Central,
     189             :     PCS_NAD83_Wyoming_W_Cen,    Proj_Wyoming_CS83_West_Central,
     190             :     PCS_NAD83_Wyoming_West,   Proj_Wyoming_CS83_West,
     191             : 
     192             :     PCS_NAD83_Puerto_Rico_Virgin_Is,  Proj_Puerto_Rico_Virgin_Is,
     193             : 
     194             :     PCS_NAD27_Alabama_East,   Proj_Alabama_CS27_East,
     195             :     PCS_NAD27_Alabama_West,   Proj_Alabama_CS27_West,
     196             : 
     197             :     PCS_NAD27_Alaska_zone_1,    Proj_Alaska_CS27_1,
     198             :     PCS_NAD27_Alaska_zone_2,    Proj_Alaska_CS27_2,
     199             :     PCS_NAD27_Alaska_zone_3,    Proj_Alaska_CS27_3,
     200             :     PCS_NAD27_Alaska_zone_4,    Proj_Alaska_CS27_4,
     201             :     PCS_NAD27_Alaska_zone_5,    Proj_Alaska_CS27_5,
     202             :     PCS_NAD27_Alaska_zone_6,    Proj_Alaska_CS27_6,
     203             :     PCS_NAD27_Alaska_zone_7,    Proj_Alaska_CS27_7,
     204             :     PCS_NAD27_Alaska_zone_8,    Proj_Alaska_CS27_8,
     205             :     PCS_NAD27_Alaska_zone_9,    Proj_Alaska_CS27_9,
     206             :     PCS_NAD27_Alaska_zone_10,   Proj_Alaska_CS27_10,
     207             : 
     208             :     PCS_NAD27_California_I,   Proj_California_CS27_I,
     209             :     PCS_NAD27_California_II,    Proj_California_CS27_II,
     210             :     PCS_NAD27_California_III,   Proj_California_CS27_III,
     211             :     PCS_NAD27_California_IV,    Proj_California_CS27_IV,
     212             :     PCS_NAD27_California_V,   Proj_California_CS27_V,
     213             :     PCS_NAD27_California_VI,    Proj_California_CS27_VI,
     214             :     PCS_NAD27_California_VII,   Proj_California_CS27_VII,
     215             : 
     216             :     PCS_NAD27_Arizona_East,   Proj_Arizona_Coordinate_System_east,
     217             :     PCS_NAD27_Arizona_Central,    Proj_Arizona_Coordinate_System_Central,
     218             :     PCS_NAD27_Arizona_West,   Proj_Arizona_Coordinate_System_west,
     219             : 
     220             :     PCS_NAD27_Arkansas_North,   Proj_Arkansas_CS27_North,
     221             :     PCS_NAD27_Arkansas_South,   Proj_Arkansas_CS27_South,
     222             : 
     223             :     PCS_NAD27_Colorado_North,   Proj_Colorado_CS27_North,
     224             :     PCS_NAD27_Colorado_Central,   Proj_Colorado_CS27_Central,
     225             :     PCS_NAD27_Colorado_South,   Proj_Colorado_CS27_South,
     226             : 
     227             :     PCS_NAD27_Connecticut,    Proj_Connecticut_CS27,
     228             : 
     229             :     PCS_NAD27_Delaware,     Proj_Delaware_CS27,
     230             : 
     231             :     PCS_NAD27_Florida_East,   Proj_Florida_CS27_East,
     232             :     PCS_NAD27_Florida_North,    Proj_Florida_CS27_North,
     233             :     PCS_NAD27_Florida_West,   Proj_Florida_CS27_West,
     234             : 
     235             :     PCS_NAD27_Hawaii_zone_1,    Proj_Hawaii_CS27_1,
     236             :     PCS_NAD27_Hawaii_zone_2,    Proj_Hawaii_CS27_2,
     237             :     PCS_NAD27_Hawaii_zone_3,    Proj_Hawaii_CS27_3,
     238             :     PCS_NAD27_Hawaii_zone_4,    Proj_Hawaii_CS27_4,
     239             :     PCS_NAD27_Hawaii_zone_5,    Proj_Hawaii_CS27_5,
     240             : 
     241             :     PCS_NAD27_Georgia_East,   Proj_Georgia_CS27_East,
     242             :     PCS_NAD27_Georgia_West,   Proj_Georgia_CS27_West,
     243             : 
     244             :     PCS_NAD27_Idaho_East,   Proj_Idaho_CS27_East,
     245             :     PCS_NAD27_Idaho_Central,    Proj_Idaho_CS27_Central,
     246             :     PCS_NAD27_Idaho_West,   Proj_Idaho_CS27_West,
     247             : 
     248             :     PCS_NAD27_Illinois_East,    Proj_Illinois_CS27_East,
     249             :     PCS_NAD27_Illinois_West,    Proj_Illinois_CS27_West,
     250             : 
     251             :     PCS_NAD27_Indiana_East,   Proj_Indiana_CS27_East,
     252             :     PCS_NAD27_Indiana_West,   Proj_Indiana_CS27_West,
     253             : 
     254             :     PCS_NAD27_Iowa_North,         Proj_Iowa_CS27_North,
     255             :     PCS_NAD27_Iowa_South,         Proj_Iowa_CS27_South,
     256             : 
     257             :     PCS_NAD27_Kansas_North,   Proj_Kansas_CS27_North,
     258             :     PCS_NAD27_Kansas_South,   Proj_Kansas_CS27_South,
     259             : 
     260             :     PCS_NAD27_Kentucky_North,   Proj_Kentucky_CS27_North,
     261             :     PCS_NAD27_Kentucky_South,   Proj_Kentucky_CS27_South,
     262             : 
     263             :     PCS_NAD27_Louisiana_North,    Proj_Louisiana_CS27_North,
     264             :     PCS_NAD27_Louisiana_South,    Proj_Louisiana_CS27_South,
     265             : 
     266             :     PCS_NAD27_Maine_East,   Proj_Maine_CS27_East,
     267             :     PCS_NAD27_Maine_West,   Proj_Maine_CS27_West,
     268             : 
     269             :     PCS_NAD27_Maryland,     Proj_Maryland_CS27,
     270             : 
     271             :     PCS_NAD27_Massachusetts,    Proj_Massachusetts_CS27_Mainland,
     272             :     PCS_NAD27_Massachusetts_Is,   Proj_Massachusetts_CS27_Island,
     273             : 
     274             :     PCS_NAD27_Michigan_North,   Proj_Michigan_CS27_North,
     275             :     PCS_NAD27_Michigan_Central,   Proj_Michigan_CS27_Central,
     276             :     PCS_NAD27_Michigan_South,   Proj_Michigan_CS27_South,
     277             : 
     278             :     PCS_NAD27_Minnesota_North,    Proj_Minnesota_CS27_North,
     279             :     PCS_NAD27_Minnesota_Cent,   Proj_Minnesota_CS27_Central,
     280             :     PCS_NAD27_Minnesota_South,    Proj_Minnesota_CS27_South,
     281             : 
     282             :     PCS_NAD27_Mississippi_East,   Proj_Mississippi_CS27_East,
     283             :     PCS_NAD27_Mississippi_West,   Proj_Mississippi_CS27_West,
     284             : 
     285             :     PCS_NAD27_Missouri_East,    Proj_Missouri_CS27_East,
     286             :     PCS_NAD27_Missouri_Central,   Proj_Missouri_CS27_Central,
     287             :     PCS_NAD27_Missouri_West,    Proj_Missouri_CS27_West,
     288             : 
     289             :     PCS_NAD27_Montana_North,    Proj_Montana_CS27_North,
     290             :     PCS_NAD27_Montana_Central,    Proj_Montana_CS27_Central,
     291             :     PCS_NAD27_Montana_South,    Proj_Montana_CS27_South,
     292             : 
     293             :     PCS_NAD27_Nebraska_North,   Proj_Nebraska_CS27_North,
     294             :     PCS_NAD27_Nebraska_South,   Proj_Nebraska_CS27_South,
     295             : 
     296             :     PCS_NAD27_Nevada_East,    Proj_Nevada_CS27_East,
     297             :     PCS_NAD27_Nevada_Central,   Proj_Nevada_CS27_Central,
     298             :     PCS_NAD27_Nevada_West,    Proj_Nevada_CS27_West,
     299             : 
     300             :     PCS_NAD27_New_Hampshire,    Proj_New_Hampshire_CS27,
     301             : 
     302             :     PCS_NAD27_New_Jersey,   Proj_New_Jersey_CS27,
     303             : 
     304             :     PCS_NAD27_New_Mexico_East,    Proj_New_Mexico_CS27_East,
     305             :     PCS_NAD27_New_Mexico_Cent,    Proj_New_Mexico_CS27_Central,
     306             :     PCS_NAD27_New_Mexico_West,    Proj_New_Mexico_CS27_West,
     307             : 
     308             :     PCS_NAD27_New_York_East,    Proj_New_York_CS27_East,
     309             :     PCS_NAD27_New_York_Central,   Proj_New_York_CS27_Central,
     310             :     PCS_NAD27_New_York_West,    Proj_New_York_CS27_West,
     311             :     PCS_NAD27_New_York_Long_Is,   Proj_New_York_CS27_Long_Island,
     312             : 
     313             :     PCS_NAD27_North_Carolina,         Proj_North_Carolina_CS27,
     314             : 
     315             :     PCS_NAD27_North_Dakota_N,   Proj_North_Dakota_CS27_North,
     316             :     PCS_NAD27_North_Dakota_S,   Proj_North_Dakota_CS27_South,
     317             : 
     318             :     PCS_NAD27_Ohio_North,   Proj_Ohio_CS27_North,
     319             :     PCS_NAD27_Ohio_South,   Proj_Ohio_CS27_South,
     320             : 
     321             :     PCS_NAD27_Oklahoma_North,   Proj_Oklahoma_CS27_North,
     322             :     PCS_NAD27_Oklahoma_South,   Proj_Oklahoma_CS27_South,
     323             : 
     324             :     PCS_NAD27_Oregon_North,   Proj_Oregon_CS27_North,
     325             :     PCS_NAD27_Oregon_South,   Proj_Oregon_CS27_South,
     326             : 
     327             :     PCS_NAD27_Pennsylvania_N,   Proj_Pennsylvania_CS27_North,
     328             :     PCS_NAD27_Pennsylvania_S,   Proj_Pennsylvania_CS27_South,
     329             : 
     330             :     PCS_NAD27_Rhode_Island,   Proj_Rhode_Island_CS27,
     331             : 
     332             :     PCS_NAD27_South_Carolina_N,   Proj_South_Carolina_CS27_North,
     333             :     PCS_NAD27_South_Carolina_S,   Proj_South_Carolina_CS27_South,
     334             : 
     335             :     PCS_NAD27_South_Dakota_N,   Proj_South_Dakota_CS27_North,
     336             :     PCS_NAD27_South_Dakota_S,   Proj_South_Dakota_CS27_South,
     337             : 
     338             :     PCS_NAD27_Tennessee,    Proj_Tennessee_CS27,
     339             : 
     340             :     PCS_NAD27_Texas_North,    Proj_Texas_CS27_North,
     341             :     PCS_NAD27_Texas_North_Cen,    Proj_Texas_CS27_North_Central,
     342             :     PCS_NAD27_Texas_Central,    Proj_Texas_CS27_Central,
     343             :     PCS_NAD27_Texas_South_Cen,    Proj_Texas_CS27_South_Central,
     344             :     PCS_NAD27_Texas_South,    Proj_Texas_CS27_South,
     345             : 
     346             :     PCS_NAD27_Utah_North,   Proj_Utah_CS27_North,
     347             :     PCS_NAD27_Utah_Central,   Proj_Utah_CS27_Central,
     348             :     PCS_NAD27_Utah_South,   Proj_Utah_CS27_South,
     349             : 
     350             :     PCS_NAD27_Vermont,      Proj_Vermont_CS27,
     351             : 
     352             :     PCS_NAD27_Virginia_North,   Proj_Virginia_CS27_North,
     353             :     PCS_NAD27_Virginia_South,   Proj_Virginia_CS27_South,
     354             : 
     355             :     PCS_NAD27_Washington_North,   Proj_Washington_CS27_North,
     356             :     PCS_NAD27_Washington_South,   Proj_Washington_CS27_South,
     357             : 
     358             :     PCS_NAD27_West_Virginia_N,    Proj_West_Virginia_CS27_North,
     359             :     PCS_NAD27_West_Virginia_S,    Proj_West_Virginia_CS27_South,
     360             : 
     361             :     PCS_NAD27_Wisconsin_North,    Proj_Wisconsin_CS27_North,
     362             :     PCS_NAD27_Wisconsin_Cen,    Proj_Wisconsin_CS27_Central,
     363             :     PCS_NAD27_Wisconsin_South,    Proj_Wisconsin_CS27_South,
     364             : 
     365             :     PCS_NAD27_Wyoming_East,   Proj_Wyoming_CS27_East,
     366             :     PCS_NAD27_Wyoming_E_Cen,    Proj_Wyoming_CS27_East_Central,
     367             :     PCS_NAD27_Wyoming_W_Cen,    Proj_Wyoming_CS27_West_Central,
     368             :     PCS_NAD27_Wyoming_West,   Proj_Wyoming_CS27_West,
     369             : 
     370             :     PCS_NAD27_Puerto_Rico,    Proj_Puerto_Rico_CS27,
     371             : 
     372             :     KvUserDefined
     373             : };
     374             : 
     375             : /************************************************************************/
     376             : /*                          GTIFMapSysToPCS()                           */
     377             : /*                                                                      */
     378             : /*      Given a Datum, MapSys and zone value generate the best PCS      */
     379             : /*      code possible.                                                  */
     380             : /************************************************************************/
     381             : 
     382           0 : int GTIFMapSysToPCS( int MapSys, int Datum, int nZone )
     383             : 
     384             : {
     385           0 :     int   PCSCode = KvUserDefined;
     386             : 
     387           0 :     if( MapSys == MapSys_UTM_North )
     388             :     {
     389           0 :   if( Datum == GCS_NAD27 )
     390           0 :       PCSCode = PCS_NAD27_UTM_zone_3N + nZone - 3;
     391           0 :   else if( Datum == GCS_NAD83 )
     392           0 :       PCSCode = PCS_NAD83_UTM_zone_3N + nZone - 3;
     393           0 :   else if( Datum == GCS_WGS_72 )
     394           0 :       PCSCode = PCS_WGS72_UTM_zone_1N + nZone - 1;
     395           0 :   else if( Datum == GCS_WGS_72BE )
     396           0 :       PCSCode = PCS_WGS72BE_UTM_zone_1N + nZone - 1;
     397           0 :   else if( Datum == GCS_WGS_84 )
     398           0 :       PCSCode = PCS_WGS84_UTM_zone_1N + nZone - 1;
     399             :     }
     400           0 :     else if( MapSys == MapSys_UTM_South )
     401             :     {
     402           0 :   if( Datum == GCS_WGS_72 )
     403           0 :       PCSCode = PCS_WGS72_UTM_zone_1S + nZone - 1;
     404           0 :   else if( Datum == GCS_WGS_72BE )
     405           0 :       PCSCode = PCS_WGS72BE_UTM_zone_1S + nZone - 1;
     406           0 :   else if( Datum == GCS_WGS_84 )
     407           0 :       PCSCode = PCS_WGS84_UTM_zone_1S + nZone - 1;
     408             :     }
     409           0 :     else if( MapSys == MapSys_State_Plane_27 )
     410             :     {
     411           0 :         PCSCode = 10000 + nZone;
     412           0 :   for( int i = 0; StatePlaneTable[i] != KvUserDefined; i += 2 )
     413             :   {
     414           0 :       if( StatePlaneTable[i+1] == PCSCode )
     415           0 :           PCSCode = StatePlaneTable[i];
     416             :   }
     417             : 
     418             :         /* Old EPSG code was in error for Tennesse CS27, override */
     419           0 :         if( nZone == 4100 )
     420           0 :             PCSCode = 2204;
     421             :     }
     422           0 :     else if( MapSys == MapSys_State_Plane_83 )
     423             :     {
     424           0 :         PCSCode = 10000 + nZone + 30;
     425             : 
     426           0 :   for( int i = 0; StatePlaneTable[i] != KvUserDefined; i += 2 )
     427             :   {
     428           0 :       if( StatePlaneTable[i+1] == PCSCode )
     429           0 :           PCSCode = StatePlaneTable[i];
     430             :   }
     431             : 
     432             :         /* Old EPSG code was in error for Kentucky North CS83, override */
     433           0 :         if( nZone == 1601 )
     434           0 :             PCSCode = 2205;
     435             :     }
     436             : 
     437           0 :     return PCSCode;
     438             : }
     439             : 
     440             : /************************************************************************/
     441             : /*                          GTIFMapSysToProj()                          */
     442             : /*                                                                      */
     443             : /*      Given a MapSys and zone value generate the best Proj_           */
     444             : /*      code possible.                                                  */
     445             : /************************************************************************/
     446             : 
     447           0 : int GTIFMapSysToProj( int MapSys, int nZone )
     448             : 
     449             : {
     450           0 :     int   ProjCode = KvUserDefined;
     451             : 
     452           0 :     if( MapSys == MapSys_UTM_North )
     453             :     {
     454           0 :         ProjCode = Proj_UTM_zone_1N + nZone - 1;
     455             :     }
     456           0 :     else if( MapSys == MapSys_UTM_South )
     457             :     {
     458           0 :         ProjCode = Proj_UTM_zone_1S + nZone - 1;
     459             :     }
     460           0 :     else if( MapSys == MapSys_State_Plane_27 )
     461             :     {
     462           0 :         ProjCode = 10000 + nZone;
     463             : 
     464             :         /* Tennesse override */
     465           0 :         if( nZone == 4100 )
     466           0 :             ProjCode = 15302;
     467             :     }
     468           0 :     else if( MapSys == MapSys_State_Plane_83 )
     469             :     {
     470           0 :         ProjCode = 10000 + nZone + 30;
     471             : 
     472             :         /* Kentucky North override */
     473           0 :         if( nZone == 1601 )
     474           0 :             ProjCode = 15303;
     475             :     }
     476             : 
     477           0 :     return ProjCode;
     478             : }
     479             : 
     480             : /************************************************************************/
     481             : /*                          GTIFPCSToMapSys()                           */
     482             : /************************************************************************/
     483             : 
     484             : /**
     485             :  * Translate a PCS_ code into a UTM or State Plane map system, a datum,
     486             :  * and a zone if possible.
     487             :  *
     488             :  * @param PCSCode The projection code (PCS_*) as would be stored in the
     489             :  * ProjectedCSTypeGeoKey of a GeoTIFF file.
     490             :  *
     491             :  * @param pDatum Pointer to an integer into which the datum code (GCS_*)
     492             :  * is put if the function succeeds.
     493             :  *
     494             :  * @param pZone Pointer to an integer into which the zone will be placed
     495             :  * if the function is successful.
     496             :  *
     497             :  * @return Returns either MapSys_UTM_North, MapSys_UTM_South,
     498             :  * MapSys_State_Plane_83, MapSys_State_Plane_27 or KvUserDefined.
     499             :  * KvUserDefined indicates that the
     500             :  * function failed to recognise the projection as UTM or State Plane.
     501             :  *
     502             :  * The zone value is only set if the return code is other than KvUserDefined.
     503             :  * For utm map system the returned zone will be between 1 and 60.  For
     504             :  * State Plane, the USGS state plane zone number is returned.  For instance,
     505             :  * Alabama East is zone 101.
     506             :  *
     507             :  * The datum (really this is the GCS) is set to a GCS_ value such as GCS_NAD27.
     508             :  *
     509             :  * This function is useful to recognise (most) UTM and State Plane coordinate
     510             :  * systems.
     511             :  * It is used as a fallback mechanism by GTIFGetDefn() for normalization when
     512             :  * PROJ database is not found.
     513             :  */
     514             : 
     515        6172 : int GTIFPCSToMapSys( int PCSCode, int * pDatum, int * pZone )
     516             : 
     517             : {
     518        6172 :     int   Datum = KvUserDefined, Proj = KvUserDefined;
     519        6172 :     int   nZone = KvUserDefined;
     520             : 
     521             : /* -------------------------------------------------------------------- */
     522             : /*      UTM with various datums.  Note there are lots of PCS UTM        */
     523             : /*      codes not done yet which use strange datums.                    */
     524             : /* -------------------------------------------------------------------- */
     525        6172 :     if( PCSCode >= PCS_NAD27_UTM_zone_3N && PCSCode <= PCS_NAD27_UTM_zone_22N )
     526             :     {
     527        5510 :   Datum = GCS_NAD27;
     528        5510 :   Proj = MapSys_UTM_North;
     529        5510 :   nZone = PCSCode - PCS_NAD27_UTM_zone_3N + 3;
     530             :     }
     531         662 :     else if( PCSCode >= PCS_NAD83_UTM_zone_3N
     532         380 :        && PCSCode <= PCS_NAD83_UTM_zone_23N )
     533             :     {
     534          12 :   Datum = GCS_NAD83;
     535          12 :   Proj = MapSys_UTM_North;
     536          12 :   nZone = PCSCode - PCS_NAD83_UTM_zone_3N + 3;
     537             :     }
     538             : 
     539         650 :     else if( PCSCode >= PCS_WGS72_UTM_zone_1N
     540         324 :        && PCSCode <= PCS_WGS72_UTM_zone_60N )
     541             :     {
     542           0 :   Datum = GCS_WGS_72;
     543           0 :   Proj = MapSys_UTM_North;
     544           0 :   nZone = PCSCode - PCS_WGS72_UTM_zone_1N + 1;
     545             :     }
     546         650 :     else if( PCSCode >= PCS_WGS72_UTM_zone_1S
     547         324 :        && PCSCode <= PCS_WGS72_UTM_zone_60S )
     548             :     {
     549           0 :   Datum = GCS_WGS_72;
     550           0 :   Proj = MapSys_UTM_South;
     551           0 :   nZone = PCSCode - PCS_WGS72_UTM_zone_1S + 1;
     552             :     }
     553             : 
     554         650 :     else if( PCSCode >= PCS_WGS72BE_UTM_zone_1N
     555         324 :        && PCSCode <= PCS_WGS72BE_UTM_zone_60N )
     556             :     {
     557           0 :   Datum = GCS_WGS_72BE;
     558           0 :   Proj = MapSys_UTM_North;
     559           0 :   nZone = PCSCode - PCS_WGS72BE_UTM_zone_1N + 1;
     560             :     }
     561         650 :     else if( PCSCode >= PCS_WGS72BE_UTM_zone_1S
     562         324 :        && PCSCode <= PCS_WGS72BE_UTM_zone_60S )
     563             :     {
     564           0 :   Datum = GCS_WGS_72BE;
     565           0 :   Proj = MapSys_UTM_South;
     566           0 :   nZone = PCSCode - PCS_WGS72BE_UTM_zone_1S + 1;
     567             :     }
     568             : 
     569         650 :     else if( PCSCode >= PCS_WGS84_UTM_zone_1N
     570         324 :        && PCSCode <= PCS_WGS84_UTM_zone_60N )
     571             :     {
     572         318 :   Datum = GCS_WGS_84;
     573         318 :   Proj = MapSys_UTM_North;
     574         318 :   nZone = PCSCode - PCS_WGS84_UTM_zone_1N + 1;
     575             :     }
     576         332 :     else if( PCSCode >= PCS_WGS84_UTM_zone_1S
     577           4 :        && PCSCode <= PCS_WGS84_UTM_zone_60S )
     578             :     {
     579           4 :   Datum = GCS_WGS_84;
     580           4 :   Proj = MapSys_UTM_South;
     581           4 :   nZone = PCSCode - PCS_WGS84_UTM_zone_1S + 1;
     582             :     }
     583         328 :     else if( PCSCode >= PCS_SAD69_UTM_zone_18N
     584          20 :        && PCSCode <= PCS_SAD69_UTM_zone_22N )
     585             :     {
     586           0 :   Datum = KvUserDefined;
     587           0 :   Proj = MapSys_UTM_North;
     588           0 :   nZone = PCSCode - PCS_SAD69_UTM_zone_18N + 18;
     589             :     }
     590         328 :     else if( PCSCode >= PCS_SAD69_UTM_zone_17S
     591          20 :        && PCSCode <= PCS_SAD69_UTM_zone_25S )
     592             :     {
     593           0 :   Datum = KvUserDefined;
     594           0 :   Proj = MapSys_UTM_South;
     595           0 :   nZone = PCSCode - PCS_SAD69_UTM_zone_17S + 17;
     596             :     }
     597             : 
     598             : /* -------------------------------------------------------------------- */
     599             : /*      State Plane zones, first we translate any PCS_ codes to   */
     600             : /*  a Proj_ code that we can get a handle on.     */
     601             : /* -------------------------------------------------------------------- */
     602     1543000 :     for( int i = 0; StatePlaneTable[i] != KvUserDefined; i += 2 )
     603             :     {
     604     1536830 :   if( StatePlaneTable[i] == PCSCode )
     605           8 :       PCSCode = StatePlaneTable[i+1];
     606             :     }
     607             : 
     608        6172 :     if( PCSCode <= 15900 && PCSCode >= 10000 )
     609             :     {
     610           8 :   if( (PCSCode % 100) >= 30 )
     611             :         {
     612           4 :             Proj = MapSys_State_Plane_83;
     613           4 :       Datum = GCS_NAD83;
     614             :         }
     615             :   else
     616             :         {
     617           4 :             Proj = MapSys_State_Plane_27;
     618           4 :       Datum = GCS_NAD27;
     619             :         }
     620             : 
     621           8 :   nZone = PCSCode - 10000;
     622           8 :   if( Datum == GCS_NAD83 )
     623           4 :       nZone -= 30;
     624             :     }
     625             : 
     626        6172 :     if( pDatum != NULL )
     627        6172 :         *pDatum = Datum;
     628             : 
     629        6172 :     if( pZone != NULL )
     630        6172 :         *pZone = nZone;
     631             : 
     632        6172 :     return Proj;
     633             : }
     634             : 
     635             : /************************************************************************/
     636             : /*                          GTIFProjToMapSys()                          */
     637             : /************************************************************************/
     638             : 
     639             : /**
     640             :  * Translate a Proj_ code into a UTM or State Plane map system, and a zone
     641             :  * if possible.
     642             :  *
     643             :  * @param ProjCode The projection code (Proj_*) as would be stored in the
     644             :  * ProjectionGeoKey of a GeoTIFF file.
     645             :  * @param pZone Pointer to an integer into which the zone will be placed
     646             :  * if the function is successful.
     647             :  *
     648             :  * @return Returns either MapSys_UTM_North, MapSys_UTM_South,
     649             :  * MapSys_State_Plane_27, MapSys_State_Plane_83 or KvUserDefined.
     650             :  * KvUserDefined indicates that the
     651             :  * function failed to recognise the projection as UTM or State Plane.
     652             :  *
     653             :  * The zone value is only set if the return code is other than KvUserDefined.
     654             :  * For utm map system the returned zone will be between 1 and 60.  For
     655             :  * State Plane, the USGS state plane zone number is returned.  For instance,
     656             :  * Alabama East is zone 101.
     657             :  *
     658             :  * This function is useful to recognise UTM and State Plane coordinate
     659             :  * systems, and to extract zone numbers so the projections can be
     660             :  * represented as UTM rather than as the underlying projection method such
     661             :  * Transverse Mercator for instance.
     662             :  */
     663             : 
     664        7447 : int GTIFProjToMapSys( int ProjCode, int * pZone )
     665             : 
     666             : {
     667        7447 :     int   nZone = KvUserDefined;
     668        7447 :     int   MapSys = KvUserDefined;
     669             : 
     670             : /* -------------------------------------------------------------------- */
     671             : /*      Handle UTM.                                                     */
     672             : /* -------------------------------------------------------------------- */
     673        7447 :     if( ProjCode >= Proj_UTM_zone_1N && ProjCode <= Proj_UTM_zone_60N )
     674             :     {
     675        2944 :   MapSys = MapSys_UTM_North;
     676        2944 :   nZone = ProjCode - Proj_UTM_zone_1N + 1;
     677             :     }
     678        4503 :     else if( ProjCode >= Proj_UTM_zone_1S && ProjCode <= Proj_UTM_zone_60S )
     679             :     {
     680           3 :   MapSys = MapSys_UTM_South;
     681           3 :   nZone = ProjCode - Proj_UTM_zone_1S + 1;
     682             :     }
     683             : 
     684             : /* -------------------------------------------------------------------- */
     685             : /*      Handle State Plane.  I think there are some anomalies in        */
     686             : /*      here, so this is a bit risky.                                   */
     687             : /* -------------------------------------------------------------------- */
     688        4500 :     else if( ProjCode >= 10101 && ProjCode <= 15299 )
     689             :     {
     690           8 :         if( ProjCode % 100 >= 30 )
     691             :         {
     692           5 :             MapSys = MapSys_State_Plane_83;
     693           5 :             nZone = ProjCode - 10000 - 30;
     694             :         }
     695             :         else
     696             :         {
     697           3 :             MapSys = MapSys_State_Plane_27;
     698           3 :             nZone = ProjCode - 10000;
     699             :         }
     700             :     }
     701             : 
     702        7447 :     if( pZone != NULL )
     703        7447 :         *pZone = nZone;
     704             : 
     705        7447 :     return MapSys;
     706             : }

Generated by: LCOV version 1.14