~ubuntu-branches/ubuntu/hardy/libterralib/hardy

« back to all changes in this revision

Viewing changes to src/tiff/geo_extra.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T Chen
  • Date: 2005-11-25 22:32:59 UTC
  • Revision ID: james.westby@ubuntu.com-20051125223259-3zubal8ux4ki4fjg
Tags: upstream-3.0.3b2
ImportĀ upstreamĀ versionĀ 3.0.3b2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************************************
 
2
 * $Id: geo_extra.c,v 1.2 2004/03/19 11:51:23 lubia Exp $
 
3
 *
 
4
 * Project:  libgeotiff
 
5
 * Purpose:  Code to normalize a few common PCS values without use of CSV
 
6
 *           files.
 
7
 * Author:   Frank Warmerdam, warmerda@home.com
 
8
 *
 
9
 ******************************************************************************
 
10
 * Copyright (c) 1999, Frank Warmerdam
 
11
 *
 
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:
 
18
 *
 
19
 * The above copyright notice and this permission notice shall be included
 
20
 * in all copies or substantial portions of the Software.
 
21
 *
 
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
 ******************************************************************************
 
30
 *
 
31
 * $Log: geo_extra.c,v $
 
32
 * Revision 1.2  2004/03/19 11:51:23  lubia
 
33
 * Atualizada as bibliotecas Tif e GeoTif
 
34
 *
 
35
 * Revision 1.4  2002/12/01 23:44:34  warmerda
 
36
 * Fixed typo in last fix.
 
37
 *
 
38
 * Revision 1.3  2002/12/01 23:42:06  warmerda
 
39
 * added overrides for two deprecated stateplane zones
 
40
 *
 
41
 * Revision 1.2  1999/05/04 03:09:33  warmerda
 
42
 * avoid warnings
 
43
 *
 
44
 * Revision 1.1  1999/04/28 20:01:29  warmerda
 
45
 * new
 
46
 *
 
47
 */
 
48
 
 
49
/*
 
50
#include "geotiff.h"
 
51
#include "geo_tiffp.h"
 
52
#include "geo_keyp.h"
 
53
*/
 
54
 
 
55
#include "geo_normalize.h"
 
56
#include "geovalues.h"
 
57
 
 
58
static int StatePlaneTable[] = 
 
