NCEPLIBS-g2c 1.9.0
Loading...
Searching...
No Matches
getdim.c
Go to the documentation of this file.
1
6#include <stdio.h>
7#include <stdlib.h>
8#include "grib2_int.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 {
44 *width = igdstmpl[7];
45 *height = igdstmpl[8];
46 *iscan = igdstmpl[18];
47 break;
48 }
49 case 10: /* Mercator */
50 {
51 *width = igdstmpl[7];
52 *height = igdstmpl[8];
53 *iscan = igdstmpl[15];
54 break;
55 }
56 case 20: /* Polar Stereographic */
57 {
58 *width = igdstmpl[7];
59 *height = igdstmpl[8];
60 *iscan = igdstmpl[17];
61 break;
62 }
63 case 30: /* Lambert Conformal */
64 {
65 *width = igdstmpl[7];
66 *height = igdstmpl[8];
67 *iscan = igdstmpl[17];
68 break;
69 }
70 case 40: /* Gaussian */
71 case 41:
72 case 42:
73 case 43:
74 {
75 *width = igdstmpl[7];
76 *height = igdstmpl[8];
77 *iscan = igdstmpl[18];
78 break;
79 }
80 case 90: /* Space View/Orthographic */
81 {
82 *width = igdstmpl[7];
83 *height = igdstmpl[8];
84 *iscan = igdstmpl[16];
85 break;
86 }
87 case 110: /* Equatorial Azimuthal */
88 {
89 *width = igdstmpl[7];
90 *height = igdstmpl[8];
91 *iscan = igdstmpl[15];
92 break;
93 }
94 default:
95 {
96 *width = 0;
97 *height = 0;
98 *iscan = 0;
99 break;
100 }
101 } /* end switch */
102 }
103 else
104 {
105 *width = 0;
106 *height = 0;
107 }
108
109 if (igds)
110 free(igds);
111 if (igdstmpl)
112 free(igdstmpl);
113 if (list_opt)
114 free(list_opt);
115
116 return 0;
117}
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.