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

Generated by: LCOV version 1.14