59
{
 
60
    PCS_NAD83_Alabama_East,             Proj_Alabama_CS83_East,
 
61
    PCS_NAD83_Alabama_West,             Proj_Alabama_CS83_West,
 
62
 
 
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,
 
73
 
 
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,
 
80
 
 
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,
 
84
 
 
85
    PCS_NAD83_Arkansas_North,           Proj_Arkansas_CS83_North,
 
86
    PCS_NAD83_Arkansas_South,           Proj_Arkansas_CS83_South,
 
87
 
 
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,
 
91
 
 
92
    PCS_NAD83_Connecticut,              Proj_Connecticut_CS83,
 
93
 
 
94
    PCS_NAD83_Delaware,                 Proj_Delaware_CS83,
 
95
 
 
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,
 
99
 
 
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,
 
105
 
 
106
    PCS_NAD83_Georgia_East,             Proj_Georgia_CS83_East,
 
107
    PCS_NAD83_Georgia_West,             Proj_Georgia_CS83_West,
 
108
 
 
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,
 
112
 
 
113
    PCS_NAD83_Illinois_East,            Proj_Illinois_CS83_East,
 
114
    PCS_NAD83_Illinois_West,            Proj_Illinois_CS83_West,
 
115
 
 
116
    PCS_NAD83_Indiana_East,             Proj_Indiana_CS83_East,
 
117
    PCS_NAD83_Indiana_West,             Proj_Indiana_CS83_West,
 
118
 
 
119
    PCS_NAD83_Iowa_North,               Proj_Iowa_CS83_North,
 
120
    PCS_NAD83_Iowa_South,               Proj_Iowa_CS83_South,
 
121
 
 
122
    PCS_NAD83_Kansas_North,             Proj_Kansas_CS83_North,
 
123
    PCS_NAD83_Kansas_South,             Proj_Kansas_CS83_South,
 
124
 
 
125
    PCS_NAD83_Kentucky_North,           Proj_Kentucky_CS83_North,
 
126
    PCS_NAD83_Kentucky_South,           Proj_Kentucky_CS83_South,
 
127
 
 
128
    PCS_NAD83_Louisiana_North,          Proj_Louisiana_CS83_North,
 
129
    PCS_NAD83_Louisiana_South,          Proj_Louisiana_CS83_South,
 
130
 
 
131
    PCS_NAD83_Maine_East,               Proj_Maine_CS83_East,
 
132
    PCS_NAD83_Maine_West,               Proj_Maine_CS83_West,
 
133
 
 
134
    PCS_NAD83_Maryland,                 Proj_Maryland_CS83,
 
135
 
 
136
    PCS_NAD83_Massachusetts,            Proj_Massachusetts_CS83_Mainland,
 
137
    PCS_NAD83_Massachusetts_Is,         Proj_Massachusetts_CS83_Island,
 
138
 
 
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,
 
142
 
 
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,
 
146
 
 
147
    PCS_NAD83_Mississippi_East,         Proj_Mississippi_CS83_East,
 
148
    PCS_NAD83_Mississippi_West,         Proj_Mississippi_CS83_West,
 
149
 
 
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,
 
153
 
 
154
    PCS_NAD83_Montana,                  Proj_Montana_CS83,
 
155
 
 
156
    PCS_NAD83_Nebraska,                 Proj_Nebraska_CS83,
 
157
 
 
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,
 
161
 
 
162
    PCS_NAD83_New_Hampshire,            Proj_New_Hampshire_CS83,
 
163
 
 
164
    PCS_NAD83_New_Jersey,               Proj_New_Jersey_CS83,
 
165
 
 
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,
 
169
 
 
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,
 
174
 
 
175
    PCS_NAD83_North_Carolina,           Proj_North_Carolina_CS83,
 
176
 
 
177
    PCS_NAD83_North_Dakota_N,           Proj_North_Dakota_CS83_North,
 
178
    PCS_NAD83_North_Dakota_S,           Proj_North_Dakota_CS83_South,
 
179
 
 
180
    PCS_NAD83_Ohio_North,               Proj_Ohio_CS83_North,
 
181
    PCS_NAD83_Ohio_South,               Proj_Ohio_CS83_South,
 
182
 
 
183
    PCS_NAD83_Oklahoma_North,           Proj_Oklahoma_CS83_North,
 
184
    PCS_NAD83_Oklahoma_South,           Proj_Oklahoma_CS83_South,
 
185
 
 
186
    PCS_NAD83_Oregon_North,             Proj_Oregon_CS83_North,
 
187
    PCS_NAD83_Oregon_South,             Proj_Oregon_CS83_South,
 
188
 
 
189
    PCS_NAD83_Pennsylvania_N,           Proj_Pennsylvania_CS83_North,
 
190
    PCS_NAD83_Pennsylvania_S,           Proj_Pennsylvania_CS83_South,
 
191
 
 
192
    PCS_NAD83_Rhode_Island,             Proj_Rhode_Island_CS83,
 
193
 
 
194
    PCS_NAD83_South_Carolina,           Proj_South_Carolina_CS83,
 
195
 
 
196
    PCS_NAD83_South_Dakota_N,           Proj_South_Dakota_CS83_North,
 
197
    PCS_NAD83_South_Dakota_S,           Proj_South_Dakota_CS83_South,
 
198
 
 
199
    PCS_NAD83_Tennessee,                Proj_Tennessee_CS83,
 
200
 
 
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,
 
206
 
 
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,
 
210
 
 
211
    PCS_NAD83_Vermont,                  Proj_Vermont_CS83,
 
212
 
 
213
    PCS_NAD83_Virginia_North,           Proj_Virginia_CS83_North,
 
214
    PCS_NAD83_Virginia_South,           Proj_Virginia_CS83_South,
 
215
 
 
216
    PCS_NAD83_Washington_North,         Proj_Washington_CS83_North,
 
217
    PCS_NAD83_Washington_South,         Proj_Washington_CS83_South,
 
218
 
 
219
    PCS_NAD83_West_Virginia_N,          Proj_West_Virginia_CS83_North,
 
220
    PCS_NAD83_West_Virginia_S,          Proj_West_Virginia_CS83_South,
 
221
 
 
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,
 
225
 
 
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,
 
230
    
 
231
    PCS_NAD83_Puerto_Rico_Virgin_Is,    Proj_Puerto_Rico_Virgin_Is,
 
232
 
 
233
    PCS_NAD27_Alabama_East,             Proj_Alabama_CS27_East,
 
234
    PCS_NAD27_Alabama_West,             Proj_Alabama_CS27_West,
 
235
 
 
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,
 
246
 
 
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,
 
254
 
 
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,
 
258
 
 
259
    PCS_NAD27_Arkansas_North,           Proj_Arkansas_CS27_North,
 
260
    PCS_NAD27_Arkansas_South,           Proj_Arkansas_CS27_South,
 
261
 
 
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,
 
265
 
 
266
    PCS_NAD27_Connecticut,              Proj_Connecticut_CS27,
 
267
 
 
268
    PCS_NAD27_Delaware,                 Proj_Delaware_CS27,
 
269
 
 
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,
 
273
 
 
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,
 
279
 
 
280
    PCS_NAD27_Georgia_East,             Proj_Georgia_CS27_East,
 
281
    PCS_NAD27_Georgia_West,             Proj_Georgia_CS27_West,
 
282
 
 
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,
 
286
 
 
287
    PCS_NAD27_Illinois_East,            Proj_Illinois_CS27_East,
 
288
    PCS_NAD27_Illinois_West,            Proj_Illinois_CS27_West,
 
289
 
 
290
    PCS_NAD27_Indiana_East,             Proj_Indiana_CS27_East,
 
291
    PCS_NAD27_Indiana_West,             Proj_Indiana_CS27_West,
 
292
 
 
293
    PCS_NAD27_Iowa_North,               Proj_Iowa_CS27_North,
 
294
    PCS_NAD27_Iowa_South,               Proj_Iowa_CS27_South,
 
295
 
 
296
    PCS_NAD27_Kansas_North,             Proj_Kansas_CS27_North,
 
297
    PCS_NAD27_Kansas_South,             Proj_Kansas_CS27_South,
 
298
 
 
299
    PCS_NAD27_Kentucky_North,           Proj_Kentucky_CS27_North,
 
300
    PCS_NAD27_Kentucky_South,           Proj_Kentucky_CS27_South,
 
301
 
 
302
    PCS_NAD27_Louisiana_North,          Proj_Louisiana_CS27_North,
 
303
    PCS_NAD27_Louisiana_South,          Proj_Louisiana_CS27_South,
 
304
 
 
305
    PCS_NAD27_Maine_East,               Proj_Maine_CS27_East,
 
306
    PCS_NAD27_Maine_West,               Proj_Maine_CS27_West,
 
307
 
 
308
    PCS_NAD27_Maryland,                 Proj_Maryland_CS27,
 
309
 
 
310
    PCS_NAD27_Massachusetts,            Proj_Massachusetts_CS27_Mainland,
 
311
    PCS_NAD27_Massachusetts_Is,         Proj_Massachusetts_CS27_Island,
 
312
 
 
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,
 
316
 
 
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,
 
320
 
 
321
    PCS_NAD27_Mississippi_East,         Proj_Mississippi_CS27_East,
 
322
    PCS_NAD27_Mississippi_West,         Proj_Mississippi_CS27_West,
 
323
 
 
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,
 
327
 
 
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,
 
331
 
 
332
    PCS_NAD27_Nebraska_North,           Proj_Nebraska_CS27_North,
 
333
    PCS_NAD27_Nebraska_South,           Proj_Nebraska_CS27_South,
 
334
 
 
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,
 
338
 
 
339
    PCS_NAD27_New_Hampshire,            Proj_New_Hampshire_CS27,
 
340
 
 
341
    PCS_NAD27_New_Jersey,               Proj_New_Jersey_CS27,
 
342
 
 
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,
 
346
 
 
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,
 
351
 
 
352
    PCS_NAD27_North_Carolina,           Proj_North_Carolina_CS27,
 
353
 
 
354
    PCS_NAD27_North_Dakota_N,           Proj_North_Dakota_CS27_North,
 
355
    PCS_NAD27_North_Dakota_S,           Proj_North_Dakota_CS27_South,
 
356
 
 
357
    PCS_NAD27_Ohio_North,               Proj_Ohio_CS27_North,
 
358
    PCS_NAD27_Ohio_South,               Proj_Ohio_CS27_South,
 
359
 
 
360
    PCS_NAD27_Oklahoma_North,           Proj_Oklahoma_CS27_North,
 
361
    PCS_NAD27_Oklahoma_South,           Proj_Oklahoma_CS27_South,
 
362
 
 
363
    PCS_NAD27_Oregon_North,             Proj_Oregon_CS27_North,
 
364
    PCS_NAD27_Oregon_South,             Proj_Oregon_CS27_South,
 
365
 
 
366
    PCS_NAD27_Pennsylvania_N,           Proj_Pennsylvania_CS27_North,
 
367
    PCS_NAD27_Pennsylvania_S,           Proj_Pennsylvania_CS27_South,
 
368
 
 
369
    PCS_NAD27_Rhode_Island,             Proj_Rhode_Island_CS27,
 
370
 
 
371
    PCS_NAD27_South_Carolina_N,         Proj_South_Carolina_CS27_North,
 
372
    PCS_NAD27_South_Carolina_S,         Proj_South_Carolina_CS27_South,
 
373
 
 
374
    PCS_NAD27_South_Dakota_N,           Proj_South_Dakota_CS27_North,
 
375
    PCS_NAD27_South_Dakota_S,           Proj_South_Dakota_CS27_South,
 
376
 
 
377
    PCS_NAD27_Tennessee,                Proj_Tennessee_CS27,
 
378
 
 
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,
 
384
 
 
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,
 
388
 
 
389
    PCS_NAD27_Vermont,                  Proj_Vermont_CS27,
 
390
 
 
391
    PCS_NAD27_Virginia_North,           Proj_Virginia_CS27_North,
 
392
    PCS_NAD27_Virginia_South,           Proj_Virginia_CS27_South,
 
393
 
 
394
    PCS_NAD27_Washington_North,         Proj_Washington_CS27_North,
 
395
    PCS_NAD27_Washington_South,         Proj_Washington_CS27_South,
 
396
 
 
397
    PCS_NAD27_West_Virginia_N,          Proj_West_Virginia_CS27_North,
 
398
    PCS_NAD27_West_Virginia_S,          Proj_West_Virginia_CS27_South,
 
399
 
 
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,
 
403
 
 
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,
 
408
    
 
409
    PCS_NAD27_Puerto_Rico,              Proj_Puerto_Rico_CS27,
 
410
 
 
411
    KvUserDefined
 
412
};
 
