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