LCOV - code coverage report
Current view: directory - frmts/grib/degrib18/g2clib-1.0.4 - getdim.c (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 45 0 0.0 %
Date: 2011-12-18 Functions: 1 0 0.0 %

       1                 : #include <stdio.h>
       2                 : #include <stdlib.h>
       3                 : #include "grib2.h"
       4                 : 
       5                 : g2int g2_unpack3(unsigned char *,g2int *,g2int **,g2int **,
       6                 :                          g2int *,g2int **,g2int *);
       7                 : 
       8               0 : g2int getdim(unsigned char *csec3,g2int *width,g2int *height,g2int *iscan)
       9                 : //$$$  SUBPROGRAM DOCUMENTATION BLOCK
      10                 : //                .      .    .                                       .
      11                 : // SUBPROGRAM:    getdim 
      12                 : //   PRGMMR: Gilbert         ORG: W/NP11    DATE: 2002-12-11
      13                 : //
      14                 : // ABSTRACT: This subroutine returns the dimensions and scanning mode of 
      15                 : //   a grid definition packed in GRIB2 Grid Definition Section 3 format.
      16                 : //
      17                 : // PROGRAM HISTORY LOG:
      18                 : // 2002-12-11  Gilbert
      19                 : //
      20                 : // USAGE:    int getdim(unsigned char *csec3,g2int *width,
      21                 : //                      g2int *height, g2int *iscan)
      22                 : //   INPUT ARGUMENT LIST:
      23                 : //     csec3    - Character array that contains the packed GRIB2 GDS
      24                 : //
      25                 : //   OUTPUT ARGUMENT LIST:      
      26                 : //     width    - x (or i) dimension of the grid.
      27                 : //     height   - y (or j) dimension of the grid.
      28                 : //     iscan    - Scanning mode ( see Code Table 3.4 )
      29                 : //
      30                 : // REMARKS:  Returns width and height set to zero, if grid template
      31                 : //           not recognized.
      32                 : //
      33                 : // ATTRIBUTES:
      34                 : //   LANGUAGE: C
      35                 : //   MACHINE:  IBM SP
      36                 : //
      37                 : //$$$
      38                 : {
      39                 :     
      40                 :       g2int  *igdstmpl,*list_opt;
      41                 :       g2int  *igds;
      42                 :       g2int  iofst,igdtlen,num_opt,jerr;
      43                 : 
      44               0 :       igdstmpl=0;
      45               0 :       list_opt=0;
      46               0 :       igds=0;
      47               0 :       iofst=0;       // set offset to beginning of section
      48               0 :       jerr= g2_unpack3(csec3,&iofst,&igds,&igdstmpl,
      49                 :                        &igdtlen,&list_opt,&num_opt);
      50               0 :       if (jerr == 0) {
      51               0 :          switch ( igds[4] )     //  Template number
      52                 :          {
      53                 :            case 0:    // Lat/Lon
      54                 :            case 1:
      55                 :            case 2:
      56                 :            case 3:
      57                 :            {
      58               0 :               *width=igdstmpl[7];
      59               0 :               *height=igdstmpl[8];
      60               0 :               *iscan=igdstmpl[18];
      61               0 :               break;
      62                 :            }
      63                 :            case 10:   // Mercator
      64                 :            {
      65               0 :               *width=igdstmpl[7];
      66               0 :               *height=igdstmpl[8];
      67               0 :               *iscan=igdstmpl[15];
      68               0 :               break;
      69                 :            }
      70                 :            case 20:   // Polar Stereographic
      71                 :            {
      72               0 :               *width=igdstmpl[7];
      73               0 :               *height=igdstmpl[8];
      74               0 :               *iscan=igdstmpl[17];
      75               0 :               break;
      76                 :            }
      77                 :            case 30:   // Lambert Conformal
      78                 :            {
      79               0 :               *width=igdstmpl[7];
      80               0 :               *height=igdstmpl[8];
      81               0 :               *iscan=igdstmpl[17];
      82               0 :               break;
      83                 :            }
      84                 :            case 40:   // Gaussian
      85                 :            case 41:
      86                 :            case 42:
      87                 :            case 43:
      88                 :            {
      89               0 :               *width=igdstmpl[7];
      90               0 :               *height=igdstmpl[8];
      91               0 :               *iscan=igdstmpl[18];
      92               0 :               break;
      93                 :            }
      94                 :            case 90:   // Space View/Orthographic
      95                 :            {
      96               0 :               *width=igdstmpl[7];
      97               0 :               *height=igdstmpl[8];
      98               0 :               *iscan=igdstmpl[16];
      99               0 :               break;
     100                 :            }
     101                 :            case 110:   // Equatorial Azimuthal
     102                 :            {
     103               0 :               *width=igdstmpl[7];
     104               0 :               *height=igdstmpl[8];
     105               0 :               *iscan=igdstmpl[15];
     106               0 :               break;
     107                 :            }
     108                 :            default:
     109                 :            {
     110               0 :               *width=0;
     111               0 :               *height=0;
     112               0 :               *iscan=0;
     113                 :               break;
     114                 :            }
     115                 :          }  // end switch
     116                 :       }
     117                 :       else {
     118               0 :          *width=0;
     119               0 :          *height=0;
     120                 :       }
     121                 : 
     122               0 :       if (igds != 0) free(igds);
     123               0 :       if (igdstmpl != 0) free(igdstmpl);
     124               0 :       if (list_opt != 0) free(list_opt);
     125                 : 
     126               0 :       return 0;
     127                 : }

Generated by: LCOV version 1.7