413
 
 
414
/************************************************************************/
 
415
/*                          GTIFMapSysToPCS()                           */
 
416
/*                                                                      */
 
417
/*      Given a Datum, MapSys and zone value generate the best PCS      */
 
418
/*      code possible.                                                  */
 
419
/************************************************************************/
 
420
 
 
421
int     GTIFMapSysToPCS( int MapSys, int Datum, int nZone )
 
422
 
 
423
{
 
424
    int         PCSCode = KvUserDefined;
 
425
 
 
426
    if( MapSys == MapSys_UTM_North )
 
427
    {
 
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;
 
438
    }
 
439
    else if( MapSys == MapSys_UTM_South )
 
440
    {
 
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;
 
447
    }
 
448
    else if( MapSys == MapSys_State_Plane_27 )
 
449
    {
 
450
        int             i;
 
451
 
 
452
        PCSCode = 10000 + nZone;
 
453
        for( i = 0; StatePlaneTable[i] != KvUserDefined; i += 2 )
 
454
        {
 
455
            if( StatePlaneTable[i+1] == PCSCode )
 
456
                PCSCode = StatePlaneTable[i];
 
457
        }
 
458
 
 
459
        /* Old EPSG code was in error for Tennesse CS27, override */
 
460
        if( nZone == 4100 )
 
461
            PCSCode = 2204;
 
462
    }
 
463
    else if( MapSys == MapSys_State_Plane_83 )
 
464
    {
 
465
        int             i;
 
466
 
 
467
        PCSCode = 10000 + nZone + 30;
 
468
 
 
469
        for( i = 0; StatePlaneTable[i] != KvUserDefined; i += 2 )
 
470
        {
 
471
            if( StatePlaneTable[i+1] == PCSCode )
 
472
                PCSCode = StatePlaneTable[i];
 
473
        }
 
474
 
 
475
        /* Old EPSG code was in error for Kentucky North CS83, override */
 
476
        if( nZone == 1601 )
 
477
            PCSCode = 2205;
 
478
    }
 
479
 
 
480
    return( PCSCode );
 
481
}
 
