Mapper
make_fmap_file.c
Go to the documentation of this file.
1 #define _POSIX_SOURCE
2 #include "prototypes_new.h"
3 
5 
6 {
7 
8 extern char rfc[10];
9 extern int mode;
10 extern char shef_source[50];
11 extern int wfo_orig;
12 extern time_t tim;
13 extern char fmap_file[100];
14 extern struct map map[1500];
15 FILE *fo;
16 int ib,j;
17 char fbuf[100];
18 char *spaces,xbuf[300],mbuf[100];
19 int len,k;
20 struct tm *gmtim;
21 float temp;
22 int itim;
23 int numzones;
24 int i;
25 char pchar[2];
26 time_t stim;
27 int kk;
28 time_t ctim;
29 int year,month,day,hour,min;
30 
31 ctim=time(NULL);
32 
33 gmtim=gmtime(&ctim);
34 
35 month=gmtim->tm_mon+1;
36 day=gmtim->tm_mday;
37 hour=gmtim->tm_hour;
38 year=gmtim->tm_year+1900;
39 min=0;
40 
41 pchar[1]=0;
42 
43 spaces=" ";
44 
45 gmtim=gmttime(&tim);
46 
47 sprintf(fbuf,"%s%02d-%02d-%02d",fmap_file,gmtim->tm_mon+1,gmtim->tm_mday,
48  gmtim->tm_year);
49 
50 fo=fopen(fbuf,"w");
51 
52 if(fo==NULL) {
53 
54  printf("could not open %s\n",fbuf);
55 
56  exit(1);
57 
58  }
59 
60 chmod(fbuf,S_IRUSR | S_IWUSR |
61  S_IRGRP | S_IWGRP |
62  S_IROTH | S_IWOTH);
63 
64 stim=tim-86400;
65 gmtim=gmtime(&stim);
66 
67 for(ib=0;map[ib].hb5[0]!=0;ib++){
68 
69  if(mode==0) {
70 
71  if(wfo_orig != map[ib].owner)
72  continue;
73 
74  }
75 
76  numzones=0;
77  for(j=0;j < 4;j++) {
78 
79  if(map[ib].zones[j] < 0)
80  continue;
81 
82  numzones++;
83 
84  }
85 
86 
87  for(j=0;j < 4;j++) {
88 
89  if(map[ib].zones[j] < 0)
90  continue;
91 
92  strcpy(xbuf,".ER ");
93  strcat(xbuf,map[ib].hb5);
94 
95  i=0;
96  while(xbuf[i] != 0)
97  xbuf[i++]=toupper(xbuf[i]);
98 
99  if(strcmp(rfc,"cbrfc")==0 &&
100  strlen(map[ib].hb5)==7) {
101 
102  printf("polygon write\n");
103 
104  pchar[0]=map[ib].bchar[0];
105  strcat(xbuf,pchar);
106 
107  }
108 
109  else {
110 
111 
112  if(j==0 && numzones != 1) {
113 
114  strcat(xbuf,"L");
115  pchar[0]=map[ib].bchar[0];
116  strcat(xbuf,pchar);
117 
118  }
119 
120 
121  else if(j==0 && numzones == 1) {
122 
123  strcat(xbuf,"O");
124  pchar[0]=map[ib].bchar[0];
125  strcat(xbuf,pchar);
126 
127  }
128 
129 
130  else if(j==1) {
131 
132  strcat(xbuf,"M");
133  pchar[0]=map[ib].bchar[1];
134  strcat(xbuf,pchar);
135 
136  }
137 
138  else if(j==2) {
139 
140  strcat(xbuf,"U");
141  pchar[0]=map[ib].bchar[2];
142  strcat(xbuf,pchar);
143 
144  }
145 
146  else if(j==3) {
147 
148  strcat(xbuf,"G");
149  pchar[0]=map[ib].bchar[3];
150  strcat(xbuf,pchar);
151 
152  }
153 
154  }
155 
156  sprintf(mbuf," %04d%02d%02d",gmtim->tm_year+1900,
157  gmtim->tm_mon+1,gmtim->tm_mday);
158  strcat(xbuf,mbuf);
159 
160  sprintf(mbuf," DH18/DC%04d%02d%02d%02d%02d/PPQF%cZZ/DIH+6",
161  year,month,day,hour,min,shef_source[0]);
162  strcat(xbuf,mbuf);
163 
164  for(k=0;k<12;k++) {
165 
166  if(k==4) {
167 
168  strcat(xbuf,"\n");
169  strcat(xbuf,".E1 ");
170 
171  }
172 
173  if(map[ib].maps_done[k]==1) {
174 
175  if(j==0)
176  temp=map[ib].lz[k];
177 
178  if(j==1)
179  temp=map[ib].mz[k];
180 
181  if(j==2)
182  temp=map[ib].uz[k];
183 
184  if(j==3)
185  temp=map[ib].gz[k];
186 
187  }
188 
189  else
190  temp=0.0;
191 
192  if(k != 4)
193  strcat(xbuf,"/");
194 
195  sprintf(mbuf,"%5.2f",temp);
196 
197  strcat(xbuf,mbuf);
198 
199  }
200 
201  strcat(xbuf,"\n");
202  fputs(xbuf,fo);
203 
204  }
205 
206  }
207 
208 
209 fclose(fo);
210 
211 return;
212 
213 }
214 
215 
216 
static int i
struct tm * gmttime(time_t *secs)
Definition: gmttime.c:5
char fbuf[100]
Definition: decode_HDP.c:2
int hour
Definition: display_data.c:26
int day
Definition: display_data.c:26
int year
Definition: display_data.c:26
int month
Definition: display_data.c:26
fclose(fp)
sprintf(fbuf,"/usr/mapper/nexrad/ngrid.%02d-%02d-%02d-%02d", year, month, day, hour)
printf("fbuf is %s\n", fbuf)
void make_fmap_file()
Definition: make_fmap_file.c:4
int j
Definition: mapp2h.h:48
char temp[9]
Definition: mapp2h.h:66
int k
Definition: mapp2h.h:48
ib
Definition: shleap.cc:46
Definition: misc.h:236
char bchar[5]
Definition: misc.h:242
char hb5[10]
Definition: misc.h:238
float lz[200]
Definition: misc.h:250
float uz[200]
Definition: misc.h:248
float gz[200]
Definition: misc.h:247
float mz[200]
Definition: misc.h:249
Definition: misc.h:93
tim()
Definition: tim.c:4