1
/******************************************************************************
2
* $Id: geo_extra.c,v 1.2 2004/03/19 11:51:23 lubia Exp $
5
* Purpose: Code to normalize a few common PCS values without use of CSV
7
* Author: Frank Warmerdam, warmerda@home.com
9
******************************************************************************
10
* Copyright (c) 1999, Frank Warmerdam
12
* Permission is hereby granted, free of charge, to any person obtaining a
13
* copy of this software and associated documentation files (the "Software"),
14
* to deal in the Software without restriction, including without limitation
15
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
16
* and/or sell copies of the Software, and to permit persons to whom the
17
* Software is furnished to do so, subject to the following conditions:
19
* The above copyright notice and this permission notice shall be included
20
* in all copies or substantial portions of the Software.
22
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28
* DEALINGS IN THE SOFTWARE.
29
******************************************************************************
31
* $Log: geo_extra.c,v $
32
* Revision 1.2 2004/03/19 11:51:23 lubia
33
* Atualizada as bibliotecas Tif e GeoTif
35
* Revision 1.4 2002/12/01 23:44:34 warmerda
36
* Fixed typo in last fix.
38
* Revision 1.3 2002/12/01 23:42:06 warmerda
39
* added overrides for two deprecated stateplane zones
41
* Revision 1.2 1999/05/04 03:09:33 warmerda
44
* Revision 1.1 1999/04/28 20:01:29 warmerda
51
#include "geo_tiffp.h"
55
#include "geo_normalize.h"
56
#include "geovalues.h"
58
static int StatePlaneTable[] =
60
PCS_NAD83_Alabama_East, Proj_Alabama_CS83_East,
61
PCS_NAD83_Alabama_West, Proj_Alabama_CS83_West,
63
PCS_NAD83_Alaska_zone_1, Proj_Alaska_CS83_1,
64
PCS_NAD83_Alaska_zone_2, Proj_Alaska_CS83_2,
65
PCS_NAD83_Alaska_zone_3, Proj_Alaska_CS83_3,
66
PCS_NAD83_Alaska_zone_4, Proj_Alaska_CS83_4,
67
PCS_NAD83_Alaska_zone_5, Proj_Alaska_CS83_5,
68
PCS_NAD83_Alaska_zone_6, Proj_Alaska_CS83_6,
69
PCS_NAD83_Alaska_zone_7, Proj_Alaska_CS83_7,
70
PCS_NAD83_Alaska_zone_8, Proj_Alaska_CS83_8,
71
PCS_NAD83_Alaska_zone_9, Proj_Alaska_CS83_9,
72
PCS_NAD83_Alaska_zone_10, Proj_Alaska_CS83_10,
74
PCS_NAD83_California_1, Proj_California_CS83_1,
75
PCS_NAD83_California_2, Proj_California_CS83_2,
76
PCS_NAD83_California_3, Proj_California_CS83_3,
77
PCS_NAD83_California_4, Proj_California_CS83_4,
78
PCS_NAD83_California_5, Proj_California_CS83_5,
79
PCS_NAD83_California_6, Proj_California_CS83_6,
81
PCS_NAD83_Arizona_East, Proj_Arizona_CS83_east,
82
PCS_NAD83_Arizona_Central, Proj_Arizona_CS83_Central,
83
PCS_NAD83_Arizona_West, Proj_Arizona_CS83_west,
85
PCS_NAD83_Arkansas_North, Proj_Arkansas_CS83_North,
86
PCS_NAD83_Arkansas_South, Proj_Arkansas_CS83_South,
88
PCS_NAD83_Colorado_North, Proj_Colorado_CS83_North,
89
PCS_NAD83_Colorado_Central, Proj_Colorado_CS83_Central,
90
PCS_NAD83_Colorado_South, Proj_Colorado_CS83_South,
92
PCS_NAD83_Connecticut, Proj_Connecticut_CS83,
94
PCS_NAD83_Delaware, Proj_Delaware_CS83,
96
PCS_NAD83_Florida_East, Proj_Florida_CS83_East,
97
PCS_NAD83_Florida_North, Proj_Florida_CS83_North,
98
PCS_NAD83_Florida_West, Proj_Florida_CS83_West,
100
PCS_NAD83_Hawaii_zone_1, Proj_Hawaii_CS83_1,
101
PCS_NAD83_Hawaii_zone_2, Proj_Hawaii_CS83_2,
102
PCS_NAD83_Hawaii_zone_3, Proj_Hawaii_CS83_3,
103
PCS_NAD83_Hawaii_zone_4, Proj_Hawaii_CS83_4,
104
PCS_NAD83_Hawaii_zone_5, Proj_Hawaii_CS83_5,
106
PCS_NAD83_Georgia_East, Proj_Georgia_CS83_East,
107
PCS_NAD83_Georgia_West, Proj_Georgia_CS83_West,
109
PCS_NAD83_Idaho_East, Proj_Idaho_CS83_East,
110
PCS_NAD83_Idaho_Central, Proj_Idaho_CS83_Central,
111
PCS_NAD83_Idaho_West, Proj_Idaho_CS83_West,
113
PCS_NAD83_Illinois_East, Proj_Illinois_CS83_East,
114
PCS_NAD83_Illinois_West, Proj_Illinois_CS83_West,
116
PCS_NAD83_Indiana_East, Proj_Indiana_CS83_East,
117
PCS_NAD83_Indiana_West, Proj_Indiana_CS83_West,
119
PCS_NAD83_Iowa_North, Proj_Iowa_CS83_North,
120
PCS_NAD83_Iowa_South, Proj_Iowa_CS83_South,
122
PCS_NAD83_Kansas_North, Proj_Kansas_CS83_North,
123
PCS_NAD83_Kansas_South, Proj_Kansas_CS83_South,
125
PCS_NAD83_Kentucky_North, Proj_Kentucky_CS83_North,
126
PCS_NAD83_Kentucky_South, Proj_Kentucky_CS83_South,
128
PCS_NAD83_Louisiana_North, Proj_Louisiana_CS83_North,
129
PCS_NAD83_Louisiana_South, Proj_Louisiana_CS83_South,
131
PCS_NAD83_Maine_East, Proj_Maine_CS83_East,
132
PCS_NAD83_Maine_West, Proj_Maine_CS83_West,
134
PCS_NAD83_Maryland, Proj_Maryland_CS83,
136
PCS_NAD83_Massachusetts, Proj_Massachusetts_CS83_Mainland,
137
PCS_NAD83_Massachusetts_Is, Proj_Massachusetts_CS83_Island,
139
PCS_NAD83_Michigan_North, Proj_Michigan_CS83_North,
140
PCS_NAD83_Michigan_Central, Proj_Michigan_CS83_Central,
141
PCS_NAD83_Michigan_South, Proj_Michigan_CS83_South,
143
PCS_NAD83_Minnesota_North, Proj_Minnesota_CS83_North,
144
PCS_NAD83_Minnesota_Cent, Proj_Minnesota_CS83_Central,
145
PCS_NAD83_Minnesota_South, Proj_Minnesota_CS83_South,
147
PCS_NAD83_Mississippi_East, Proj_Mississippi_CS83_East,
148
PCS_NAD83_Mississippi_West, Proj_Mississippi_CS83_West,
150
PCS_NAD83_Missouri_East, Proj_Missouri_CS83_East,
151
PCS_NAD83_Missouri_Central, Proj_Missouri_CS83_Central,
152
PCS_NAD83_Missouri_West, Proj_Missouri_CS83_West,
154
PCS_NAD83_Montana, Proj_Montana_CS83,
156
PCS_NAD83_Nebraska, Proj_Nebraska_CS83,
158
PCS_NAD83_Nevada_East, Proj_Nevada_CS83_East,
159
PCS_NAD83_Nevada_Central, Proj_Nevada_CS83_Central,
160
PCS_NAD83_Nevada_West, Proj_Nevada_CS83_West,
162
PCS_NAD83_New_Hampshire, Proj_New_Hampshire_CS83,
164
PCS_NAD83_New_Jersey, Proj_New_Jersey_CS83,
166
PCS_NAD83_New_Mexico_East, Proj_New_Mexico_CS83_East,
167
PCS_NAD83_New_Mexico_Cent, Proj_New_Mexico_CS83_Central,
168
PCS_NAD83_New_Mexico_West, Proj_New_Mexico_CS83_West,
170
PCS_NAD83_New_York_East, Proj_New_York_CS83_East,
171
PCS_NAD83_New_York_Central, Proj_New_York_CS83_Central,
172
PCS_NAD83_New_York_West, Proj_New_York_CS83_West,
173
PCS_NAD83_New_York_Long_Is, Proj_New_York_CS83_Long_Island,
175
PCS_NAD83_North_Carolina, Proj_North_Carolina_CS83,
177
PCS_NAD83_North_Dakota_N, Proj_North_Dakota_CS83_North,
178
PCS_NAD83_North_Dakota_S, Proj_North_Dakota_CS83_South,
180
PCS_NAD83_Ohio_North, Proj_Ohio_CS83_North,
181
PCS_NAD83_Ohio_South, Proj_Ohio_CS83_South,
183
PCS_NAD83_Oklahoma_North, Proj_Oklahoma_CS83_North,
184
PCS_NAD83_Oklahoma_South, Proj_Oklahoma_CS83_South,
186
PCS_NAD83_Oregon_North, Proj_Oregon_CS83_North,
187
PCS_NAD83_Oregon_South, Proj_Oregon_CS83_South,
189
PCS_NAD83_Pennsylvania_N, Proj_Pennsylvania_CS83_North,
190
PCS_NAD83_Pennsylvania_S, Proj_Pennsylvania_CS83_South,
192
PCS_NAD83_Rhode_Island, Proj_Rhode_Island_CS83,
194
PCS_NAD83_South_Carolina, Proj_South_Carolina_CS83,
196
PCS_NAD83_South_Dakota_N, Proj_South_Dakota_CS83_North,
197
PCS_NAD83_South_Dakota_S, Proj_South_Dakota_CS83_South,
199
PCS_NAD83_Tennessee, Proj_Tennessee_CS83,
201
PCS_NAD83_Texas_North, Proj_Texas_CS83_North,
202
PCS_NAD83_Texas_North_Cen, Proj_Texas_CS83_North_Central,
203
PCS_NAD83_Texas_Central, Proj_Texas_CS83_Central,
204
PCS_NAD83_Texas_South_Cen, Proj_Texas_CS83_South_Central,
205
PCS_NAD83_Texas_South, Proj_Texas_CS83_South,
207
PCS_NAD83_Utah_North, Proj_Utah_CS83_North,
208
PCS_NAD83_Utah_Central, Proj_Utah_CS83_Central,
209
PCS_NAD83_Utah_South, Proj_Utah_CS83_South,
211
PCS_NAD83_Vermont, Proj_Vermont_CS83,
213
PCS_NAD83_Virginia_North, Proj_Virginia_CS83_North,
214
PCS_NAD83_Virginia_South, Proj_Virginia_CS83_South,
216
PCS_NAD83_Washington_North, Proj_Washington_CS83_North,
217
PCS_NAD83_Washington_South, Proj_Washington_CS83_South,
219
PCS_NAD83_West_Virginia_N, Proj_West_Virginia_CS83_North,
220
PCS_NAD83_West_Virginia_S, Proj_West_Virginia_CS83_South,
222
PCS_NAD83_Wisconsin_North, Proj_Wisconsin_CS83_North,
223
PCS_NAD83_Wisconsin_Cen, Proj_Wisconsin_CS83_Central,
224
PCS_NAD83_Wisconsin_South, Proj_Wisconsin_CS83_South,
226
PCS_NAD83_Wyoming_East, Proj_Wyoming_CS83_East,
227
PCS_NAD83_Wyoming_E_Cen, Proj_Wyoming_CS83_East_Central,
228
PCS_NAD83_Wyoming_W_Cen, Proj_Wyoming_CS83_West_Central,
229
PCS_NAD83_Wyoming_West, Proj_Wyoming_CS83_West,
231
PCS_NAD83_Puerto_Rico_Virgin_Is, Proj_Puerto_Rico_Virgin_Is,
233
PCS_NAD27_Alabama_East, Proj_Alabama_CS27_East,
234
PCS_NAD27_Alabama_West, Proj_Alabama_CS27_West,
236
PCS_NAD27_Alaska_zone_1, Proj_Alaska_CS27_1,
237
PCS_NAD27_Alaska_zone_2, Proj_Alaska_CS27_2,
238
PCS_NAD27_Alaska_zone_3, Proj_Alaska_CS27_3,
239
PCS_NAD27_Alaska_zone_4, Proj_Alaska_CS27_4,
240
PCS_NAD27_Alaska_zone_5, Proj_Alaska_CS27_5,
241
PCS_NAD27_Alaska_zone_6, Proj_Alaska_CS27_6,
242
PCS_NAD27_Alaska_zone_7, Proj_Alaska_CS27_7,
243
PCS_NAD27_Alaska_zone_8, Proj_Alaska_CS27_8,
244
PCS_NAD27_Alaska_zone_9, Proj_Alaska_CS27_9,
245
PCS_NAD27_Alaska_zone_10, Proj_Alaska_CS27_10,
247
PCS_NAD27_California_I, Proj_California_CS27_I,
248
PCS_NAD27_California_II, Proj_California_CS27_II,
249
PCS_NAD27_California_III, Proj_California_CS27_III,
250
PCS_NAD27_California_IV, Proj_California_CS27_IV,
251
PCS_NAD27_California_V, Proj_California_CS27_V,
252
PCS_NAD27_California_VI, Proj_California_CS27_VI,
253
PCS_NAD27_California_VII, Proj_California_CS27_VII,
255
PCS_NAD27_Arizona_East, Proj_Arizona_Coordinate_System_east,
256
PCS_NAD27_Arizona_Central, Proj_Arizona_Coordinate_System_Central,
257
PCS_NAD27_Arizona_West, Proj_Arizona_Coordinate_System_west,
259
PCS_NAD27_Arkansas_North, Proj_Arkansas_CS27_North,
260
PCS_NAD27_Arkansas_South, Proj_Arkansas_CS27_South,
262
PCS_NAD27_Colorado_North, Proj_Colorado_CS27_North,
263
PCS_NAD27_Colorado_Central, Proj_Colorado_CS27_Central,
264
PCS_NAD27_Colorado_South, Proj_Colorado_CS27_South,
266
PCS_NAD27_Connecticut, Proj_Connecticut_CS27,
268
PCS_NAD27_Delaware, Proj_Delaware_CS27,
270
PCS_NAD27_Florida_East, Proj_Florida_CS27_East,
271
PCS_NAD27_Florida_North, Proj_Florida_CS27_North,
272
PCS_NAD27_Florida_West, Proj_Florida_CS27_West,
274
PCS_NAD27_Hawaii_zone_1, Proj_Hawaii_CS27_1,
275
PCS_NAD27_Hawaii_zone_2, Proj_Hawaii_CS27_2,
276
PCS_NAD27_Hawaii_zone_3, Proj_Hawaii_CS27_3,
277
PCS_NAD27_Hawaii_zone_4, Proj_Hawaii_CS27_4,
278
PCS_NAD27_Hawaii_zone_5, Proj_Hawaii_CS27_5,
280
PCS_NAD27_Georgia_East, Proj_Georgia_CS27_East,
281
PCS_NAD27_Georgia_West, Proj_Georgia_CS27_West,
283
PCS_NAD27_Idaho_East, Proj_Idaho_CS27_East,
284
PCS_NAD27_Idaho_Central, Proj_Idaho_CS27_Central,
285
PCS_NAD27_Idaho_West, Proj_Idaho_CS27_West,
287
PCS_NAD27_Illinois_East, Proj_Illinois_CS27_East,
288
PCS_NAD27_Illinois_West, Proj_Illinois_CS27_West,
290
PCS_NAD27_Indiana_East, Proj_Indiana_CS27_East,
291
PCS_NAD27_Indiana_West, Proj_Indiana_CS27_West,
293
PCS_NAD27_Iowa_North, Proj_Iowa_CS27_North,
294
PCS_NAD27_Iowa_South, Proj_Iowa_CS27_South,
296
PCS_NAD27_Kansas_North, Proj_Kansas_CS27_North,
297
PCS_NAD27_Kansas_South, Proj_Kansas_CS27_South,
299
PCS_NAD27_Kentucky_North, Proj_Kentucky_CS27_North,
300
PCS_NAD27_Kentucky_South, Proj_Kentucky_CS27_South,
302
PCS_NAD27_Louisiana_North, Proj_Louisiana_CS27_North,
303
PCS_NAD27_Louisiana_South, Proj_Louisiana_CS27_South,
305
PCS_NAD27_Maine_East, Proj_Maine_CS27_East,
306
PCS_NAD27_Maine_West, Proj_Maine_CS27_West,
308
PCS_NAD27_Maryland, Proj_Maryland_CS27,
310
PCS_NAD27_Massachusetts, Proj_Massachusetts_CS27_Mainland,
311
PCS_NAD27_Massachusetts_Is, Proj_Massachusetts_CS27_Island,
313
PCS_NAD27_Michigan_North, Proj_Michigan_CS27_North,
314
PCS_NAD27_Michigan_Central, Proj_Michigan_CS27_Central,
315
PCS_NAD27_Michigan_South, Proj_Michigan_CS27_South,
317
PCS_NAD27_Minnesota_North, Proj_Minnesota_CS27_North,
318
PCS_NAD27_Minnesota_Cent, Proj_Minnesota_CS27_Central,
319
PCS_NAD27_Minnesota_South, Proj_Minnesota_CS27_South,
321
PCS_NAD27_Mississippi_East, Proj_Mississippi_CS27_East,
322
PCS_NAD27_Mississippi_West, Proj_Mississippi_CS27_West,
324
PCS_NAD27_Missouri_East, Proj_Missouri_CS27_East,
325
PCS_NAD27_Missouri_Central, Proj_Missouri_CS27_Central,
326
PCS_NAD27_Missouri_West, Proj_Missouri_CS27_West,
328
PCS_NAD27_Montana_North, Proj_Montana_CS27_North,
329
PCS_NAD27_Montana_Central, Proj_Montana_CS27_Central,
330
PCS_NAD27_Montana_South, Proj_Montana_CS27_South,
332
PCS_NAD27_Nebraska_North, Proj_Nebraska_CS27_North,
333
PCS_NAD27_Nebraska_South, Proj_Nebraska_CS27_South,
335
PCS_NAD27_Nevada_East, Proj_Nevada_CS27_East,
336
PCS_NAD27_Nevada_Central, Proj_Nevada_CS27_Central,
337
PCS_NAD27_Nevada_West, Proj_Nevada_CS27_West,
339
PCS_NAD27_New_Hampshire, Proj_New_Hampshire_CS27,
341
PCS_NAD27_New_Jersey, Proj_New_Jersey_CS27,
343
PCS_NAD27_New_Mexico_East, Proj_New_Mexico_CS27_East,
344
PCS_NAD27_New_Mexico_Cent, Proj_New_Mexico_CS27_Central,
345
PCS_NAD27_New_Mexico_West, Proj_New_Mexico_CS27_West,
347
PCS_NAD27_New_York_East, Proj_New_York_CS27_East,
348
PCS_NAD27_New_York_Central, Proj_New_York_CS27_Central,
349
PCS_NAD27_New_York_West, Proj_New_York_CS27_West,
350
PCS_NAD27_New_York_Long_Is, Proj_New_York_CS27_Long_Island,
352
PCS_NAD27_North_Carolina, Proj_North_Carolina_CS27,
354
PCS_NAD27_North_Dakota_N, Proj_North_Dakota_CS27_North,
355
PCS_NAD27_North_Dakota_S, Proj_North_Dakota_CS27_South,
357
PCS_NAD27_Ohio_North, Proj_Ohio_CS27_North,
358
PCS_NAD27_Ohio_South, Proj_Ohio_CS27_South,
360
PCS_NAD27_Oklahoma_North, Proj_Oklahoma_CS27_North,
361
PCS_NAD27_Oklahoma_South, Proj_Oklahoma_CS27_South,
363
PCS_NAD27_Oregon_North, Proj_Oregon_CS27_North,
364
PCS_NAD27_Oregon_South, Proj_Oregon_CS27_South,
366
PCS_NAD27_Pennsylvania_N, Proj_Pennsylvania_CS27_North,
367
PCS_NAD27_Pennsylvania_S, Proj_Pennsylvania_CS27_South,
369
PCS_NAD27_Rhode_Island, Proj_Rhode_Island_CS27,
371
PCS_NAD27_South_Carolina_N, Proj_South_Carolina_CS27_North,
372
PCS_NAD27_South_Carolina_S, Proj_South_Carolina_CS27_South,
374
PCS_NAD27_South_Dakota_N, Proj_South_Dakota_CS27_North,
375
PCS_NAD27_South_Dakota_S, Proj_South_Dakota_CS27_South,
377
PCS_NAD27_Tennessee, Proj_Tennessee_CS27,
379
PCS_NAD27_Texas_North, Proj_Texas_CS27_North,
380
PCS_NAD27_Texas_North_Cen, Proj_Texas_CS27_North_Central,
381
PCS_NAD27_Texas_Central, Proj_Texas_CS27_Central,
382
PCS_NAD27_Texas_South_Cen, Proj_Texas_CS27_South_Central,
383
PCS_NAD27_Texas_South, Proj_Texas_CS27_South,
385
PCS_NAD27_Utah_North, Proj_Utah_CS27_North,
386
PCS_NAD27_Utah_Central, Proj_Utah_CS27_Central,
387
PCS_NAD27_Utah_South, Proj_Utah_CS27_South,
389
PCS_NAD27_Vermont, Proj_Vermont_CS27,
391
PCS_NAD27_Virginia_North, Proj_Virginia_CS27_North,
392
PCS_NAD27_Virginia_South, Proj_Virginia_CS27_South,
394
PCS_NAD27_Washington_North, Proj_Washington_CS27_North,
395
PCS_NAD27_Washington_South, Proj_Washington_CS27_South,
397
PCS_NAD27_West_Virginia_N, Proj_West_Virginia_CS27_North,
398
PCS_NAD27_West_Virginia_S, Proj_West_Virginia_CS27_South,
400
PCS_NAD27_Wisconsin_North, Proj_Wisconsin_CS27_North,
401
PCS_NAD27_Wisconsin_Cen, Proj_Wisconsin_CS27_Central,
402
PCS_NAD27_Wisconsin_South, Proj_Wisconsin_CS27_South,
404
PCS_NAD27_Wyoming_East, Proj_Wyoming_CS27_East,
405
PCS_NAD27_Wyoming_E_Cen, Proj_Wyoming_CS27_East_Central,
406
PCS_NAD27_Wyoming_W_Cen, Proj_Wyoming_CS27_West_Central,
407
PCS_NAD27_Wyoming_West, Proj_Wyoming_CS27_West,
409
PCS_NAD27_Puerto_Rico, Proj_Puerto_Rico_CS27,
414
/************************************************************************/
415
/* GTIFMapSysToPCS() */
417
/* Given a Datum, MapSys and zone value generate the best PCS */
419
/************************************************************************/
421
int GTIFMapSysToPCS( int MapSys, int Datum, int nZone )
424
int PCSCode = KvUserDefined;
426
if( MapSys == MapSys_UTM_North )
428
if( Datum == GCS_NAD27 )
429
PCSCode = PCS_NAD27_UTM_zone_3N + nZone - 3;
430
else if( Datum == GCS_NAD83 )
431
PCSCode = PCS_NAD83_UTM_zone_3N + nZone - 3;
432
else if( Datum == GCS_WGS_72 )
433
PCSCode = PCS_WGS72_UTM_zone_1N + nZone - 1;
434
else if( Datum == GCS_WGS_72BE )
435
PCSCode = PCS_WGS72BE_UTM_zone_1N + nZone - 1;
436
else if( Datum == GCS_WGS_84 )
437
PCSCode = PCS_WGS84_UTM_zone_1N + nZone - 1;
439
else if( MapSys == MapSys_UTM_South )
441
if( Datum == GCS_WGS_72 )
442
PCSCode = PCS_WGS72_UTM_zone_1S + nZone - 1;
443
else if( Datum == GCS_WGS_72BE )
444
PCSCode = PCS_WGS72BE_UTM_zone_1S + nZone - 1;
445
else if( Datum == GCS_WGS_84 )
446
PCSCode = PCS_WGS84_UTM_zone_1S + nZone - 1;
448
else if( MapSys == MapSys_State_Plane_27 )
452
PCSCode = 10000 + nZone;
453
for( i = 0; StatePlaneTable[i] != KvUserDefined; i += 2 )
455
if( StatePlaneTable[i+1] == PCSCode )
456
PCSCode = StatePlaneTable[i];
459
/* Old EPSG code was in error for Tennesse CS27, override */
463
else if( MapSys == MapSys_State_Plane_83 )
467
PCSCode = 10000 + nZone + 30;
469
for( i = 0; StatePlaneTable[i] != KvUserDefined; i += 2 )
471
if( StatePlaneTable[i+1] == PCSCode )
472
PCSCode = StatePlaneTable[i];
475
/* Old EPSG code was in error for Kentucky North CS83, override */
483
/************************************************************************/
484
/* GTIFMapSysToProj() */
486
/* Given a MapSys and zone value generate the best Proj_ */
488
/************************************************************************/
490
int GTIFMapSysToProj( int MapSys, int nZone )
493
int ProjCode = KvUserDefined;
495
if( MapSys == MapSys_UTM_North )
497
ProjCode = Proj_UTM_zone_1N + nZone - 1;
499
else if( MapSys == MapSys_UTM_South )
501
ProjCode = Proj_UTM_zone_1S + nZone - 1;
503
else if( MapSys == MapSys_State_Plane_27 )
505
ProjCode = 10000 + nZone;
507
/* Tennesse override */
511
else if( MapSys == MapSys_State_Plane_83 )
513
ProjCode = 10000 + nZone + 30;
515
/* Kentucky North override */
523
/************************************************************************/
524
/* GTIFPCSToMapSys() */
525
/************************************************************************/
528
* Translate a PCS_ code into a UTM or State Plane map system, a datum,
529
* and a zone if possible.
531
* @param PCSCode The projection code (PCS_*) as would be stored in the
532
* ProjectedCSTypeGeoKey of a GeoTIFF file.
534
* @param pDatum Pointer to an integer into which the datum code (GCS_*)
535
* is put if the function succeeds.
537
* @param pZone Pointer to an integer into which the zone will be placed
538
* if the function is successful.
540
* @return Returns either MapSys_UTM_North, MapSys_UTM_South,
541
* MapSys_State_Plane_83, MapSys_State_Plane_27 or KvUserDefined.
542
* KvUserDefined indicates that the
543
* function failed to recognise the projection as UTM or State Plane.
545
* The zone value is only set if the return code is other than KvUserDefined.
546
* For utm map system the returned zone will be between 1 and 60. For
547
* State Plane, the USGS state plane zone number is returned. For instance,
548
* Alabama East is zone 101.
550
* The datum (really this is the GCS) is set to a GCS_ value such as GCS_NAD27.
552
* This function is useful to recognise (most) UTM and State Plane coordinate
553
* systems, even if CSV files aren't available to translate them automatically.
554
* It is used as a fallback mechanism by GTIFGetDefn() for normalization when
555
* CSV files aren't found.
558
int GTIFPCSToMapSys( int PCSCode, int * pDatum, int * pZone )
561
int Datum = KvUserDefined, Proj = KvUserDefined;
562
int nZone = KvUserDefined, i;
564
/* -------------------------------------------------------------------- */
565
/* UTM with various datums. Note there are lots of PCS UTM */
566
/* codes not done yet which use strange datums. */
567
/* -------------------------------------------------------------------- */
568
if( PCSCode >= PCS_NAD27_UTM_zone_3N && PCSCode <= PCS_NAD27_UTM_zone_22N )
571
Proj = MapSys_UTM_North;
572
nZone = PCSCode - PCS_NAD27_UTM_zone_3N + 3;
574
else if( PCSCode >= PCS_NAD83_UTM_zone_3N
575
&& PCSCode <= PCS_NAD83_UTM_zone_23N )
578
Proj = MapSys_UTM_North;
579
nZone = PCSCode - PCS_NAD83_UTM_zone_3N + 3;
582
else if( PCSCode >= PCS_WGS72_UTM_zone_1N
583
&& PCSCode <= PCS_WGS72_UTM_zone_60N )
586
Proj = MapSys_UTM_North;
587
nZone = PCSCode - PCS_WGS72_UTM_zone_1N + 1;
589
else if( PCSCode >= PCS_WGS72_UTM_zone_1S
590
&& PCSCode <= PCS_WGS72_UTM_zone_60S )
593
Proj = MapSys_UTM_South;
594
nZone = PCSCode - PCS_WGS72_UTM_zone_1S + 1;
597
else if( PCSCode >= PCS_WGS72BE_UTM_zone_1N
598
&& PCSCode <= PCS_WGS72BE_UTM_zone_60N )
600
Datum = GCS_WGS_72BE;
601
Proj = MapSys_UTM_North;
602
nZone = PCSCode - PCS_WGS72BE_UTM_zone_1N + 1;
604
else if( PCSCode >= PCS_WGS72BE_UTM_zone_1S
605
&& PCSCode <= PCS_WGS72BE_UTM_zone_60S )
607
Datum = GCS_WGS_72BE;
608
Proj = MapSys_UTM_South;
609
nZone = PCSCode - PCS_WGS72BE_UTM_zone_1S + 1;
612
else if( PCSCode >= PCS_WGS84_UTM_zone_1N
613
&& PCSCode <= PCS_WGS84_UTM_zone_60N )
616
Proj = MapSys_UTM_North;
617
nZone = PCSCode - PCS_WGS84_UTM_zone_1N + 1;
619
else if( PCSCode >= PCS_WGS84_UTM_zone_1S
620
&& PCSCode <= PCS_WGS84_UTM_zone_60S )
623
Proj = MapSys_UTM_South;
624
nZone = PCSCode - PCS_WGS84_UTM_zone_1S + 1;
626
else if( PCSCode >= PCS_SAD69_UTM_zone_18N
627
&& PCSCode <= PCS_SAD69_UTM_zone_22N )
629
Datum = KvUserDefined;
630
Proj = MapSys_UTM_North;
631
nZone = PCSCode - PCS_SAD69_UTM_zone_18N + 18;
633
else if( PCSCode >= PCS_SAD69_UTM_zone_17S
634
&& PCSCode <= PCS_SAD69_UTM_zone_25S )
636
Datum = KvUserDefined;
637
Proj = MapSys_UTM_South;
638
nZone = PCSCode - PCS_SAD69_UTM_zone_17S + 17;
641
/* -------------------------------------------------------------------- */
642
/* State Plane zones, first we translate any PCS_ codes to */
643
/* a Proj_ code that we can get a handle on. */
644
/* -------------------------------------------------------------------- */
645
for( i = 0; StatePlaneTable[i] != KvUserDefined; i += 2 )
647
if( StatePlaneTable[i] == PCSCode )
648
PCSCode = StatePlaneTable[i+1];
651
if( PCSCode <= 15900 && PCSCode >= 10000 )
653
if( (PCSCode % 100) >= 30 )
655
Proj = MapSys_State_Plane_83;
660
Proj = MapSys_State_Plane_27;
664
nZone = PCSCode - 10000;
665
if( Datum == GCS_NAD83 )
678
/************************************************************************/
679
/* GTIFProjToMapSys() */
680
/************************************************************************/
683
* Translate a Proj_ code into a UTM or State Plane map system, and a zone
686
* @param ProjCode The projection code (Proj_*) as would be stored in the
687
* ProjectionGeoKey of a GeoTIFF file.
688
* @param pZone Pointer to an integer into which the zone will be placed
689
* if the function is successful.
691
* @return Returns either MapSys_UTM_North, MapSys_UTM_South,
692
* MapSys_State_Plane_27, MapSys_State_Plane_83 or KvUserDefined.
693
* KvUserDefined indicates that the
694
* function failed to recognise the projection as UTM or State Plane.
696
* The zone value is only set if the return code is other than KvUserDefined.
697
* For utm map system the returned zone will be between 1 and 60. For
698
* State Plane, the USGS state plane zone number is returned. For instance,
699
* Alabama East is zone 101.
701
* This function is useful to recognise UTM and State Plane coordinate
702
* systems, and to extract zone numbers so the projections can be
703
* represented as UTM rather than as the underlying projection method such
704
* Transverse Mercator for instance.
707
int GTIFProjToMapSys( int ProjCode, int * pZone )
710
int nZone = KvUserDefined;
711
int MapSys = KvUserDefined;
713
/* -------------------------------------------------------------------- */
715
/* -------------------------------------------------------------------- */
716
if( ProjCode >= Proj_UTM_zone_1N && ProjCode <= Proj_UTM_zone_60N )
718
MapSys = MapSys_UTM_North;
719
nZone = ProjCode - Proj_UTM_zone_1N + 1;
721
else if( ProjCode >= Proj_UTM_zone_1S && ProjCode <= Proj_UTM_zone_60S )
723
MapSys = MapSys_UTM_South;
724
nZone = ProjCode - Proj_UTM_zone_1S + 1;
727
/* -------------------------------------------------------------------- */
728
/* Handle State Plane. I think there are some anomolies in */
729
/* here, so this is a bit risky. */
730
/* -------------------------------------------------------------------- */
731
else if( ProjCode >= 10101 && ProjCode <= 15299 )
733
if( ProjCode % 100 >= 30 )
735
MapSys = MapSys_State_Plane_83;
736
nZone = ProjCode - 10000 - 30;
740
MapSys = MapSys_State_Plane_27;
741
nZone = ProjCode - 10000;