482
 
 
483
/************************************************************************/
 
484
/*                          GTIFMapSysToProj()                          */
 
485
/*                                                                      */
 
486
/*      Given a MapSys and zone value generate the best Proj_           */
 
487
/*      code possible.                                                  */
 
488
/************************************************************************/
 
489
 
 
490
int     GTIFMapSysToProj( int MapSys, int nZone )
 
491
 
 
492
{
 
493
    int         ProjCode = KvUserDefined;
 
494
 
 
495
    if( MapSys == MapSys_UTM_North )
 
496
    {
 
497
        ProjCode = Proj_UTM_zone_1N + nZone - 1;
 
498
    }
 
499
    else if( MapSys == MapSys_UTM_South )
 
500
    {
 
501
        ProjCode = Proj_UTM_zone_1S + nZone - 1;
 
502
    }
 
503
    else if( MapSys == MapSys_State_Plane_27 )
 
504
    {
 
505
        ProjCode = 10000 + nZone;
 
506
 
 
507
        /* Tennesse override */
 
508
        if( nZone == 4100 )
 
509
            ProjCode = 15302;
 
510
    }
 
511
    else if( MapSys == MapSys_State_Plane_83 )
 
512
    {
 
513
        ProjCode = 10000 + nZone + 30;
 
514
 
 
515
        /* Kentucky North override */
 
516
        if( nZone == 1601 )
 
517
            ProjCode = 15303;
 
518
    }
 
519
 
 
520
    return( ProjCode );
 
521
}
 
