Loading...
Searching...
No Matches
getdim.c
Go to the documentation of this file.
#include "grib2_int.h"
#include <stdio.h>
#include <stdlib.h>
g2int
getdim(unsigned char *csec3, g2int *width, g2int *height, g2int *iscan)
{
g2int *igdstmpl = NULL, *list_opt = NULL;
g2int *igds = NULL;
g2int iofst, igdtlen, num_opt, jerr;
iofst = 0; /* set offset to beginning of section */
if (!(jerr = g2_unpack3(csec3, &iofst, &igds, &igdstmpl, &igdtlen,
&list_opt, &num_opt)))
{
switch (igds[4]) /* Template number */
{
case 0: /* Lat/Lon */
case 1:
case 2:
case 3: {
*width = igdstmpl[7];
*height = igdstmpl[8];
*iscan = igdstmpl[18];
break;
}
case 10: /* Mercator */
{
*width = igdstmpl[7];
*height = igdstmpl[8];
*iscan = igdstmpl[15];
break;
}
case 20: /* Polar Stereographic */
{
*width = igdstmpl[7];
*height = igdstmpl[8];
*iscan = igdstmpl[17];
break;
}
case 30: /* Lambert Conformal */
{
*width = igdstmpl[7];
*height = igdstmpl[8];
*iscan = igdstmpl[17];
break;
}
case 40: /* Gaussian */
case 41:
case 42:
case 43: {
*width = igdstmpl[7];
*height = igdstmpl[8];
*iscan = igdstmpl[18];
break;
}
case 90: /* Space View/Orthographic */
{
*width = igdstmpl[7];
*height = igdstmpl[8];
*iscan = igdstmpl[16];
break;
}
case 110: /* Equatorial Azimuthal */
{
*width = igdstmpl[7];
*height = igdstmpl[8];
*iscan = igdstmpl[15];
break;
}
default: {
*width = 0;
*height = 0;
*iscan = 0;
break;
}
} /* end switch */
}
else
{
*width = 0;
*height = 0;
}
if (igds)
free(igds);
if (igdstmpl)
free(igdstmpl);
if (list_opt)
free(list_opt);
return 0;
}
g2_unpack3
g2int g2_unpack3(unsigned char *cgrib, g2int *iofst, g2int **igds, g2int **igdstmpl, g2int *mapgridlen, g2int **ideflist, g2int *idefnum)
Unpack Section 3 (Grid Definition Section) of a GRIB2 message.
Definition g2_unpack3.c:62
getdim
g2int getdim(unsigned char *csec3, g2int *width, g2int *height, g2int *iscan)
Return the dimensions and scanning mode of a grid definition.
Definition getdim.c:27
g2int
int64_t g2int
Long integer type.
Definition grib2.h:32
grib2_int.h
Header file with internal function prototypes NCEPLIBS-g2c library.