NCEPLIBS-g2c 2.0.0
Loading...
Searching...
No Matches
getdim.c
Go to the documentation of this file.
1
6#include "grib2_int.h"
7#include <stdio.h>
8#include <stdlib.h>
9
27getdim(unsigned char *csec3, g2int *width, g2int *height, g2int *iscan)
28{
29 g2int *igdstmpl = NULL, *list_opt = NULL;
30 g2int *igds = NULL;
31 g2int iofst, igdtlen, num_opt, jerr;
32
33 iofst = 0; /* set offset to beginning of section */
34 if (!(jerr = g2_unpack3(csec3, &iofst, &igds, &igdstmpl, &igdtlen,
35 &list_opt, &num_opt)))
36 {
37 switch (igds[4]) /* Template number */
38 {
39 case 0: /* Lat/Lon */
40 case 1:
41 case 2:
42 case 3: {
43 *width = igdstmpl[7];
44 *height = igdstmpl[8];
45 *iscan = igdstmpl[18];
46 break;
47 }
48 case 10: /* Mercator */
49 {
50 *width = igdstmpl[7];
51 *height = igdstmpl[8];
52 *iscan = igdstmpl[15];
53 break;
54 }
55 case 20: /* Polar Stereographic */
56 {
57 *width = igdstmpl[7];
58 *height = igdstmpl[8];
59 *iscan = igdstmpl[17];
60 break;
61 }
62 case 30: /* Lambert Conformal */
63 {
64 *width = igdstmpl[7];
65 *height = igdstmpl[8];
66 *iscan = igdstmpl[17];
67 break;
68 }
69 case 40: /* Gaussian */
70 case 41:
71 case 42:
72 case 43: {
73 *width = igdstmpl[7];
74 *height = igdstmpl[8];
75 *iscan = igdstmpl[18];
76 break;
77 }
78 case 90: /* Space View/Orthographic */
79 {
80 *width = igdstmpl[7];
81 *height = igdstmpl[8];
82 *iscan = igdstmpl[16];
83 break;
84 }
85 case 110: /* Equatorial Azimuthal */
86 {
87 *width = igdstmpl[7];
88 *height = igdstmpl[8];
89 *iscan = igdstmpl[15];
90 break;
91 }
92 default: {
93 *width = 0;
94 *height = 0;
95 *iscan = 0;
96 break;
97 }
98 } /* end switch */
99 }
100 else
101 {
102 *width = 0;
103 *height = 0;
104 }
105
106 if (igds)
107 free(igds);
108 if (igdstmpl)
109 free(igdstmpl);
110 if (list_opt)
111 free(list_opt);
112
113 return 0;
114}
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
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
int64_t g2int
Long integer type.
Definition grib2.h:32
Header file with internal function prototypes NCEPLIBS-g2c library.