522
 
 
523
/************************************************************************/
 
524
/*                          GTIFPCSToMapSys()                           */
 
525
/************************************************************************/
 
526
 
 
527
/**
 
528
 * Translate a PCS_ code into a UTM or State Plane map system, a datum,
 
529
 * and a zone if possible.
 
530
 *
 
531
 * @param PCSCode The projection code (PCS_*) as would be stored in the
 
532
 * ProjectedCSTypeGeoKey of a GeoTIFF file.
 
533
 *
 
534
 * @param pDatum Pointer to an integer into which the datum code (GCS_*)
 
535
 * is put if the function succeeds.
 
536
 *
 
537
 * @param pZone Pointer to an integer into which the zone will be placed
 
538
 * if the function is successful.
 
539
 *
 
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.
 
544
 *
 
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.
 
549
 *
 
550
 * The datum (really this is the GCS) is set to a GCS_ value such as GCS_NAD27.
 
551
 *
 
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. 
 
556
 */
 
557
 
 
558
int GTIFPCSToMapSys( int PCSCode, int * pDatum, int * pZone )
 
559
 
 
560
{
 
561
    int         Datum = KvUserDefined, Proj = KvUserDefined;
 
562
    int         nZone = KvUserDefined, i;
 
563
 
 
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 )
 
