/src/gdal/frmts/grib/degrib/g2clib/pdstemplates.c
Line | Count | Source (jump to first uncovered line) |
1 | | #include <stdlib.h> |
2 | | #include "grib2.h" |
3 | | #include "pdstemplates.h" |
4 | | |
5 | | /* GDAL: in original g2clib, this is in pdstemplates.h */ |
6 | | static const struct pdstemplate templatespds[MAXPDSTEMP] = { |
7 | | // 4.0: Analysis or Forecast at Horizontal Level/Layer |
8 | | // at a point in time |
9 | | {0,15,0, {1,1,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4} }, |
10 | | // 4.1: Individual Ensemble Forecast at Horizontal Level/Layer |
11 | | // at a point in time |
12 | | {1,18,0, {1,1,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4,1,1,1} }, |
13 | | // 4.2: Derived Fcst based on whole Ensemble at Horiz Level/Layer |
14 | | // at a point in time |
15 | | {2,17,0, {1,1,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4,1,1} }, |
16 | | // 4.3: Derived Fcst based on Ensemble cluster over rectangular |
17 | | // area at Horiz Level/Layer at a point in time |
18 | | {3,31,1, {1,1,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4,1,1,1,1,1,1,1,-4,-4,4,4,1,-1,4,-1,4} }, |
19 | | // 4.4: Derived Fcst based on Ensemble cluster over circular |
20 | | // area at Horiz Level/Layer at a point in time |
21 | | {4,30,1, {1,1,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4,1,1,1,1,1,1,1,-4,4,4,1,-1,4,-1,4} }, |
22 | | // 4.5: Probablility Forecast at Horiz Level/Layer |
23 | | // at a point in time |
24 | | {5,22,0, {1,1,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4,1,1,1,-1,-4,-1,-4} }, |
25 | | // 4.6: Percentile Forecast at Horiz Level/Layer |
26 | | // at a point in time |
27 | | {6,16,0, {1,1,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4,1} }, |
28 | | // 4.7: Analysis or Forecast Error at Horizontal Level/Layer |
29 | | // at a point in time |
30 | | {7,15,0, {1,1,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4} }, |
31 | | // 4.8: Ave/Accum/etc... at Horiz Level/Layer |
32 | | // in a time interval |
33 | | {8,29,1, {1,1,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4,2,1,1,1,1,1,1,4,1,1,1,4,1,4} }, |
34 | | // 4.9: Probablility Forecast at Horiz Level/Layer |
35 | | // in a time interval |
36 | | {9,36,1, {1,1,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4,1,1,1,-1,-4,-1,-4,2,1,1,1,1,1,1,4,1,1,1,4,1,4} }, |
37 | | // 4.10: Percentile Forecast at Horiz Level/Layer |
38 | | // in a time interval |
39 | | {10,30,1, {1,1,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4,1,2,1,1,1,1,1,1,4,1,1,1,4,1,4} }, |
40 | | // 4.11: Individual Ensemble Forecast at Horizontal Level/Layer |
41 | | // in a time interval |
42 | | {11,32,1, {1,1,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4,1,1,1,2,1,1,1,1,1,1,4,1,1,1,4,1,4} }, |
43 | | // 4.12: Derived Fcst based on whole Ensemble at Horiz Level/Layer |
44 | | // in a time interval |
45 | | {12,31,1, {1,1,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4,1,1,2,1,1,1,1,1,1,4,1,1,1,4,1,4} }, |
46 | | // 4.13: Derived Fcst based on Ensemble cluster over rectangular |
47 | | // area at Horiz Level/Layer in a time interval |
48 | | {13,45,1, {1,1,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4,1,1,1,1,1,1,1,-4,-4,4,4,1,-1,4,-1,4,2,1,1,1,1,1,1,4,1,1,1,4,1,4} }, |
49 | | // 4.14: Derived Fcst based on Ensemble cluster over circular |
50 | | // area at Horiz Level/Layer in a time interval |
51 | | {14,44,1, {1,1,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4,1,1,1,1,1,1,1,-4,4,4,1,-1,4,-1,4,2,1,1,1,1,1,1,4,1,1,1,4,1,4} }, |
52 | | // 4.15: Average, accumulation, extreme values or other statistically-processed values over a |
53 | | // spatial area at a horizontal level or in a horizontal layer at a point in time |
54 | | {15,18,0, {1,1,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4,1,1,1} }, |
55 | | // 4.20: Radar Product |
56 | | {20,19,0, {1,1,1,1,1,-4,4,2,4,2,1,1,1,1,1,2,1,3,2} }, |
57 | | // 4.30: Satellite Product |
58 | | {30,5,1, {1,1,1,1,1} }, |
59 | | // 4.31: Satellite Product |
60 | | {31,5,1, {1,1,1,1,1} }, |
61 | | // 4.40: Analysis or forecast at a horizontal level or in a horizontal layer |
62 | | // at a point in time for atmospheric chemical constituents |
63 | | {40,16,0, {1,1,2,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4} }, |
64 | | // 4.41: Individual ensemble forecast, control and perturbed, at a horizontal level or |
65 | | // in a horizontal layer at a point in time for atmospheric chemical constituents |
66 | | {41,19,0, {1,1,2,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4,1,1,1} }, |
67 | | // 4.42: Average, accumulation, and/or extreme values or other statistically-processed values |
68 | | // at a horizontal level or in a horizontal layer in a continuous or non-continuous |
69 | | // time interval for atmospheric chemical constituents |
70 | | {42,30,1, {1,1,2,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4,2,1,1,1,1,1,1,4,1,1,1,4,1,4} }, |
71 | | // 4.43: Individual ensemble forecast, control and perturbed, at a horizontal level |
72 | | // or in a horizontal layer in a continuous or non-continuous |
73 | | // time interval for atmospheric chemical constituents |
74 | | {43,33,1, {1,1,2,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4,1,1,1,2,1,1,1,1,1,1,4,1,1,1,4,1,4} }, |
75 | | // 4.254: CCITT IA5 Character String |
76 | | {254,3,0, {1,1,4} }, |
77 | | // 4.1000: Cross section of analysis or forecast |
78 | | // at a point in time |
79 | | {1000,9,0, {1,1,1,1,1,2,1,1,-4} }, |
80 | | // 4.1001: Cross section of Ave/Accum/etc... analysis or forecast |
81 | | // in a time interval |
82 | | {1001,16,0, {1,1,1,1,1,2,1,1,4,4,1,1,1,4,1,4} }, |
83 | | // 4.1001: Cross section of Ave/Accum/etc... analysis or forecast |
84 | | // over latitude or longitude |
85 | | {1002,15,0, {1,1,1,1,1,2,1,1,-4,1,1,1,4,4,2} }, |
86 | | // 4.1100: Hovmoller-type grid w/ no averaging or other |
87 | | // statistical processing |
88 | | {1100,15,0, {1,1,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4} }, |
89 | | // 4.1100: Hovmoller-type grid with averaging or other |
90 | | // statistical processing |
91 | | {1101,22,0, {1,1,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4,4,1,1,1,4,1,4} }, |
92 | | // 4.32:Simulate (synthetic) Satellite Product |
93 | | {32,10,1, {1,1,1,1,1,2,1,1,-4,1} }, // (last-1)th coefficient corrected from - 2 to -4 by ERO |
94 | | // 4.44: Analysis or forecast at a horizontal level or in a horizontal layer |
95 | | // at a point in time for Aerosol |
96 | | {44,21,0, {1,1,2,1,-1,-4,-1,-4,1,1,1,2,1,1,-2,1,-1,-4,1,-1,-4} }, |
97 | | // 4.45: Individual ensemble forecast, control and |
98 | | // perturbed, at a horizontal level or in a horizontal layer |
99 | | // at a point in time for Aerosol |
100 | | {45,24,0, {1,1,2,1,-1,-4,-1,-4,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4,1,1,1} }, |
101 | | // 4.46: Ave or Accum or Extreme value at level/layer |
102 | | // at horizontal level or in a horizontal in a continuous or |
103 | | // non-continuous time interval for Aerosol |
104 | | {46,35,1, {1,1,2,1,-1,-4,-1,-4,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4,2,1,1,1,1,1,1,4,1,1,1,4,1,4} }, |
105 | | // 4.47: Individual ensemble forecast, control and |
106 | | // perturbed, at horizontal level or in a horizontal |
107 | | // in a continuous or non-continuous time interval for Aerosol |
108 | | {47,38,1, {1,1,1,2,1,-1,-4,-1,-4,1,1,2,1,1,-4,1,-1,-4,1,-1,-4,1,1,1,2,1,1,1,1,1,1,4,1,1,1,4,1,4} }, |
109 | | |
110 | | // PDT 4.48 |
111 | | // 4.48: Analysis or forecast at a horizontal level or in a horizontal layer |
112 | | // at a point in time for Optical Properties of Aerosol |
113 | | {48,26,0, {1,1,2,1,-1,-4,-1,-4,1,-1,-4,-1,-4,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4} }, |
114 | | |
115 | | // VALIDATION --- PDT 4.50 |
116 | | // 4.50: Analysis or forecast of multi component parameter or |
117 | | // matrix element at a point in time |
118 | | {50,21,0, {1,1,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4,1,1,4,4,4,4} }, |
119 | | |
120 | | // VALIDATION --- PDT 4.52 |
121 | | // 4.52: Analysis or forecast of Wave parameters |
122 | | // at the Sea surface at a point in time |
123 | | {52,15,0, {1,1,1,1,1,1,1,1,2,1,1,-4,1,-1,-4} }, |
124 | | |
125 | | // 4.51: Categorical forecasts at a horizontal level or |
126 | | // in a horizontal layer at a point in time |
127 | | {51,16,1, {1,1,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4,1} }, |
128 | | |
129 | | // 4.91: Categorical forecasts at a horizontal level or |
130 | | // in a horizontal layer at a point in time |
131 | | // in a continuous or non-continuous time interval |
132 | | {91,36,1, {1,1,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4,1,1,1,-1,-4,-1,-4,2,1,1,1,1,1,1,4,1,1,1,4,1,4} }, |
133 | | // PDT 4.33 (07/29/2013) |
134 | | // 4.33: Individual ensemble forecast, control, perturbed, |
135 | | // at a horizontal level or in a horizontal layer |
136 | | // at a point in time for simulated (synthetic) Satellite data |
137 | | {33,18,1, {1,1,1,1,1,2,1,1,-4,1,2,2,2,-1,-4,1,1,1} }, |
138 | | // PDT 4.34 (07/29/2013) |
139 | | // 4.34: Individual ensemble forecast, control, perturbed, |
140 | | // at a horizontal level or in a horizontal layer,in a continuous or |
141 | | // non-continuous interval for simulated (synthetic) Satellite data |
142 | | {34,32,1, {1,1,1,1,1,2,1,1,-4,1,2,2,2,-1,-4,1,1,1,2,1,1,1,1,1,1,4,1,1,1,4,1,4} }, |
143 | | // PDT 4.53 (07/29/2013) |
144 | | // 4.53: Partitioned parameters at |
145 | | // horizontal level or horizontal layer |
146 | | // at a point in time |
147 | | {53,19,1, {1,1,1,1,4,2,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4} }, |
148 | | // PDT 4.54 (07/29/2013) |
149 | | // 4.54: Individual ensemble forecast, control, perturbed, |
150 | | // at a horizontal level or in a horizontal layer |
151 | | // at a point in time for partitioned parameters |
152 | | {54,22,1, {1,1,1,1,4,2,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4,1,1,1} }, |
153 | | // PDT 4.57 (10/07/2015) |
154 | | // 4.57: Analysis or Forecast at a horizontal or in a |
155 | | // horizontal layer at a point in time for |
156 | | // atmospheric chemical constituents based on |
157 | | // a distribution function |
158 | | {57,7,1, {1,1,2,2,2,2,1} }, |
159 | | // PDT 4.60 (10/07/2015) |
160 | | // 4.60: Individual ensemble reforecast, control and perturbed, |
161 | | // at a horizontal level or in a horizontal layer |
162 | | // at a point in time |
163 | | {60,24,0, {1,1,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4,1,1,1,2,1,1,1,1,1} }, |
164 | | // PDT 4.61 (10/07/2015) |
165 | | // 4.61: Individual ensemble reforecast, control and perturbed, |
166 | | // at a horizontal level or in a horizontal layer |
167 | | // in a continuous or non-continuous time interval |
168 | | {61,38,1, {1,1,1,1,1,2,1,1,-4,1,-1,-4,1,-1,-4,1,1,1,2,1,1,1,1,1,2,1,1,1,1,1,1,4,1,1,1,4,1,4} }, |
169 | | // VALIDATION --- PDT 4.35 |
170 | | // PDT 4.35 (10/07/2015) |
171 | | // 4.35: Individual ensemble reforecast, control and perturbed, |
172 | | // at a horizontal level or in a horizontal layer |
173 | | // in a continuous or non-continuous time interval |
174 | | {35,6,1, {1,1,1,1,1,1} } |
175 | | |
176 | | } ; |
177 | | |
178 | | const struct pdstemplate *get_templatespds() |
179 | 436k | { |
180 | 436k | return templatespds; |
181 | 436k | } |
182 | | |
183 | | g2int getpdsindex(g2int number) |
184 | | ///$$$ SUBPROGRAM DOCUMENTATION BLOCK |
185 | | // . . . . |
186 | | // SUBPROGRAM: getpdsindex |
187 | | // PRGMMR: Gilbert ORG: W/NP11 DATE: 2001-06-28 |
188 | | // |
189 | | // ABSTRACT: This function returns the index of specified Product |
190 | | // Definition Template 4.NN (NN=number) in array templates. |
191 | | // |
192 | | // PROGRAM HISTORY LOG: |
193 | | // 2001-06-28 Gilbert |
194 | | // 2009-01-14 Vuong Changed structure name template to gtemplate |
195 | | // 2009-12-15 Vuong Added Product Definition Template 4.31 |
196 | | // Added Product Definition Template 4.15 |
197 | | // 2010-08-03 Vuong Added Product Definition Template 4.42 and 4.43 |
198 | | // 2010-12-08 Vuong Corrected Product Definition Template 4.42 and 4.43 |
199 | | // 2012-03-29 Vuong Added Templates 4.44,4.45,4.46,4.47,4.48,4.50, |
200 | | // 4.51,4.91,4.32 and 4.52 |
201 | | // 2013-08-05 Vuong Corrected 4.91 and added Templates 4.33,4.34,4.53,4.54 |
202 | | // 2015-10-07 Vuong Added Templates 4.57, 4.60, 4.61 and |
203 | | // allow a forecast time to be negative |
204 | | // USAGE: index=getpdsindex(number) |
205 | | // INPUT ARGUMENT LIST: |
206 | | // number - NN, indicating the number of the Product Definition |
207 | | // Template 4.NN that is being requested. |
208 | | // |
209 | | // RETURNS: Index of PDT 4.NN in array templates, if template exists. |
210 | | // = -1, otherwise. |
211 | | // |
212 | | // REMARKS: None |
213 | | // |
214 | | // ATTRIBUTES: |
215 | | // LANGUAGE: C |
216 | | // MACHINE: IBM SP |
217 | | // |
218 | | //$$$/ |
219 | 57.3k | { |
220 | 57.3k | g2int j,l_getpdsindex=-1; |
221 | | |
222 | 569k | for (j=0;j<MAXPDSTEMP;j++) { |
223 | 566k | if (number == templatespds[j].template_num) { |
224 | 54.3k | l_getpdsindex=j; |
225 | 54.3k | return(l_getpdsindex); |
226 | 54.3k | } |
227 | 566k | } |
228 | | |
229 | 2.96k | return(l_getpdsindex); |
230 | 57.3k | } |
231 | | |
232 | | |
233 | | gtemplate *getpdstemplate(g2int number) |
234 | | ///$$$ SUBPROGRAM DOCUMENTATION BLOCK |
235 | | // . . . . |
236 | | // SUBPROGRAM: getpdstemplate |
237 | | // PRGMMR: Gilbert ORG: W/NP11 DATE: 2000-05-11 |
238 | | // |
239 | | // ABSTRACT: This subroutine returns PDS template information for a |
240 | | // specified Product Definition Template 4.NN. |
241 | | // The number of entries in the template is returned along with a map |
242 | | // of the number of octets occupied by each entry. Also, a flag is |
243 | | // returned to indicate whether the template would need to be extended. |
244 | | // |
245 | | // PROGRAM HISTORY LOG: |
246 | | // 2000-05-11 Gilbert |
247 | | // 2009-01-14 Vuong Changed structure name template to gtemplate |
248 | | // 2009-08-05 Vuong Added Product Definition Template 4.31 |
249 | | // 2010-08-03 Vuong Added Product Definition Template 4.42 and 4.43 |
250 | | // 2010-12-08 Vuong Corrected Product Definition Template 4.42 and 4.43 |
251 | | // 2012-02-15 Vuong Added Templates 4.44,4.45,4.46,4.47,4.48,4.50, |
252 | | // 4.51,4.91,4.32 and 4.52 |
253 | | // 2013-08-05 Vuong Corrected 4.91 and added Templates 4.33,4.34,4.53,4.54 |
254 | | // 2015-10-07 Vuong Added Templates 4.57, 4.60, 4.61 and |
255 | | // allow a forecast time to be negative |
256 | | // |
257 | | // USAGE: CALL getpdstemplate(number) |
258 | | // INPUT ARGUMENT LIST: |
259 | | // number - NN, indicating the number of the Product Definition |
260 | | // Template 4.NN that is being requested. |
261 | | // |
262 | | // RETURN VALUE: |
263 | | // - Pointer to the returned template struct. |
264 | | // Returns NULL pointer, if template not found. |
265 | | // |
266 | | // REMARKS: None |
267 | | // |
268 | | // ATTRIBUTES: |
269 | | // LANGUAGE: C |
270 | | // MACHINE: IBM SP |
271 | | // |
272 | | //$$$/ |
273 | 28.9k | { |
274 | 28.9k | g2int l_index; |
275 | 28.9k | gtemplate *new; |
276 | | |
277 | 28.9k | l_index=getpdsindex(number); |
278 | | |
279 | 28.9k | if (l_index != -1) { |
280 | 27.5k | new=(gtemplate *)malloc(sizeof(gtemplate)); |
281 | 27.5k | new->type=4; |
282 | 27.5k | new->num=templatespds[l_index].template_num; |
283 | 27.5k | new->maplen=templatespds[l_index].mappdslen; |
284 | 27.5k | new->needext=templatespds[l_index].needext; |
285 | 27.5k | new->map=(g2int *)templatespds[l_index].mappds; |
286 | 27.5k | new->extlen=0; |
287 | 27.5k | new->ext=0; //NULL |
288 | 27.5k | return(new); |
289 | 27.5k | } |
290 | 1.39k | else { |
291 | | //printf("getpdstemplate: PDS Template 4.%d not defined.\n",(int)number); |
292 | 1.39k | return(0); //NULL |
293 | 1.39k | } |
294 | | |
295 | 0 | return(0); //NULL |
296 | 28.9k | } |
297 | | |
298 | | |
299 | | gtemplate *extpdstemplate(g2int number,g2int *list) |
300 | | ///$$$ SUBPROGRAM DOCUMENTATION BLOCK |
301 | | // . . . . |
302 | | // SUBPROGRAM: extpdstemplate |
303 | | // PRGMMR: Gilbert ORG: W/NP11 DATE: 2000-05-11 |
304 | | // |
305 | | // ABSTRACT: This subroutine generates the remaining octet map for a |
306 | | // given Product Definition Template, if required. Some Templates can |
307 | | // vary depending on data values given in an earlier part of the |
308 | | // Template, and it is necessary to know some of the earlier entry |
309 | | // values to generate the full octet map of the Template. |
310 | | // |
311 | | // PROGRAM HISTORY LOG: |
312 | | // 2000-05-11 Gilbert |
313 | | // 2009-01-14 Vuong Changed structure name template to gtemplate |
314 | | // 2009-08-05 Vuong Added Product Definition Template 4.31 |
315 | | // 2010-08-03 Vuong Added Product Definition Template 4.42 and 4.43 |
316 | | // 2010-12-08 Vuong Corrected Product Definition Template 4.42 and 4.43 |
317 | | // 2012-02-15 Vuong Added Templates 4.44,4.45,4.46,4.47,4.48,4.50, |
318 | | // 4.51,4.91,4.32 and 4.52 |
319 | | // 2013-08-05 Vuong Corrected 4.91 and added Templates 4.33,4.34,4.53,4.54 |
320 | | // 2015-10-07 Vuong Added Templates 4.57, 4.60, 4.61 and |
321 | | // allow a forecast time to be negative |
322 | | // |
323 | | // USAGE: CALL extpdstemplate(number,list) |
324 | | // INPUT ARGUMENT LIST: |
325 | | // number - NN, indicating the number of the Product Definition |
326 | | // Template 4.NN that is being requested. |
327 | | // list() - The list of values for each entry in the |
328 | | // the Product Definition Template 4.NN. |
329 | | // |
330 | | // RETURN VALUE: |
331 | | // - Pointer to the returned template struct. |
332 | | // Returns NULL pointer, if template not found. |
333 | | // |
334 | | // ATTRIBUTES: |
335 | | // LANGUAGE: C |
336 | | // MACHINE: IBM SP |
337 | | // |
338 | | //$$$ |
339 | 8.01k | { |
340 | 8.01k | gtemplate *new; |
341 | 8.01k | g2int l_index,i,j,k,l; |
342 | | |
343 | 8.01k | l_index=getpdsindex(number); |
344 | 8.01k | if (l_index == -1) return(0); |
345 | | |
346 | 8.01k | new=getpdstemplate(number); |
347 | 8.01k | if (new == NULL) return NULL; |
348 | | |
349 | 8.01k | if ( ! new->needext ) return(new); |
350 | | |
351 | 5.70k | if ( number == 3 ) { |
352 | 0 | new->extlen=list[26]; |
353 | 0 | new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen); |
354 | 0 | for (i=0;i<new->extlen;i++) { |
355 | 0 | new->ext[i]=1; |
356 | 0 | } |
357 | 0 | } |
358 | 5.70k | else if ( number == 4 ) { |
359 | 2.85k | new->extlen=list[25]; |
360 | 2.85k | new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen); |
361 | 96.8k | for (i=0;i<new->extlen;i++) { |
362 | 94.0k | new->ext[i]=1; |
363 | 94.0k | } |
364 | 2.85k | } |
365 | 2.84k | else if ( number == 8 ) { |
366 | 215 | if ( list[21] > 1 ) { |
367 | 12 | new->extlen=(list[21]-1)*6; |
368 | 12 | new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen); |
369 | 252 | for (j=2;j<=list[21];j++) { |
370 | 240 | l=(j-2)*6; |
371 | 1.68k | for (k=0;k<6;k++) { |
372 | 1.44k | new->ext[l+k]=new->map[23+k]; |
373 | 1.44k | } |
374 | 240 | } |
375 | 12 | } |
376 | 215 | } |
377 | 2.63k | else if ( number == 9 ) { |
378 | 0 | if ( list[28] > 1 ) { |
379 | 0 | new->extlen=(list[28]-1)*6; |
380 | 0 | new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen); |
381 | 0 | for (j=2;j<=list[28];j++) { |
382 | 0 | l=(j-2)*6; |
383 | 0 | for (k=0;k<6;k++) { |
384 | 0 | new->ext[l+k]=new->map[30+k]; |
385 | 0 | } |
386 | 0 | } |
387 | 0 | } |
388 | 0 | } |
389 | 2.63k | else if ( number == 10 ) { |
390 | 348 | if ( list[22] > 1 ) { |
391 | 348 | new->extlen=(list[22]-1)*6; |
392 | 348 | new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen); |
393 | 4.52k | for (j=2;j<=list[22];j++) { |
394 | 4.17k | l=(j-2)*6; |
395 | 29.2k | for (k=0;k<6;k++) { |
396 | 25.0k | new->ext[l+k]=new->map[24+k]; |
397 | 25.0k | } |
398 | 4.17k | } |
399 | 348 | } |
400 | 348 | } |
401 | 2.28k | else if ( number == 11 ) { |
402 | 0 | if ( list[24] > 1 ) { |
403 | 0 | new->extlen=(list[24]-1)*6; |
404 | 0 | new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen); |
405 | 0 | for (j=2;j<=list[24];j++) { |
406 | 0 | l=(j-2)*6; |
407 | 0 | for (k=0;k<6;k++) { |
408 | 0 | new->ext[l+k]=new->map[26+k]; |
409 | 0 | } |
410 | 0 | } |
411 | 0 | } |
412 | 0 | } |
413 | 2.28k | else if ( number == 12 ) { |
414 | 634 | if ( list[23] > 1 ) { |
415 | 634 | new->extlen=(list[23]-1)*6; |
416 | 634 | new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen); |
417 | 55.2k | for (j=2;j<=list[23];j++) { |
418 | 54.6k | l=(j-2)*6; |
419 | 382k | for (k=0;k<6;k++) { |
420 | 327k | new->ext[l+k]=new->map[25+k]; |
421 | 327k | } |
422 | 54.6k | } |
423 | 634 | } |
424 | 634 | } |
425 | 1.65k | else if ( number == 13 ) { |
426 | 0 | new->extlen=(list[37] > 1 ? ((list[37]-1)*6) : 0)+list[26]; |
427 | 0 | new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen); |
428 | 0 | if ( list[37] > 1 ) { |
429 | 0 | for (j=2;j<=list[37];j++) { |
430 | 0 | l=(j-2)*6; |
431 | 0 | for (k=0;k<6;k++) { |
432 | 0 | new->ext[l+k]=new->map[39+k]; |
433 | 0 | } |
434 | 0 | } |
435 | 0 | } |
436 | 0 | l=(list[37]-1)*6; |
437 | 0 | if ( l<0 ) l=0; |
438 | 0 | for (i=0;i<list[26];i++) { |
439 | 0 | new->ext[l+i]=1; |
440 | 0 | } |
441 | 0 | } |
442 | 1.65k | else if ( number == 14 ) { |
443 | 0 | new->extlen=(list[36] > 1 ? ((list[36]-1)*6) : 0) +list[25]; |
444 | 0 | new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen); |
445 | 0 | if ( list[36] > 1 ) { |
446 | 0 | for (j=2;j<=list[36];j++) { |
447 | 0 | l=(j-2)*6; |
448 | 0 | for (k=0;k<6;k++) { |
449 | 0 | new->ext[l+k]=new->map[38+k]; |
450 | 0 | } |
451 | 0 | } |
452 | 0 | } |
453 | 0 | l=(list[36]-1)*6; |
454 | 0 | if ( l<0 ) l=0; |
455 | 0 | for (i=0;i<list[25];i++) { |
456 | 0 | new->ext[l+i]=1; |
457 | 0 | } |
458 | 0 | } |
459 | 1.65k | else if ( number == 30 ) { |
460 | 6 | new->extlen=list[4]*5; |
461 | 6 | new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen); |
462 | 156 | for (i=0;i<list[4];i++) { |
463 | 150 | l=i*5; |
464 | 150 | new->ext[l]=2; |
465 | 150 | new->ext[l+1]=2; |
466 | 150 | new->ext[l+2]=1; |
467 | 150 | new->ext[l+3]=1; |
468 | 150 | new->ext[l+4]=4; |
469 | 150 | } |
470 | 6 | } |
471 | 1.64k | else if ( number == 31 ) { |
472 | 0 | new->extlen=list[4]*5; |
473 | 0 | new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen); |
474 | 0 | for (i=0;i<list[4];i++) { |
475 | 0 | l=i*5; |
476 | 0 | new->ext[l]=2; |
477 | 0 | new->ext[l+1]=2; |
478 | 0 | new->ext[l+2]=2; |
479 | 0 | new->ext[l+3]=1; |
480 | 0 | new->ext[l+4]=4; |
481 | 0 | } |
482 | 0 | } |
483 | 1.64k | else if ( number == 42 ) { |
484 | 0 | if ( list[22] > 1 ) { |
485 | 0 | new->extlen=(list[22]-1)*6; |
486 | 0 | new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen); |
487 | 0 | for (j=2;j<=list[22];j++) { |
488 | 0 | l=(j-2)*6; |
489 | 0 | for (k=0;k<6;k++) { |
490 | 0 | new->ext[l+k]=new->map[24+k]; |
491 | 0 | } |
492 | 0 | } |
493 | 0 | } |
494 | 0 | } |
495 | 1.64k | else if ( number == 43 ) { |
496 | 22 | if ( list[25] > 1 ) { |
497 | 2 | new->extlen=(list[25]-1)*6; |
498 | 2 | new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen); |
499 | 20 | for (j=2;j<=list[25];j++) { |
500 | 18 | l=(j-2)*6; |
501 | 126 | for (k=0;k<6;k++) { |
502 | 108 | new->ext[l+k]=new->map[27+k]; |
503 | 108 | } |
504 | 18 | } |
505 | 2 | } |
506 | 22 | } |
507 | 1.62k | else if ( number == 32 ) { |
508 | 59 | new->extlen=list[9]*5; /* ERO: was 10, but wrong given the below loop */ |
509 | 59 | new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen); |
510 | 718 | for (i=0;i<list[9];i++) { |
511 | 659 | l=i*5; |
512 | 659 | new->ext[l]=2; |
513 | 659 | new->ext[l+1]=2; |
514 | 659 | new->ext[l+2]=2; |
515 | 659 | new->ext[l+3]=-1; |
516 | 659 | new->ext[l+4]=-4; |
517 | 659 | } |
518 | 59 | } |
519 | 1.56k | else if ( number == 46 ) { |
520 | 0 | if ( list[27] > 1 ) { |
521 | 0 | new->extlen=(list[27]-1)*6; |
522 | 0 | new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen); |
523 | 0 | for (j=2;j<=list[27];j++) { |
524 | 0 | l=(j-2)*6; |
525 | 0 | for (k=0;k<6;k++) { |
526 | 0 | new->ext[l+k]=new->map[29+k]; |
527 | 0 | } |
528 | 0 | } |
529 | 0 | } |
530 | 0 | } |
531 | 1.56k | else if ( number == 47 ) { |
532 | 10 | if ( list[30] > 1 ) { |
533 | 0 | new->extlen=(list[30]-1)*6; |
534 | 0 | new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen); |
535 | 0 | for (j=2;j<=list[30];j++) { |
536 | 0 | l=(j-2)*6; |
537 | 0 | for (k=0;k<6;k++) { |
538 | 0 | new->ext[l+k]=new->map[32+k]; |
539 | 0 | } |
540 | 0 | } |
541 | 0 | } |
542 | 10 | } |
543 | 1.55k | else if ( number == 51 ) { |
544 | 0 | new->extlen=list[15]*6; /* GDAL fix */ |
545 | 0 | new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen); |
546 | 0 | for (i=0;i<list[15];i++) { |
547 | 0 | l=i*6; |
548 | 0 | new->ext[l]=1; |
549 | 0 | new->ext[l+1]=1; |
550 | 0 | new->ext[l+2]=-1; |
551 | 0 | new->ext[l+3]=-4; |
552 | 0 | new->ext[l+4]=-1; |
553 | 0 | new->ext[l+5]=-4; |
554 | 0 | } |
555 | 0 | } |
556 | 1.55k | else if ( number == 33 ) { |
557 | 0 | new->extlen=list[9]; |
558 | 0 | new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen); |
559 | 0 | for (i=0;i<new->extlen;i++) { |
560 | 0 | new->ext[i]=1; |
561 | 0 | } |
562 | 0 | } |
563 | 1.55k | else if ( number == 34 ) { |
564 | 0 | new->extlen=(list[24] > 1 ? ((list[24]-1)*6) : 0)+list[9]; |
565 | 0 | new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen); |
566 | 0 | if ( list[24] > 1 ) { |
567 | 0 | for (j=2;j<=list[24];j++) { |
568 | 0 | l=(j-2)*6; |
569 | 0 | for (k=0;k<6;k++) { |
570 | 0 | new->ext[l+k]=new->map[26+k]; |
571 | 0 | } |
572 | 0 | } |
573 | 0 | } |
574 | 0 | l=(list[24]-1)*6; |
575 | 0 | if ( l<0 ) l=0; |
576 | 0 | for (i=0;i<list[9];i++) { |
577 | 0 | new->ext[l+i]=1; |
578 | 0 | } |
579 | 0 | } |
580 | 1.55k | else if ( number == 53 ) { |
581 | 0 | new->extlen=list[3]; |
582 | 0 | new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen); |
583 | 0 | for (i=0;i<new->extlen;i++) { |
584 | 0 | new->ext[i]=1; |
585 | 0 | } |
586 | 0 | } |
587 | 1.55k | else if ( number == 54 ) { |
588 | 2 | new->extlen=list[3]; |
589 | 2 | new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen); |
590 | 252 | for (i=0;i<new->extlen;i++) { |
591 | 250 | new->ext[i]=1; |
592 | 250 | } |
593 | 2 | } |
594 | 1.55k | else if ( number == 91 ) { |
595 | 2 | new->extlen=(list[28] > 1 ? ((list[28]-1)*6) : 0)+list[15]; |
596 | 2 | new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen); |
597 | 2 | if ( list[28] > 1 ) { |
598 | 0 | for (j=2;j<=list[28];j++) { |
599 | 0 | l=(j-2)*6; |
600 | 0 | for (k=0;k<6;k++) { |
601 | 0 | new->ext[l+k]=new->map[30+k]; |
602 | 0 | } |
603 | 0 | } |
604 | 0 | } |
605 | 2 | l=(list[28]-1)*6; /* GDAL fix */ |
606 | 2 | if ( l<0 ) l=0; |
607 | 2 | for (i=0;i<list[15];i++) { |
608 | 0 | new->ext[l+i]=1; |
609 | 0 | } |
610 | 2 | } |
611 | | // PDT 4.57 (10/07/2015) |
612 | 1.54k | else if ( number == 57 ) { |
613 | 0 | new->extlen=list[6]*15; |
614 | 0 | new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen); |
615 | 0 | for (i=0;i<list[6];i++) { |
616 | 0 | l=i*15; |
617 | 0 | new->ext[l]=1; |
618 | 0 | new->ext[l+1]=-4; |
619 | 0 | new->ext[l+2]=1; |
620 | 0 | new->ext[l+3]=1; |
621 | 0 | new->ext[l+4]=1; |
622 | 0 | new->ext[l+5]=2; |
623 | 0 | new->ext[l+6]=1; |
624 | 0 | new->ext[l+7]=1; |
625 | 0 | new->ext[l+8]=-4; |
626 | 0 | new->ext[l+9]=1; |
627 | 0 | new->ext[l+10]=-1; |
628 | 0 | new->ext[l+11]=-4; |
629 | 0 | new->ext[l+12]=1; |
630 | 0 | new->ext[l+13]=-1; |
631 | 0 | new->ext[l+14]=-4; |
632 | 0 | } |
633 | 0 | } |
634 | | // PDT 4.61 (10/07/2015) |
635 | 1.54k | else if ( number == 61 ) { |
636 | 1.54k | if ( list[30] > 1 ) { |
637 | 635 | new->extlen=(list[30]-1)*6; |
638 | 635 | new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen); |
639 | 15.3k | for (j=2;j<=list[30];j++) { |
640 | 14.7k | l=(j-2)*6; |
641 | 103k | for (k=0;k<6;k++) { |
642 | 88.5k | new->ext[l+k]=new->map[32+k]; |
643 | 88.5k | } |
644 | 14.7k | } |
645 | 635 | } |
646 | 1.54k | } |
647 | | |
648 | 5.70k | return(new); |
649 | | |
650 | 8.01k | } |
651 | | |