LCOV - code coverage report
Current view: top level - frmts/grib/degrib/g2clib - pdstemplates.c (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 54 243 22.2 %
Date: 2025-09-10 17:48:50 Functions: 4 4 100.0 %

          Line data    Source code
       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: Probability 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: Probability 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        7824 : const struct pdstemplate *get_templatespds()
     179             : {
     180        7824 :     return templatespds;
     181             : }
     182             : 
     183        2565 : 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             : {
     220        2565 :            g2int j,l_getpdsindex=-1;
     221             : 
     222       11089 :            for (j=0;j<MAXPDSTEMP;j++) {
     223       11078 :               if (number == templatespds[j].template_num) {
     224        2554 :                  l_getpdsindex=j;
     225        2554 :                  return(l_getpdsindex);
     226             :               }
     227             :            }
     228             : 
     229          11 :            return(l_getpdsindex);
     230             : }
     231             : 
     232             : 
     233        1301 : 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             : {
     274             :            g2int l_index;
     275             :            gtemplate *new;
     276             : 
     277        1301 :            l_index=getpdsindex(number);
     278             : 
     279        1301 :            if (l_index != -1) {
     280        1296 :               new=(gtemplate *)malloc(sizeof(gtemplate));
     281        1296 :               new->type=4;
     282        1296 :               new->num=templatespds[l_index].template_num;
     283        1296 :               new->maplen=templatespds[l_index].mappdslen;
     284        1296 :               new->needext=templatespds[l_index].needext;
     285        1296 :               new->map=(g2int *)templatespds[l_index].mappds;
     286        1296 :               new->extlen=0;
     287        1296 :               new->ext=0;        //NULL
     288        1296 :               return(new);
     289             :            }
     290             :            else {
     291             :              //printf("getpdstemplate: PDS Template 4.%d not defined.\n",(int)number);
     292             :            }
     293             : 
     294           5 :          return(0);        //NULL
     295             : }
     296             : 
     297             : 
     298         461 : gtemplate *extpdstemplate(g2int number,g2int *list)
     299             : ///$$$  SUBPROGRAM DOCUMENTATION BLOCK
     300             : //                .      .    .                                       .
     301             : // SUBPROGRAM:    extpdstemplate
     302             : //   PRGMMR: Gilbert         ORG: W/NP11    DATE: 2000-05-11
     303             : //
     304             : // ABSTRACT: This subroutine generates the remaining octet map for a
     305             : //   given Product Definition Template, if required.  Some Templates can
     306             : //   vary depending on data values given in an earlier part of the
     307             : //   Template, and it is necessary to know some of the earlier entry
     308             : //   values to generate the full octet map of the Template.
     309             : //
     310             : // PROGRAM HISTORY LOG:
     311             : // 2000-05-11  Gilbert
     312             : // 2009-01-14  Vuong     Changed structure name template to gtemplate
     313             : // 2009-08-05  Vuong     Added Product Definition Template 4.31
     314             : // 2010-08-03  Vuong     Added Product Definition Template 4.42 and 4.43
     315             : // 2010-12-08  Vuong     Corrected Product Definition Template 4.42 and 4.43
     316             : // 2012-02-15  Vuong     Added Templates 4.44,4.45,4.46,4.47,4.48,4.50,
     317             : //                       4.51,4.91,4.32 and 4.52
     318             : // 2013-08-05  Vuong     Corrected 4.91 and added Templates 4.33,4.34,4.53,4.54
     319             : // 2015-10-07  Vuong     Added Templates 4.57, 4.60, 4.61 and
     320             : //                       allow a forecast time to be negative
     321             : //
     322             : // USAGE:    CALL extpdstemplate(number,list)
     323             : //   INPUT ARGUMENT LIST:
     324             : //     number   - NN, indicating the number of the Product Definition
     325             : //                Template 4.NN that is being requested.
     326             : //     list()   - The list of values for each entry in the
     327             : //                the Product Definition Template 4.NN.
     328             : //
     329             : //   RETURN VALUE:
     330             : //        - Pointer to the returned template struct.
     331             : //          Returns NULL pointer, if template not found.
     332             : //
     333             : // ATTRIBUTES:
     334             : //   LANGUAGE: C
     335             : //   MACHINE:  IBM SP
     336             : //
     337             : //$$$
     338             : {
     339             :            gtemplate *new;
     340             :            g2int l_index,i,j,k,l;
     341             : 
     342         461 :            l_index=getpdsindex(number);
     343         461 :            if (l_index == -1) return(0);
     344             : 
     345         461 :            new=getpdstemplate(number);
     346         461 :            if (new == NULL) return NULL;
     347             : 
     348         461 :            if ( ! new->needext ) return(new);
     349             : 
     350         152 :            if ( number == 3 ) {
     351           0 :               new->extlen=list[26];
     352           0 :               new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen);
     353           0 :               for (i=0;i<new->extlen;i++) {
     354           0 :                  new->ext[i]=1;
     355             :               }
     356             :            }
     357         152 :            else if ( number == 4 ) {
     358           0 :               new->extlen=list[25];
     359           0 :               new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen);
     360           0 :               for (i=0;i<new->extlen;i++) {
     361           0 :                  new->ext[i]=1;
     362             :               }
     363             :            }
     364         152 :            else if ( number == 8 ) {
     365         115 :               if ( list[21] > 1 ) {
     366           0 :                  new->extlen=(list[21]-1)*6;
     367           0 :                  new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen);
     368           0 :                  for (j=2;j<=list[21];j++) {
     369           0 :                     l=(j-2)*6;
     370           0 :                     for (k=0;k<6;k++) {
     371           0 :                        new->ext[l+k]=new->map[23+k];
     372             :                     }
     373             :                  }
     374             :               }
     375             :            }
     376          37 :            else if ( number == 9 ) {
     377           0 :               if ( list[28] > 1 ) {
     378           0 :                  new->extlen=(list[28]-1)*6;
     379           0 :                  new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen);
     380           0 :                  for (j=2;j<=list[28];j++) {
     381           0 :                     l=(j-2)*6;
     382           0 :                     for (k=0;k<6;k++) {
     383           0 :                        new->ext[l+k]=new->map[30+k];
     384             :                     }
     385             :                  }
     386             :               }
     387             :            }
     388          37 :            else if ( number == 10 ) {
     389           0 :               if ( list[22] > 1 ) {
     390           0 :                  new->extlen=(list[22]-1)*6;
     391           0 :                  new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen);
     392           0 :                  for (j=2;j<=list[22];j++) {
     393           0 :                     l=(j-2)*6;
     394           0 :                     for (k=0;k<6;k++) {
     395           0 :                        new->ext[l+k]=new->map[24+k];
     396             :                     }
     397             :                  }
     398             :               }
     399             :            }
     400          37 :            else if ( number == 11 ) {
     401           0 :               if ( list[24] > 1 ) {
     402           0 :                  new->extlen=(list[24]-1)*6;
     403           0 :                  new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen);
     404           0 :                  for (j=2;j<=list[24];j++) {
     405           0 :                     l=(j-2)*6;
     406           0 :                     for (k=0;k<6;k++) {
     407           0 :                        new->ext[l+k]=new->map[26+k];
     408             :                     }
     409             :                  }
     410             :               }
     411             :            }
     412          37 :            else if ( number == 12 ) {
     413          10 :               if ( list[23] > 1 ) {
     414           0 :                  new->extlen=(list[23]-1)*6;
     415           0 :                  new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen);
     416           0 :                  for (j=2;j<=list[23];j++) {
     417           0 :                     l=(j-2)*6;
     418           0 :                     for (k=0;k<6;k++) {
     419           0 :                        new->ext[l+k]=new->map[25+k];
     420             :                     }
     421             :                  }
     422             :               }
     423             :            }
     424          27 :            else if ( number == 13 ) {
     425           0 :               new->extlen=(list[37] > 1 ? ((list[37]-1)*6) : 0)+list[26];
     426           0 :               new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen);
     427           0 :               if ( list[37] > 1 ) {
     428           0 :                  for (j=2;j<=list[37];j++) {
     429           0 :                     l=(j-2)*6;
     430           0 :                     for (k=0;k<6;k++) {
     431           0 :                        new->ext[l+k]=new->map[39+k];
     432             :                     }
     433             :                  }
     434             :               }
     435           0 :               l=(list[37]-1)*6;
     436           0 :               if ( l<0 ) l=0;
     437           0 :               for (i=0;i<list[26];i++) {
     438           0 :                 new->ext[l+i]=1;
     439             :               }
     440             :            }
     441          27 :            else if ( number == 14 ) {
     442           0 :               new->extlen=(list[36] > 1 ? ((list[36]-1)*6) : 0) +list[25];
     443           0 :               new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen);
     444           0 :               if ( list[36] > 1 ) {
     445           0 :                  for (j=2;j<=list[36];j++) {
     446           0 :                     l=(j-2)*6;
     447           0 :                     for (k=0;k<6;k++) {
     448           0 :                        new->ext[l+k]=new->map[38+k];
     449             :                     }
     450             :                  }
     451             :               }
     452           0 :               l=(list[36]-1)*6;
     453           0 :               if ( l<0 ) l=0;
     454           0 :               for (i=0;i<list[25];i++) {
     455           0 :                 new->ext[l+i]=1;
     456             :               }
     457             :            }
     458          27 :            else if ( number == 30 ) {
     459           0 :               new->extlen=list[4]*5;
     460           0 :               new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen);
     461           0 :               for (i=0;i<list[4];i++) {
     462           0 :                  l=i*5;
     463           0 :                  new->ext[l]=2;
     464           0 :                  new->ext[l+1]=2;
     465           0 :                  new->ext[l+2]=1;
     466           0 :                  new->ext[l+3]=1;
     467           0 :                  new->ext[l+4]=4;
     468             :               }
     469             :            }
     470          27 :            else if ( number == 31 ) {
     471           0 :               new->extlen=list[4]*5;
     472           0 :               new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen);
     473           0 :               for (i=0;i<list[4];i++) {
     474           0 :                  l=i*5;
     475           0 :                  new->ext[l]=2;
     476           0 :                  new->ext[l+1]=2;
     477           0 :                  new->ext[l+2]=2;
     478           0 :                  new->ext[l+3]=1;
     479           0 :                  new->ext[l+4]=4;
     480             :               }
     481             :            }
     482          27 :            else if ( number == 42 ) {
     483           0 :               if ( list[22] > 1 ) {
     484           0 :                  new->extlen=(list[22]-1)*6;
     485           0 :                  new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen);
     486           0 :                  for (j=2;j<=list[22];j++) {
     487           0 :                     l=(j-2)*6;
     488           0 :                     for (k=0;k<6;k++) {
     489           0 :                        new->ext[l+k]=new->map[24+k];
     490             :                     }
     491             :                  }
     492             :               }
     493             :            }
     494          27 :            else if ( number == 43 ) {
     495           0 :               if ( list[25] > 1 ) {
     496           0 :                  new->extlen=(list[25]-1)*6;
     497           0 :                  new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen);
     498           0 :                  for (j=2;j<=list[25];j++) {
     499           0 :                     l=(j-2)*6;
     500           0 :                     for (k=0;k<6;k++) {
     501           0 :                        new->ext[l+k]=new->map[27+k];
     502             :                     }
     503             :                  }
     504             :               }
     505             :            }
     506          27 :            else if ( number == 32 ) {
     507          27 :               new->extlen=list[9]*5; /* ERO: was 10, but wrong given the below loop */
     508          27 :               new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen);
     509          77 :               for (i=0;i<list[9];i++) {
     510          50 :                  l=i*5;
     511          50 :                  new->ext[l]=2;
     512          50 :                  new->ext[l+1]=2;
     513          50 :                  new->ext[l+2]=2;
     514          50 :                  new->ext[l+3]=-1;
     515          50 :                  new->ext[l+4]=-4;
     516             :               }
     517             :            }
     518           0 :            else if ( number == 46 ) {
     519           0 :               if ( list[27] > 1 ) {
     520           0 :                  new->extlen=(list[27]-1)*6;
     521           0 :                  new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen);
     522           0 :                  for (j=2;j<=list[27];j++) {
     523           0 :                     l=(j-2)*6;
     524           0 :                     for (k=0;k<6;k++) {
     525           0 :                        new->ext[l+k]=new->map[29+k];
     526             :                     }
     527             :                  }
     528             :               }
     529             :            }
     530           0 :            else if ( number == 47 ) {
     531           0 :               if ( list[30] > 1 ) {
     532           0 :                  new->extlen=(list[30]-1)*6;
     533           0 :                  new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen);
     534           0 :                  for (j=2;j<=list[30];j++) {
     535           0 :                     l=(j-2)*6;
     536           0 :                     for (k=0;k<6;k++) {
     537           0 :                        new->ext[l+k]=new->map[32+k];
     538             :                     }
     539             :                  }
     540             :               }
     541             :            }
     542           0 :            else if ( number == 51 ) {
     543           0 :               new->extlen=list[15]*6; /* GDAL fix */
     544           0 :               new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen);
     545           0 :               for (i=0;i<list[15];i++) {
     546           0 :                  l=i*6;
     547           0 :                  new->ext[l]=1;
     548           0 :                  new->ext[l+1]=1;
     549           0 :                  new->ext[l+2]=-1;
     550           0 :                  new->ext[l+3]=-4;
     551           0 :                  new->ext[l+4]=-1;
     552           0 :                  new->ext[l+5]=-4;
     553             :               }
     554             :            }
     555           0 :            else if ( number == 33 ) {
     556           0 :               new->extlen=list[9];
     557           0 :               new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen);
     558           0 :               for (i=0;i<new->extlen;i++) {
     559           0 :                  new->ext[i]=1;
     560             :               }
     561             :            }
     562           0 :            else if ( number == 34 ) {
     563           0 :               new->extlen=(list[24] > 1 ? ((list[24]-1)*6) : 0)+list[9];
     564           0 :               new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen);
     565           0 :               if ( list[24] > 1 ) {
     566           0 :                  for (j=2;j<=list[24];j++) {
     567           0 :                     l=(j-2)*6;
     568           0 :                     for (k=0;k<6;k++) {
     569           0 :                        new->ext[l+k]=new->map[26+k];
     570             :                     }
     571             :                  }
     572             :               }
     573           0 :               l=(list[24]-1)*6;
     574           0 :               if ( l<0 ) l=0;
     575           0 :               for (i=0;i<list[9];i++) {
     576           0 :                 new->ext[l+i]=1;
     577             :               }
     578             :            }
     579           0 :            else if ( number == 53 ) {
     580           0 :               new->extlen=list[3];
     581           0 :               new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen);
     582           0 :               for (i=0;i<new->extlen;i++) {
     583           0 :                  new->ext[i]=1;
     584             :               }
     585             :            }
     586           0 :            else if ( number == 54 ) {
     587           0 :               new->extlen=list[3];
     588           0 :               new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen);
     589           0 :               for (i=0;i<new->extlen;i++) {
     590           0 :                  new->ext[i]=1;
     591             :               }
     592             :            }
     593           0 :            else if ( number == 91 ) {
     594           0 :               new->extlen=(list[28] > 1 ? ((list[28]-1)*6) : 0)+list[15];
     595           0 :               new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen);
     596           0 :               if ( list[28] > 1 ) {
     597           0 :                  for (j=2;j<=list[28];j++) {
     598           0 :                     l=(j-2)*6;
     599           0 :                     for (k=0;k<6;k++) {
     600           0 :                        new->ext[l+k]=new->map[30+k];
     601             :                     }
     602             :                  }
     603             :               }
     604           0 :               l=(list[28]-1)*6; /* GDAL fix */
     605           0 :               if ( l<0 ) l=0;
     606           0 :               for (i=0;i<list[15];i++) {
     607           0 :                 new->ext[l+i]=1;
     608             :               }
     609             :              }
     610             : // PDT 4.57  (10/07/2015)
     611           0 :            else if ( number == 57 ) {
     612           0 :               new->extlen=list[6]*15;
     613           0 :               new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen);
     614           0 :               for (i=0;i<list[6];i++) {
     615           0 :                  l=i*15;
     616           0 :                  new->ext[l]=1;
     617           0 :                  new->ext[l+1]=-4;
     618           0 :                  new->ext[l+2]=1;
     619           0 :                  new->ext[l+3]=1;
     620           0 :                  new->ext[l+4]=1;
     621           0 :                  new->ext[l+5]=2;
     622           0 :                  new->ext[l+6]=1;
     623           0 :                  new->ext[l+7]=1;
     624           0 :                  new->ext[l+8]=-4;
     625           0 :                  new->ext[l+9]=1;
     626           0 :                  new->ext[l+10]=-1;
     627           0 :                  new->ext[l+11]=-4;
     628           0 :                  new->ext[l+12]=1;
     629           0 :                  new->ext[l+13]=-1;
     630           0 :                  new->ext[l+14]=-4;
     631             :               }
     632             :            }
     633             : // PDT 4.61  (10/07/2015)
     634           0 :            else if ( number == 61 ) {
     635           0 :               if ( list[30] > 1 ) {
     636           0 :                  new->extlen=(list[30]-1)*6;
     637           0 :                  new->ext=(g2int *)malloc(sizeof(g2int)*new->extlen);
     638           0 :                  for (j=2;j<=list[30];j++) {
     639           0 :                     l=(j-2)*6;
     640           0 :                     for (k=0;k<6;k++) {
     641           0 :                        new->ext[l+k]=new->map[32+k];
     642             :                     }
     643             :                  }
     644             :               }
     645             :            }
     646             : 
     647         152 :            return(new);
     648             : 
     649             : }
     650             : 

Generated by: LCOV version 1.14