569
    {
 
570
        Datum = GCS_NAD27;
 
571
        Proj = MapSys_UTM_North;
 
572
        nZone = PCSCode - PCS_NAD27_UTM_zone_3N + 3;
 
573
    }
 
574
    else if( PCSCode >= PCS_NAD83_UTM_zone_3N 
 
575
             && PCSCode <= PCS_NAD83_UTM_zone_23N )
 
576
    {
 
577
        Datum = GCS_NAD83;
 
578
        Proj = MapSys_UTM_North;
 
579
        nZone = PCSCode - PCS_NAD83_UTM_zone_3N + 3;
 
580
    }
 
581
 
 
582
    else if( PCSCode >= PCS_WGS72_UTM_zone_1N
 
583
             && PCSCode <= PCS_WGS72_UTM_zone_60N )
 
584
    {
 
585
        Datum = GCS_WGS_72;
 
586
        Proj = MapSys_UTM_North;
 
587
        nZone = PCSCode - PCS_WGS72_UTM_zone_1N + 1;
 
588
    }
 
589
    else if( PCSCode >= PCS_WGS72_UTM_zone_1S
 
590
             && PCSCode <= PCS_WGS72_UTM_zone_60S )
 
591
    {
 
592
        Datum = GCS_WGS_72;
 
593
        Proj = MapSys_UTM_South;
 
594
        nZone = PCSCode - PCS_WGS72_UTM_zone_1S + 1;
 
595
    }
 
596
 
 
597
    else if( PCSCode >= PCS_WGS72BE_UTM_zone_1N
 
598
             && PCSCode <= PCS_WGS72BE_UTM_zone_60N )
 
599
    {
 
600
        Datum = GCS_WGS_72BE;
 
601
        Proj = MapSys_UTM_North;
 
602
        nZone = PCSCode - PCS_WGS72BE_UTM_zone_1N + 1;
 
603
    }
 
604
    else if( PCSCode >= PCS_WGS72BE_UTM_zone_1S
 
605
             && PCSCode <= PCS_WGS72BE_UTM_zone_60S )
 
606
    {
 
607
        Datum = GCS_WGS_72BE;
 
608
        Proj = MapSys_UTM_South;
 
609
        nZone = PCSCode - PCS_WGS72BE_UTM_zone_1S + 1;
 
610
    }
 
611
 
 
612
    else if( PCSCode >= PCS_WGS84_UTM_zone_1N
 
613
             && PCSCode <= PCS_WGS84_UTM_zone_60N )
 
614
    {
 
615
        Datum = GCS_WGS_84;
 
616
        Proj = MapSys_UTM_North;
 
617
        nZone = PCSCode - PCS_WGS84_UTM_zone_1N + 1;
 
618
    }
 
619
    else if( PCSCode >= PCS_WGS84_UTM_zone_1S
 
620
             && PCSCode <= PCS_WGS84_UTM_zone_60S )
 
621
    {
 
622
        Datum = GCS_WGS_84;
 
623
        Proj = MapSys_UTM_South;
 
624
        nZone = PCSCode - PCS_WGS84_UTM_zone_1S + 1;
 
625
    }
 
