Main Page   Compound List   File List   Compound Members   File Members   Related Pages  

geo_extra.c

00001 /******************************************************************************
00002  * $Id: geo_extra_c-source.html 385 2001-03-05 04:58:33Z warmerda $
00003  *
00004  * Project:  libgeotiff
00005  * Purpose:  Code to normalize a few common PCS values without use of CSV
00006  *           files.
00007  * Author:   Frank Warmerdam, warmerda@home.com
00008  *
00009  ******************************************************************************
00010  * Copyright (c) 1999, Frank Warmerdam
00011  *
00012  * Permission is hereby granted, free of charge, to any person obtaining a
00013  * copy of this software and associated documentation files (the "Software"),
00014  * to deal in the Software without restriction, including without limitation
00015  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00016  * and/or sell copies of the Software, and to permit persons to whom the
00017  * Software is furnished to do so, subject to the following conditions:
00018  *
00019  * The above copyright notice and this permission notice shall be included
00020  * in all copies or substantial portions of the Software.
00021  *
00022  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00023  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00024  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00025  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00026  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00027  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00028  * DEALINGS IN THE SOFTWARE.
00029  ******************************************************************************
00030  *
00031  * $Log$
00031  * Revision 1.2  2001/03/05 04:58:33  warmerda
00031  * updated
00031  *
00032  * Revision 1.2  1999/05/04 03:09:33  warmerda
00033  * avoid warnings
00034  *
00035  * Revision 1.1  1999/04/28 20:01:29  warmerda
00036  * new
00037  *
00038  */
00039 
00040 /*
00041 #include "geotiff.h"
00042 #include "geo_tiffp.h"
00043 #include "geo_keyp.h"
00044 */
00045 
00046 #include "geo_normalize.h"
00047 #include "geovalues.h"
00048 
00049 static int StatePlaneTable[] = 
00050 {
00051     PCS_NAD83_Alabama_East,             Proj_Alabama_CS83_East,
00052     PCS_NAD83_Alabama_West,             Proj_Alabama_CS83_West,
00053 
00054     PCS_NAD83_Alaska_zone_1,            Proj_Alaska_CS83_1,
00055     PCS_NAD83_Alaska_zone_2,            Proj_Alaska_CS83_2,
00056     PCS_NAD83_Alaska_zone_3,            Proj_Alaska_CS83_3,
00057     PCS_NAD83_Alaska_zone_4,            Proj_Alaska_CS83_4,
00058     PCS_NAD83_Alaska_zone_5,            Proj_Alaska_CS83_5,
00059     PCS_NAD83_Alaska_zone_6,            Proj_Alaska_CS83_6,
00060     PCS_NAD83_Alaska_zone_7,            Proj_Alaska_CS83_7,
00061     PCS_NAD83_Alaska_zone_8,            Proj_Alaska_CS83_8,
00062     PCS_NAD83_Alaska_zone_9,            Proj_Alaska_CS83_9,
00063     PCS_NAD83_Alaska_zone_10,           Proj_Alaska_CS83_10,
00064 
00065     PCS_NAD83_California_1,             Proj_California_CS83_1,
00066     PCS_NAD83_California_2,             Proj_California_CS83_2,
00067     PCS_NAD83_California_3,             Proj_California_CS83_3,
00068     PCS_NAD83_California_4,             Proj_California_CS83_4,
00069     PCS_NAD83_California_5,             Proj_California_CS83_5,
00070     PCS_NAD83_California_6,             Proj_California_CS83_6,
00071 
00072     PCS_NAD83_Arizona_East,             Proj_Arizona_CS83_east,
00073     PCS_NAD83_Arizona_Central,          Proj_Arizona_CS83_Central,
00074     PCS_NAD83_Arizona_West,             Proj_Arizona_CS83_west,
00075 
00076     PCS_NAD83_Arkansas_North,           Proj_Arkansas_CS83_North,
00077     PCS_NAD83_Arkansas_South,           Proj_Arkansas_CS83_South,
00078 
00079     PCS_NAD83_Colorado_North,           Proj_Colorado_CS83_North,
00080     PCS_NAD83_Colorado_Central,         Proj_Colorado_CS83_Central,
00081     PCS_NAD83_Colorado_South,           Proj_Colorado_CS83_South,
00082 
00083     PCS_NAD83_Connecticut,              Proj_Connecticut_CS83,
00084 
00085     PCS_NAD83_Delaware,                 Proj_Delaware_CS83,
00086 
00087     PCS_NAD83_Florida_East,             Proj_Florida_CS83_East,
00088     PCS_NAD83_Florida_North,            Proj_Florida_CS83_North,
00089     PCS_NAD83_Florida_West,             Proj_Florida_CS83_West,
00090 
00091     PCS_NAD83_Hawaii_zone_1,            Proj_Hawaii_CS83_1,
00092     PCS_NAD83_Hawaii_zone_2,            Proj_Hawaii_CS83_2,
00093     PCS_NAD83_Hawaii_zone_3,            Proj_Hawaii_CS83_3,
00094     PCS_NAD83_Hawaii_zone_4,            Proj_Hawaii_CS83_4,
00095     PCS_NAD83_Hawaii_zone_5,            Proj_Hawaii_CS83_5,
00096 
00097     PCS_NAD83_Georgia_East,             Proj_Georgia_CS83_East,
00098     PCS_NAD83_Georgia_West,             Proj_Georgia_CS83_West,
00099 
00100     PCS_NAD83_Idaho_East,               Proj_Idaho_CS83_East,
00101     PCS_NAD83_Idaho_Central,            Proj_Idaho_CS83_Central,
00102     PCS_NAD83_Idaho_West,               Proj_Idaho_CS83_West,
00103 
00104     PCS_NAD83_Illinois_East,            Proj_Illinois_CS83_East,
00105     PCS_NAD83_Illinois_West,            Proj_Illinois_CS83_West,
00106 
00107     PCS_NAD83_Indiana_East,             Proj_Indiana_CS83_East,
00108     PCS_NAD83_Indiana_West,             Proj_Indiana_CS83_West,
00109 
00110     PCS_NAD83_Iowa_North,               Proj_Iowa_CS83_North,
00111     PCS_NAD83_Iowa_South,               Proj_Iowa_CS83_South,
00112 
00113     PCS_NAD83_Kansas_North,             Proj_Kansas_CS83_North,
00114     PCS_NAD83_Kansas_South,             Proj_Kansas_CS83_South,
00115 
00116     PCS_NAD83_Kentucky_North,           Proj_Kentucky_CS83_North,
00117     PCS_NAD83_Kentucky_South,           Proj_Kentucky_CS83_South,
00118 
00119     PCS_NAD83_Louisiana_North,          Proj_Louisiana_CS83_North,
00120     PCS_NAD83_Louisiana_South,          Proj_Louisiana_CS83_South,
00121 
00122     PCS_NAD83_Maine_East,               Proj_Maine_CS83_East,
00123     PCS_NAD83_Maine_West,               Proj_Maine_CS83_West,
00124 
00125     PCS_NAD83_Maryland,                 Proj_Maryland_CS83,
00126 
00127     PCS_NAD83_Massachusetts,            Proj_Massachusetts_CS83_Mainland,
00128     PCS_NAD83_Massachusetts_Is,         Proj_Massachusetts_CS83_Island,
00129 
00130     PCS_NAD83_Michigan_North,           Proj_Michigan_CS83_North,
00131     PCS_NAD83_Michigan_Central,         Proj_Michigan_CS83_Central,
00132     PCS_NAD83_Michigan_South,           Proj_Michigan_CS83_South,
00133 
00134     PCS_NAD83_Minnesota_North,          Proj_Minnesota_CS83_North,
00135     PCS_NAD83_Minnesota_Cent,           Proj_Minnesota_CS83_Central,
00136     PCS_NAD83_Minnesota_South,          Proj_Minnesota_CS83_South,
00137 
00138     PCS_NAD83_Mississippi_East,         Proj_Mississippi_CS83_East,
00139     PCS_NAD83_Mississippi_West,         Proj_Mississippi_CS83_West,
00140 
00141     PCS_NAD83_Missouri_East,            Proj_Missouri_CS83_East,
00142     PCS_NAD83_Missouri_Central,         Proj_Missouri_CS83_Central,
00143     PCS_NAD83_Missouri_West,            Proj_Missouri_CS83_West,
00144 
00145     PCS_NAD83_Montana,                  Proj_Montana_CS83,
00146 
00147     PCS_NAD83_Nebraska,                 Proj_Nebraska_CS83,
00148 
00149     PCS_NAD83_Nevada_East,              Proj_Nevada_CS83_East,
00150     PCS_NAD83_Nevada_Central,           Proj_Nevada_CS83_Central,
00151     PCS_NAD83_Nevada_West,              Proj_Nevada_CS83_West,
00152 
00153     PCS_NAD83_New_Hampshire,            Proj_New_Hampshire_CS83,
00154 
00155     PCS_NAD83_New_Jersey,               Proj_New_Jersey_CS83,
00156 
00157     PCS_NAD83_New_Mexico_East,          Proj_New_Mexico_CS83_East,
00158     PCS_NAD83_New_Mexico_Cent,          Proj_New_Mexico_CS83_Central,
00159     PCS_NAD83_New_Mexico_West,          Proj_New_Mexico_CS83_West,
00160 
00161     PCS_NAD83_New_York_East,            Proj_New_York_CS83_East,
00162     PCS_NAD83_New_York_Central,         Proj_New_York_CS83_Central,
00163     PCS_NAD83_New_York_West,            Proj_New_York_CS83_West,
00164     PCS_NAD83_New_York_Long_Is,         Proj_New_York_CS83_Long_Island,
00165 
00166     PCS_NAD83_North_Carolina,           Proj_North_Carolina_CS83,
00167 
00168     PCS_NAD83_North_Dakota_N,           Proj_North_Dakota_CS83_North,
00169     PCS_NAD83_North_Dakota_S,           Proj_North_Dakota_CS83_South,
00170 
00171     PCS_NAD83_Ohio_North,               Proj_Ohio_CS83_North,
00172     PCS_NAD83_Ohio_South,               Proj_Ohio_CS83_South,
00173 
00174     PCS_NAD83_Oklahoma_North,           Proj_Oklahoma_CS83_North,
00175     PCS_NAD83_Oklahoma_South,           Proj_Oklahoma_CS83_South,
00176 
00177     PCS_NAD83_Oregon_North,             Proj_Oregon_CS83_North,
00178     PCS_NAD83_Oregon_South,             Proj_Oregon_CS83_South,
00179 
00180     PCS_NAD83_Pennsylvania_N,           Proj_Pennsylvania_CS83_North,
00181     PCS_NAD83_Pennsylvania_S,           Proj_Pennsylvania_CS83_South,
00182 
00183     PCS_NAD83_Rhode_Island,             Proj_Rhode_Island_CS83,
00184 
00185     PCS_NAD83_South_Carolina,           Proj_South_Carolina_CS83,
00186 
00187     PCS_NAD83_South_Dakota_N,           Proj_South_Dakota_CS83_North,
00188     PCS_NAD83_South_Dakota_S,           Proj_South_Dakota_CS83_South,
00189 
00190     PCS_NAD83_Tennessee,                Proj_Tennessee_CS83,
00191 
00192     PCS_NAD83_Texas_North,              Proj_Texas_CS83_North,
00193     PCS_NAD83_Texas_North_Cen,          Proj_Texas_CS83_North_Central,
00194     PCS_NAD83_Texas_Central,            Proj_Texas_CS83_Central,
00195     PCS_NAD83_Texas_South_Cen,          Proj_Texas_CS83_South_Central,
00196     PCS_NAD83_Texas_South,              Proj_Texas_CS83_South,
00197 
00198     PCS_NAD83_Utah_North,               Proj_Utah_CS83_North,
00199     PCS_NAD83_Utah_Central,             Proj_Utah_CS83_Central,
00200     PCS_NAD83_Utah_South,               Proj_Utah_CS83_South,
00201 
00202     PCS_NAD83_Vermont,                  Proj_Vermont_CS83,
00203 
00204     PCS_NAD83_Virginia_North,           Proj_Virginia_CS83_North,
00205     PCS_NAD83_Virginia_South,           Proj_Virginia_CS83_South,
00206 
00207     PCS_NAD83_Washington_North,         Proj_Washington_CS83_North,
00208     PCS_NAD83_Washington_South,         Proj_Washington_CS83_South,
00209 
00210     PCS_NAD83_West_Virginia_N,          Proj_West_Virginia_CS83_North,
00211     PCS_NAD83_West_Virginia_S,          Proj_West_Virginia_CS83_South,
00212 
00213     PCS_NAD83_Wisconsin_North,          Proj_Wisconsin_CS83_North,
00214     PCS_NAD83_Wisconsin_Cen,            Proj_Wisconsin_CS83_Central,
00215     PCS_NAD83_Wisconsin_South,          Proj_Wisconsin_CS83_South,
00216 
00217     PCS_NAD83_Wyoming_East,             Proj_Wyoming_CS83_East,
00218     PCS_NAD83_Wyoming_E_Cen,            Proj_Wyoming_CS83_East_Central,
00219     PCS_NAD83_Wyoming_W_Cen,            Proj_Wyoming_CS83_West_Central,
00220     PCS_NAD83_Wyoming_West,             Proj_Wyoming_CS83_West,
00221     
00222     PCS_NAD83_Puerto_Rico_Virgin_Is,    Proj_Puerto_Rico_Virgin_Is,
00223 
00224     PCS_NAD27_Alabama_East,             Proj_Alabama_CS27_East,
00225     PCS_NAD27_Alabama_West,             Proj_Alabama_CS27_West,
00226 
00227     PCS_NAD27_Alaska_zone_1,            Proj_Alaska_CS27_1,
00228     PCS_NAD27_Alaska_zone_2,            Proj_Alaska_CS27_2,
00229     PCS_NAD27_Alaska_zone_3,            Proj_Alaska_CS27_3,
00230     PCS_NAD27_Alaska_zone_4,            Proj_Alaska_CS27_4,
00231     PCS_NAD27_Alaska_zone_5,            Proj_Alaska_CS27_5,
00232     PCS_NAD27_Alaska_zone_6,            Proj_Alaska_CS27_6,
00233     PCS_NAD27_Alaska_zone_7,            Proj_Alaska_CS27_7,
00234     PCS_NAD27_Alaska_zone_8,            Proj_Alaska_CS27_8,
00235     PCS_NAD27_Alaska_zone_9,            Proj_Alaska_CS27_9,
00236     PCS_NAD27_Alaska_zone_10,           Proj_Alaska_CS27_10,
00237 
00238     PCS_NAD27_California_I,             Proj_California_CS27_I,
00239     PCS_NAD27_California_II,            Proj_California_CS27_II,
00240     PCS_NAD27_California_III,           Proj_California_CS27_III,
00241     PCS_NAD27_California_IV,            Proj_California_CS27_IV,
00242     PCS_NAD27_California_V,             Proj_California_CS27_V,
00243     PCS_NAD27_California_VI,            Proj_California_CS27_VI,
00244     PCS_NAD27_California_VII,           Proj_California_CS27_VII,
00245 
00246     PCS_NAD27_Arizona_East,             Proj_Arizona_Coordinate_System_east,
00247     PCS_NAD27_Arizona_Central,          Proj_Arizona_Coordinate_System_Central,
00248     PCS_NAD27_Arizona_West,             Proj_Arizona_Coordinate_System_west,
00249 
00250     PCS_NAD27_Arkansas_North,           Proj_Arkansas_CS27_North,
00251     PCS_NAD27_Arkansas_South,           Proj_Arkansas_CS27_South,
00252 
00253     PCS_NAD27_Colorado_North,           Proj_Colorado_CS27_North,
00254     PCS_NAD27_Colorado_Central,         Proj_Colorado_CS27_Central,
00255     PCS_NAD27_Colorado_South,           Proj_Colorado_CS27_South,
00256 
00257     PCS_NAD27_Connecticut,              Proj_Connecticut_CS27,
00258 
00259     PCS_NAD27_Delaware,                 Proj_Delaware_CS27,
00260 
00261     PCS_NAD27_Florida_East,             Proj_Florida_CS27_East,
00262     PCS_NAD27_Florida_North,            Proj_Florida_CS27_North,
00263     PCS_NAD27_Florida_West,             Proj_Florida_CS27_West,
00264 
00265     PCS_NAD27_Hawaii_zone_1,            Proj_Hawaii_CS27_1,
00266     PCS_NAD27_Hawaii_zone_2,            Proj_Hawaii_CS27_2,
00267     PCS_NAD27_Hawaii_zone_3,            Proj_Hawaii_CS27_3,
00268     PCS_NAD27_Hawaii_zone_4,            Proj_Hawaii_CS27_4,
00269     PCS_NAD27_Hawaii_zone_5,            Proj_Hawaii_CS27_5,
00270 
00271     PCS_NAD27_Georgia_East,             Proj_Georgia_CS27_East,
00272     PCS_NAD27_Georgia_West,             Proj_Georgia_CS27_West,
00273 
00274     PCS_NAD27_Idaho_East,               Proj_Idaho_CS27_East,
00275     PCS_NAD27_Idaho_Central,            Proj_Idaho_CS27_Central,
00276     PCS_NAD27_Idaho_West,               Proj_Idaho_CS27_West,
00277 
00278     PCS_NAD27_Illinois_East,            Proj_Illinois_CS27_East,
00279     PCS_NAD27_Illinois_West,            Proj_Illinois_CS27_West,
00280 
00281     PCS_NAD27_Indiana_East,             Proj_Indiana_CS27_East,
00282     PCS_NAD27_Indiana_West,             Proj_Indiana_CS27_West,
00283 
00284     PCS_NAD27_Iowa_North,               Proj_Iowa_CS27_North,
00285     PCS_NAD27_Iowa_South,               Proj_Iowa_CS27_South,
00286 
00287     PCS_NAD27_Kansas_North,             Proj_Kansas_CS27_North,
00288     PCS_NAD27_Kansas_South,             Proj_Kansas_CS27_South,
00289 
00290     PCS_NAD27_Kentucky_North,           Proj_Kentucky_CS27_North,
00291     PCS_NAD27_Kentucky_South,           Proj_Kentucky_CS27_South,
00292 
00293     PCS_NAD27_Louisiana_North,          Proj_Louisiana_CS27_North,
00294     PCS_NAD27_Louisiana_South,          Proj_Louisiana_CS27_South,
00295 
00296     PCS_NAD27_Maine_East,               Proj_Maine_CS27_East,
00297     PCS_NAD27_Maine_West,               Proj_Maine_CS27_West,
00298 
00299     PCS_NAD27_Maryland,                 Proj_Maryland_CS27,
00300 
00301     PCS_NAD27_Massachusetts,            Proj_Massachusetts_CS27_Mainland,
00302     PCS_NAD27_Massachusetts_Is,         Proj_Massachusetts_CS27_Island,
00303 
00304     PCS_NAD27_Michigan_North,           Proj_Michigan_CS27_North,
00305     PCS_NAD27_Michigan_Central,         Proj_Michigan_CS27_Central,
00306     PCS_NAD27_Michigan_South,           Proj_Michigan_CS27_South,
00307 
00308     PCS_NAD27_Minnesota_North,          Proj_Minnesota_CS27_North,
00309     PCS_NAD27_Minnesota_Cent,           Proj_Minnesota_CS27_Central,
00310     PCS_NAD27_Minnesota_South,          Proj_Minnesota_CS27_South,
00311 
00312     PCS_NAD27_Mississippi_East,         Proj_Mississippi_CS27_East,
00313     PCS_NAD27_Mississippi_West,         Proj_Mississippi_CS27_West,
00314 
00315     PCS_NAD27_Missouri_East,            Proj_Missouri_CS27_East,
00316     PCS_NAD27_Missouri_Central,         Proj_Missouri_CS27_Central,
00317     PCS_NAD27_Missouri_West,            Proj_Missouri_CS27_West,
00318 
00319     PCS_NAD27_Montana_North,            Proj_Montana_CS27_North,
00320     PCS_NAD27_Montana_Central,          Proj_Montana_CS27_Central,
00321     PCS_NAD27_Montana_South,            Proj_Montana_CS27_South,
00322 
00323     PCS_NAD27_Nebraska_North,           Proj_Nebraska_CS27_North,
00324     PCS_NAD27_Nebraska_South,           Proj_Nebraska_CS27_South,
00325 
00326     PCS_NAD27_Nevada_East,              Proj_Nevada_CS27_East,
00327     PCS_NAD27_Nevada_Central,           Proj_Nevada_CS27_Central,
00328     PCS_NAD27_Nevada_West,              Proj_Nevada_CS27_West,
00329 
00330     PCS_NAD27_New_Hampshire,            Proj_New_Hampshire_CS27,
00331 
00332     PCS_NAD27_New_Jersey,               Proj_New_Jersey_CS27,
00333 
00334     PCS_NAD27_New_Mexico_East,          Proj_New_Mexico_CS27_East,
00335     PCS_NAD27_New_Mexico_Cent,          Proj_New_Mexico_CS27_Central,
00336     PCS_NAD27_New_Mexico_West,          Proj_New_Mexico_CS27_West,
00337 
00338     PCS_NAD27_New_York_East,            Proj_New_York_CS27_East,
00339     PCS_NAD27_New_York_Central,         Proj_New_York_CS27_Central,
00340     PCS_NAD27_New_York_West,            Proj_New_York_CS27_West,
00341     PCS_NAD27_New_York_Long_Is,         Proj_New_York_CS27_Long_Island,
00342 
00343     PCS_NAD27_North_Carolina,           Proj_North_Carolina_CS27,
00344 
00345     PCS_NAD27_North_Dakota_N,           Proj_North_Dakota_CS27_North,
00346     PCS_NAD27_North_Dakota_S,           Proj_North_Dakota_CS27_South,
00347 
00348     PCS_NAD27_Ohio_North,               Proj_Ohio_CS27_North,
00349     PCS_NAD27_Ohio_South,               Proj_Ohio_CS27_South,
00350 
00351     PCS_NAD27_Oklahoma_North,           Proj_Oklahoma_CS27_North,
00352     PCS_NAD27_Oklahoma_South,           Proj_Oklahoma_CS27_South,
00353 
00354     PCS_NAD27_Oregon_North,             Proj_Oregon_CS27_North,
00355     PCS_NAD27_Oregon_South,             Proj_Oregon_CS27_South,
00356 
00357     PCS_NAD27_Pennsylvania_N,           Proj_Pennsylvania_CS27_North,
00358     PCS_NAD27_Pennsylvania_S,           Proj_Pennsylvania_CS27_South,
00359 
00360     PCS_NAD27_Rhode_Island,             Proj_Rhode_Island_CS27,
00361 
00362     PCS_NAD27_South_Carolina_N,         Proj_South_Carolina_CS27_North,
00363     PCS_NAD27_South_Carolina_S,         Proj_South_Carolina_CS27_South,
00364 
00365     PCS_NAD27_South_Dakota_N,           Proj_South_Dakota_CS27_North,
00366     PCS_NAD27_South_Dakota_S,           Proj_South_Dakota_CS27_South,
00367 
00368     PCS_NAD27_Tennessee,                Proj_Tennessee_CS27,
00369 
00370     PCS_NAD27_Texas_North,              Proj_Texas_CS27_North,
00371     PCS_NAD27_Texas_North_Cen,          Proj_Texas_CS27_North_Central,
00372     PCS_NAD27_Texas_Central,            Proj_Texas_CS27_Central,
00373     PCS_NAD27_Texas_South_Cen,          Proj_Texas_CS27_South_Central,
00374     PCS_NAD27_Texas_South,              Proj_Texas_CS27_South,
00375 
00376     PCS_NAD27_Utah_North,               Proj_Utah_CS27_North,
00377     PCS_NAD27_Utah_Central,             Proj_Utah_CS27_Central,
00378     PCS_NAD27_Utah_South,               Proj_Utah_CS27_South,
00379 
00380     PCS_NAD27_Vermont,                  Proj_Vermont_CS27,
00381 
00382     PCS_NAD27_Virginia_North,           Proj_Virginia_CS27_North,
00383     PCS_NAD27_Virginia_South,           Proj_Virginia_CS27_South,
00384 
00385     PCS_NAD27_Washington_North,         Proj_Washington_CS27_North,
00386     PCS_NAD27_Washington_South,         Proj_Washington_CS27_South,
00387 
00388     PCS_NAD27_West_Virginia_N,          Proj_West_Virginia_CS27_North,
00389     PCS_NAD27_West_Virginia_S,          Proj_West_Virginia_CS27_South,
00390 
00391     PCS_NAD27_Wisconsin_North,          Proj_Wisconsin_CS27_North,
00392     PCS_NAD27_Wisconsin_Cen,            Proj_Wisconsin_CS27_Central,
00393     PCS_NAD27_Wisconsin_South,          Proj_Wisconsin_CS27_South,
00394 
00395     PCS_NAD27_Wyoming_East,             Proj_Wyoming_CS27_East,
00396     PCS_NAD27_Wyoming_E_Cen,            Proj_Wyoming_CS27_East_Central,
00397     PCS_NAD27_Wyoming_W_Cen,            Proj_Wyoming_CS27_West_Central,
00398     PCS_NAD27_Wyoming_West,             Proj_Wyoming_CS27_West,
00399     
00400     PCS_NAD27_Puerto_Rico,              Proj_Puerto_Rico_CS27,
00401 
00402     KvUserDefined
00403 };
00404 
00405 /************************************************************************/
00406 /*                          GTIFMapSysToPCS()                           */
00407 /*                                                                      */
00408 /*      Given a Datum, MapSys and zone value generate the best PCS      */
00409 /*      code possible.                                                  */
00410 /************************************************************************/
00411 
00412 int     GTIFMapSysToPCS( int MapSys, int Datum, int nZone )
00413 
00414 {
00415     int         PCSCode = KvUserDefined;
00416 
00417     if( MapSys == MapSys_UTM_North )
00418     {
00419         if( Datum == GCS_NAD27 )
00420             PCSCode = PCS_NAD27_UTM_zone_3N + nZone - 3;
00421         else if( Datum == GCS_NAD83 )
00422             PCSCode = PCS_NAD83_UTM_zone_3N + nZone - 3;
00423         else if( Datum == GCS_WGS_72 )
00424             PCSCode = PCS_WGS72_UTM_zone_1N + nZone - 1;
00425         else if( Datum == GCS_WGS_72BE )
00426             PCSCode = PCS_WGS72BE_UTM_zone_1N + nZone - 1;
00427         else if( Datum == GCS_WGS_84 )
00428             PCSCode = PCS_WGS84_UTM_zone_1N + nZone - 1;
00429     }
00430     else if( MapSys == MapSys_UTM_South )
00431     {
00432         if( Datum == GCS_WGS_72 )
00433             PCSCode = PCS_WGS72_UTM_zone_1S + nZone - 1;
00434         else if( Datum == GCS_WGS_72BE )
00435             PCSCode = PCS_WGS72BE_UTM_zone_1S + nZone - 1;
00436         else if( Datum == GCS_WGS_84 )
00437             PCSCode = PCS_WGS84_UTM_zone_1S + nZone - 1;
00438     }
00439     else if( MapSys == MapSys_State_Plane_27 )
00440     {
00441         int             i;
00442 
00443         PCSCode = 10000 + nZone;
00444 
00445         for( i = 0; StatePlaneTable[i] != KvUserDefined; i += 2 )
00446         {
00447             if( StatePlaneTable[i+1] == PCSCode )
00448                 PCSCode = StatePlaneTable[i];
00449         }
00450     }
00451     else if( MapSys == MapSys_State_Plane_83 )
00452     {
00453         int             i;
00454 
00455         PCSCode = 10000 + nZone + 30;
00456 
00457         for( i = 0; StatePlaneTable[i] != KvUserDefined; i += 2 )
00458         {
00459             if( StatePlaneTable[i+1] == PCSCode )
00460                 PCSCode = StatePlaneTable[i];
00461         }
00462     }
00463 
00464     return( PCSCode );
00465 }
00466 
00467 /************************************************************************/
00468 /*                          GTIFMapSysToProj()                          */
00469 /*                                                                      */
00470 /*      Given a MapSys and zone value generate the best Proj_           */
00471 /*      code possible.                                                  */
00472 /************************************************************************/
00473 
00474 int     GTIFMapSysToProj( int MapSys, int nZone )
00475 
00476 {
00477     int         ProjCode = KvUserDefined;
00478 
00479     if( MapSys == MapSys_UTM_North )
00480     {
00481         ProjCode = Proj_UTM_zone_1N + nZone - 1;
00482     }
00483     else if( MapSys == MapSys_UTM_South )
00484     {
00485         ProjCode = Proj_UTM_zone_1S + nZone - 1;
00486     }
00487     else if( MapSys == MapSys_State_Plane_27 )
00488     {
00489         ProjCode = 10000 + nZone;
00490     }
00491     else if( MapSys == MapSys_State_Plane_83 )
00492     {
00493         ProjCode = 10000 + nZone + 30;
00494     }
00495 
00496     return( ProjCode );
00497 }
00498 
00499 /************************************************************************/
00500 /*                          GTIFPCSToMapSys()                           */
00501 /************************************************************************/
00502 
00534 int GTIFPCSToMapSys( int PCSCode, int * pDatum, int * pZone )
00535 
00536 {
00537     int         Datum = KvUserDefined, Proj = KvUserDefined;
00538     int         nZone = KvUserDefined, i;
00539 
00540 /* -------------------------------------------------------------------- */
00541 /*      UTM with various datums.  Note there are lots of PCS UTM        */
00542 /*      codes not done yet which use strange datums.                    */
00543 /* -------------------------------------------------------------------- */
00544     if( PCSCode >= PCS_NAD27_UTM_zone_3N && PCSCode <= PCS_NAD27_UTM_zone_22N )
00545     {
00546         Datum = GCS_NAD27;
00547         Proj = MapSys_UTM_North;
00548         nZone = PCSCode - PCS_NAD27_UTM_zone_3N + 3;
00549     }
00550     else if( PCSCode >= PCS_NAD83_UTM_zone_3N 
00551              && PCSCode <= PCS_NAD83_UTM_zone_23N )
00552     {
00553         Datum = GCS_NAD83;
00554         Proj = MapSys_UTM_North;
00555         nZone = PCSCode - PCS_NAD83_UTM_zone_3N + 3;
00556     }
00557 
00558     else if( PCSCode >= PCS_WGS72_UTM_zone_1N
00559              && PCSCode <= PCS_WGS72_UTM_zone_60N )
00560     {
00561         Datum = GCS_WGS_72;
00562         Proj = MapSys_UTM_North;
00563         nZone = PCSCode - PCS_WGS72_UTM_zone_1N + 1;
00564     }
00565     else if( PCSCode >= PCS_WGS72_UTM_zone_1S
00566              && PCSCode <= PCS_WGS72_UTM_zone_60S )
00567     {
00568         Datum = GCS_WGS_72;
00569         Proj = MapSys_UTM_South;
00570         nZone = PCSCode - PCS_WGS72_UTM_zone_1S + 1;
00571     }
00572 
00573     else if( PCSCode >= PCS_WGS72BE_UTM_zone_1N
00574              && PCSCode <= PCS_WGS72BE_UTM_zone_60N )
00575     {
00576         Datum = GCS_WGS_72BE;
00577         Proj = MapSys_UTM_North;
00578         nZone = PCSCode - PCS_WGS72BE_UTM_zone_1N + 1;
00579     }
00580     else if( PCSCode >= PCS_WGS72BE_UTM_zone_1S
00581              && PCSCode <= PCS_WGS72BE_UTM_zone_60S )
00582     {
00583         Datum = GCS_WGS_72BE;
00584         Proj = MapSys_UTM_South;
00585         nZone = PCSCode - PCS_WGS72BE_UTM_zone_1S + 1;
00586     }
00587 
00588     else if( PCSCode >= PCS_WGS84_UTM_zone_1N
00589              && PCSCode <= PCS_WGS84_UTM_zone_60N )
00590     {
00591         Datum = GCS_WGS_84;
00592         Proj = MapSys_UTM_North;
00593         nZone = PCSCode - PCS_WGS84_UTM_zone_1N + 1;
00594     }
00595     else if( PCSCode >= PCS_WGS84_UTM_zone_1S
00596              && PCSCode <= PCS_WGS84_UTM_zone_60S )
00597     {
00598         Datum = GCS_WGS_84;
00599         Proj = MapSys_UTM_South;
00600         nZone = PCSCode - PCS_WGS84_UTM_zone_1S + 1;
00601     }
00602     else if( PCSCode >= PCS_SAD69_UTM_zone_18N 
00603              && PCSCode <= PCS_SAD69_UTM_zone_22N )
00604     {
00605         Datum = KvUserDefined;
00606         Proj = MapSys_UTM_North;
00607         nZone = PCSCode - PCS_SAD69_UTM_zone_18N + 18;
00608     }
00609     else if( PCSCode >= PCS_SAD69_UTM_zone_17S
00610              && PCSCode <= PCS_SAD69_UTM_zone_25S )
00611     {
00612         Datum = KvUserDefined;
00613         Proj = MapSys_UTM_South;
00614         nZone = PCSCode - PCS_SAD69_UTM_zone_17S + 17;
00615     }
00616 
00617 /* -------------------------------------------------------------------- */
00618 /*      State Plane zones, first we translate any PCS_ codes to         */
00619 /*      a Proj_ code that we can get a handle on.                       */
00620 /* -------------------------------------------------------------------- */
00621     for( i = 0; StatePlaneTable[i] != KvUserDefined; i += 2 )
00622     {
00623         if( StatePlaneTable[i] == PCSCode )
00624             PCSCode = StatePlaneTable[i+1];
00625     }
00626 
00627     if( PCSCode <= 15900 && PCSCode >= 10000 )
00628     {
00629         if( (PCSCode % 100) >= 30 )
00630         {
00631             Proj = MapSys_State_Plane_83;
00632             Datum = GCS_NAD83;
00633         }
00634         else
00635         {
00636             Proj = MapSys_State_Plane_27;
00637             Datum = GCS_NAD27;
00638         }
00639         
00640         nZone = PCSCode - 10000;
00641         if( Datum == GCS_NAD83 )
00642             nZone -= 30;
00643     }
00644 
00645     if( pDatum != NULL )
00646         *pDatum = Datum;
00647 
00648     if( pZone != NULL )
00649         *pZone = nZone;
00650 
00651     return( Proj );
00652 }
00653 
00654 /************************************************************************/
00655 /*                          GTIFProjToMapSys()                          */
00656 /************************************************************************/
00657 
00683 int GTIFProjToMapSys( int ProjCode, int * pZone )
00684 
00685 {
00686     int         nZone = KvUserDefined;
00687     int         MapSys = KvUserDefined;
00688 
00689 /* -------------------------------------------------------------------- */
00690 /*      Handle UTM.                                                     */
00691 /* -------------------------------------------------------------------- */
00692     if( ProjCode >= Proj_UTM_zone_1N && ProjCode <= Proj_UTM_zone_60N )
00693     {
00694         MapSys = MapSys_UTM_North;
00695         nZone = ProjCode - Proj_UTM_zone_1N + 1;
00696     }
00697     else if( ProjCode >= Proj_UTM_zone_1S && ProjCode <= Proj_UTM_zone_60S )
00698     {
00699         MapSys = MapSys_UTM_South;
00700         nZone = ProjCode - Proj_UTM_zone_1S + 1;
00701     }
00702 
00703 /* -------------------------------------------------------------------- */
00704 /*      Handle State Plane.  I think there are some anomolies in        */
00705 /*      here, so this is a bit risky.                                   */
00706 /* -------------------------------------------------------------------- */
00707     else if( ProjCode >= 10101 && ProjCode <= 15299 )
00708     {
00709         if( ProjCode % 100 >= 30 )
00710         {
00711             MapSys = MapSys_State_Plane_83;
00712             nZone = ProjCode - 10000 - 30;
00713         }
00714         else
00715         {
00716             MapSys = MapSys_State_Plane_27;
00717             nZone = ProjCode - 10000;
00718         }
00719     }
00720     
00721     if( pZone != NULL )
00722         *pZone = nZone;
00723 
00724     return( MapSys );
00725 }
00726 

Generated at Sun Mar 4 23:32:44 2001 for libgeotiff by doxygen1.2.3-20001105 written by Dimitri van Heesch, © 1997-2000