626
    else if( PCSCode >= PCS_SAD69_UTM_zone_18N 
 
627
             && PCSCode <= PCS_SAD69_UTM_zone_22N )
 
628
    {
 
629
        Datum = KvUserDefined;
 
630
        Proj = MapSys_UTM_North;
 
631
        nZone = PCSCode - PCS_SAD69_UTM_zone_18N + 18;
 
632
    }
 
633
    else if( PCSCode >= PCS_SAD69_UTM_zone_17S
 
634
             && PCSCode <= PCS_SAD69_UTM_zone_25S )
 
635
    {
 
636
        Datum = KvUserDefined;
 
637
        Proj = MapSys_UTM_South;
 
638
        nZone = PCSCode - PCS_SAD69_UTM_zone_17S + 17;
 
639
    }
 
640
 
 
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 )
 
646
    {
 
647
        if( StatePlaneTable[i] == PCSCode )
 
648
            PCSCode = StatePlaneTable[i+1];
 
649
    }
 
650
 
 
651
    if( PCSCode <= 15900 && PCSCode >= 10000 )
 
652
    {
 
653
        if( (PCSCode % 100) >= 30 )
 
654
        {
 
655
            Proj = MapSys_State_Plane_83;
 
656
            Datum = GCS_NAD83;
 
657
        }
 
658
        else
 
659
        {
 
660
            Proj = MapSys_State_Plane_27;
 
661
            Datum = GCS_NAD27;
 
662
        }
 
663
        
 
664
        nZone = PCSCode - 10000;
 
665
        if( Datum == GCS_NAD83 )
 
666
            nZone -= 30;
 
667
    }
 
668
 
 
669
    if( pDatum != NULL )
 
670
        *pDatum = Datum;
 
671
 
 
672
    if( pZone != NULL )
 
673
        *pZone = nZone;
 
674
 
 
675
    return( Proj );
 
676
}
 
677
 
 
678
/************************************************************************/
 
679
/*                          GTIFProjToMapSys()                          */
 
680
/************************************************************************/
 
681
 
 
682
/**
 
683
 * Translate a Proj_ code into a UTM or State Plane map system, and a zone
 
684
 * if possible.
 
685
 *
 
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.
 
690
 *
 
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.
 
695
 *
 
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.
 
700
 *
 
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.
 
705
 */
 
706
 
 
707
int GTIFProjToMapSys( int ProjCode, int * pZone )
 
708
 
 
709
{
 
710
    int         nZone = KvUserDefined;
 
711
    int         MapSys = KvUserDefined;
 
712
 
 
713
/* -------------------------------------------------------------------- */
 
714
/*      Handle UTM.                                                     */
 
715
/* -------------------------------------------------------------------- */
 
716
    if( ProjCode >= Proj_UTM_zone_1N && ProjCode <= Proj_UTM_zone_60N )
 
717
    {
 
718
        MapSys = MapSys_UTM_North;
 
719
        nZone = ProjCode - Proj_UTM_zone_1N + 1;
 
720
    }
 
721
    else if( ProjCode >= Proj_UTM_zone_1S && ProjCode <= Proj_UTM_zone_60S )
 
722
    {
 
723
        MapSys = MapSys_UTM_South;
 
724
        nZone = ProjCode - Proj_UTM_zone_1S + 1;
 
725
    }
 
726
 
 
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 )
 
732
    {
 
733
        if( ProjCode % 100 >= 30 )
 
734
        {
 
735
            MapSys = MapSys_State_Plane_83;
 
736
            nZone = ProjCode - 10000 - 30;
 
737
        }
 
738
        else
 
739
        {
 
740
            MapSys = MapSys_State_Plane_27;
 
741
            nZone = ProjCode - 10000;
 
742
        }
 
743
    }
 
744
    
 
745
    if( pZone != NULL )
 
746
        *pZone = nZone;
 
747
 
 
748
    return( MapSys );
 
749
}
 
750