Mapper
plot_fstations_new.c
Go to the documentation of this file.
1 
2 #include "prototypes_new.h"
3 
4 
5 void plot_fstations(Drawable pix,int h,int type,int k,int display_flag)
6 
7 {
8 
9 extern int isom;
10 extern int flf_on;
11 extern int qpf_on;
12 extern int maxmin_on;
13 extern int fstation_focus;
14 extern int wfo_all;
15 struct tag tag[20];
16 extern int wfo_in_use[20];
17 extern int ifcst;
18 extern struct fstation fstation[1000];
19 extern int max_fstations;
20 extern struct fdata fdata[60];
21 extern struct dval dval;
22 extern int npoint[2],zoom;
23 extern GC gc;
24 extern unsigned long qmap[16];
25 extern Widget drawing_area;
26 extern Display *display;
27 extern Font font[10];
28 extern XFontStruct *info_font[10];
29 extern struct station station[3000];
30 extern struct station zstation[750];
31 extern struct station tstation[1000];
32 extern int max_stations;
33 extern int dflag[10];
34 extern int qflag[10];
35 extern long amap[16];
36 int i,xc,yc,text_width,length,m;
37 int x1,y1,xadd,yadd,MY=10;
38 float xrat,yrat,mult,dmult,cmult;
39 long xmin,xmax,ymin,ymax;
40 signed long xcen,ycen,lint1,lint2;
41 Dimension width,height;
42 Arg args[10];
43 signed long XSIZE,YSIZE;
44 extern struct display_set display_set[4];
45 long r,s;
46 float conv=.0174;
47 float lat,lon;
48 char tbuf[100],mbuf[100],tbuf2[100];
49 int yheight;
50 struct tm *gm;
51 int time_pos;
52 time_t ltime;
53 extern int funct[];
54 int mm,ii;
55 
56 XSetFont(display,gc,font[4]);
57 
58 yheight=info_font[4]->ascent;
59 
60 XtSetArg(args[0],XtNwidth,&width);
61 XtSetArg(args[1],XtNheight,&height);
62 XtGetValues(drawing_area,args,2);
63 
64 XSIZE=(long)width*10L;
65 YSIZE=(long)height*10L;
66 
67 xrat=(float)XSIZE/(float)12800;
68 yrat=(float)YSIZE/(float)9600;
69 
70 if(xrat < yrat)
71  mult=xrat;
72 
73 else
74  mult=yrat;
75 
83 
84 lint1=(long)npoint[0]*(long)MY;
85 lint2=(long)npoint[1]*(long)MY;
86 
88 
89 for(ii=0;ii<max_fstations;ii++) {
90 
91  if(wfo_all!=1) {
92 
93  for(h=0;h<20;h++) {
94 
95  if(wfo_in_use[h] == -1)
96  break;
97 
98  if(fstation[ii].owner==wfo_in_use[h])
99  break;
100 
101  }
102 
103  if(wfo_in_use[h]==-1)
104  continue;
105 
106  }
107 
108  if(qpf_on==1 && fstation[ii].qpf==-1)
109  continue;
110 
111 
112  if(flf_on==1 && fstation[ii].frz==-1)
113  continue;
114 
115  if(maxmin_on==1 && fstation[ii].txn==-1)
116  continue;
117 
118  if(qpf_on==1) {
119 
120  i=fstation[ii].pindex;
121 
122  lat=station[i].lat;
123  lon=station[i].lon;
124 
125  }
126 
127  else if(flf_on==1) {
128 
129  i=fstation[ii].zindex;
130 
131  lat=zstation[i].lat;
132  lon=zstation[i].lon;
133 
134  }
135 
136  else if(maxmin_on==1) {
137 
138  i=fstation[ii].tindex;
139 
140  lat=tstation[i].lat;
141  lon=tstation[i].lon;
142 
143  }
144 
145  r=dval.a * cos(lat*conv)/(1+sin(lat*conv))
146  * cos((lon-dval.lo-90)*conv) + dval.xo +.5;
147 
148  s=dval.a * cos(lat*conv)/(1+sin(lat*conv))
149  * sin((lon-dval.lo-90)*conv) + dval.yo + .5;
150 
151  if(zoom==1) {
152 
153  x1=(xmin+(float)r * cmult)/MY;
154  y1=(ymin+(float)s * cmult)/MY;
155 
156  }
157 
158  else {
159 
160  x1=(((xmin+(float)r*cmult)-lint1)*zoom+xcen)/MY;
161  y1=(((ymin+(float)s*cmult)-lint2)*zoom+ycen)/MY;
162 
163  }
164 
165 
166  XDrawLine(display,pix,gc,x1+1,y1+1,x1+1,y1-1);
167  XDrawLine(display,pix,gc,x1+1,y1-1,x1-1,y1-1);
168  XDrawLine(display,pix,gc,x1-1,y1-1,x1-1,y1+1);
169  XDrawLine(display,pix,gc,x1-1,y1+1,x1+1,y1+1);
170 
171  if(fstation[ii].selected==1) {
172 
173  XSetForeground(display,gc,qmap[4]);
174 
175  XDrawLine(display,pix,gc,x1+5,y1+5,x1+5,y1-5);
176  XDrawLine(display,pix,gc,x1+5,y1-5,x1-5,y1-5);
177  XDrawLine(display,pix,gc,x1-5,y1-5,x1-5,y1+5);
178  XDrawLine(display,pix,gc,x1-5,y1+5,x1+5,y1+5);
179 
180 
181  }
182 
183 
184  XSetForeground(display,gc,qmap[15]);
185  if(type==1){
186 
187  if(qpf_on==1)
188  strcpy(tbuf,station[i].hb5);
189 
190  else if(flf_on==1)
191  strcpy(tbuf,zstation[i].hb5);
192 
193  else if(maxmin_on==1)
194  strcpy(tbuf,tstation[i].hb5);
195 
196  }
197 
198  else if(type==2) {
199 
200  if(qpf_on==1)
201  strcpy(tbuf,&station[i].parm[3]);
202 
203  else if(flf_on==1)
204  strcpy(tbuf,&station[i].parm[3]);
205 
206  else if(maxmin_on==1)
207  strcpy(tbuf,&tstation[i].parm[3]);
208 
209  tbuf[2]=0;
210 
211  }
212 
213  else if(type==3){
214 
215  if(qpf_on==1)
216  strcpy(tbuf,station[i].name);
217 
218  else if(flf_on==1)
219  strcpy(tbuf,station[i].name);
220 
221  else if(maxmin_on==1)
222  strcpy(tbuf,tstation[i].name);
223 
224  }
225 
226  else if(type>=4 && qpf_on==1) {
227 
228  if(fdata[k].fstn[i].rain[ifcst] < -999)
229  strcpy(mbuf," M");
230 
231  else
232  sprintf(mbuf,"%5.2f",fdata[k].fstn[i].rain[ifcst]);
233 
234  if(mbuf[0]=='0')
235  strcpy(tbuf,&mbuf[1]);
236 
237  else
238  strcpy(tbuf,mbuf);
239 
240  }
241 
242  else if(type>=4 && flf_on==1) {
243 
244  if(fdata[k].fstn[i].frz[ifcst] < 0)
245  strcpy(mbuf," M");
246 
247  else
248  sprintf(mbuf,"%5.2f",fdata[k].fstn[i].frz[ifcst]);
249 
250  if(mbuf[0]=='0')
251  strcpy(tbuf,&mbuf[1]);
252 
253  else
254  strcpy(tbuf,mbuf);
255 
256  }
257 
258  else if(type>=4 && maxmin_on==1) {
259 
260 
261  printf("%d %d %f\n",isom,
262  fdata[k].fstn[i].tx[ifcst],tstation[i].max[isom]);
263 
264  if(fdata[k].fstn[i].tx[ifcst] < 0)
265  strcpy(tbuf," M");
266 
267  else
268  sprintf(tbuf,"%3d %3d",fdata[k].fstn[i].tx[ifcst],
269  fdata[k].fstn[i].tx[ifcst]-(int)tstation[i].max[isom]);
270 
271  if(fdata[k].fstn[i].tn[ifcst] < 0)
272  strcpy(tbuf2," M");
273 
274  else
275  sprintf(tbuf2,"%3d",fdata[k].fstn[i].tn[ifcst]);
276 
277  }
278 
279  length=strlen(tbuf);
280  text_width=XTextWidth(info_font[4],tbuf,length);
281 
282  if(qpf_on==1) {
283 
284  xadd=station[i].xadd;
285  yadd=station[i].yadd;
286 
287  }
288 
289  else if(flf_on==1) {
290 
291  xadd=zstation[i].xadd;
292  yadd=zstation[i].yadd;
293 
294  }
295 
296  else if(maxmin_on==1) {
297 
298  xadd=zstation[i].xadd;
299  yadd=zstation[i].yadd;
300 
301  }
302 
303  if(xadd < 0)
304  xc=x1 - text_width;
305 
306  else
307  xc=x1+3;
308 
309  if(yadd < 0)
310  yc=y1;
311 
312  else
313  yc=y1+yheight;
314 
315 
316  if(maxmin_on==1) {
317 
318  length=strlen(tbuf);
319  XDrawString(display,pix,gc,x1+3,yc-20,tbuf,length);
320 
321  length=strlen(tbuf2);
322 
323  XDrawString(display,pix,gc,x1+3,yc,tbuf2,length);
324  XDrawLine(display,pix,gc,x1+10,yc-15,x1+17,yc-15);
325 
326  }
327 
328  else
329  XDrawString(display,pix,gc,xc,yc,tbuf,length);
330 
331 
332  if(type==5) {
333 
334  if(qpf_on==1) {
335 
336 
337  strcpy(tbuf,station[i].hb5);
338  sprintf(mbuf,"(%5.2f)",station[i].isoh[isom]);
339  strcat(tbuf,mbuf);
340 
341  }
342 
343 
344  else if(flf_on==1)
345  strcpy(tbuf,zstation[i].hb5);
346 
347  else if(maxmin_on==1)
348  strcpy(tbuf,tstation[i].hb5);
349 
350 
351 
352  length=strlen(tbuf);
353  text_width=XTextWidth(info_font[4],tbuf,length);
354 
355  XDrawString(display,pix,gc,xc,yc+10,tbuf,length);
356 
357  }
358 
359 }
360 
361 }
362 
char name[35][30]
Definition: borshef.c:10
static int i
XFontStruct * info_font[10]
Definition: mapper.c:195
Display * display
Definition: mapper.c:159
Font font[10]
Definition: mapper.c:161
float mult
Definition: edit_stations.c:6
sprintf(fbuf,"/usr/mapper/nexrad/ngrid.%02d-%02d-%02d-%02d", year, month, day, hour)
printf("fbuf is %s\n", fbuf)
double lat
Definition: mapp2h.h:41
double lon
Definition: mapp2h.h:41
int k
Definition: mapp2h.h:48
int max_stations
Definition: mapper.c:64
int dflag[10]
Definition: mapper.c:106
unsigned long qmap[16]
Definition: mapper.c:116
unsigned long amap[16]
Definition: mapper.c:117
int display_flag
Definition: mapper.c:100
void plot_fstations(Drawable pix, int h, int type, int k, int display_flag)
float xrat
long xmax
float yrat
long ymax
long lint1
GC gc
Definition: mapper.c:163
float cmult
signed long xcen
Dimension height
signed long ycen
Dimension width
int yheight
long lint2
Arg args[10]
long xmin
unsigned long XSIZE
int MY
int zoom
float dmult
Widget drawing_area
Definition: mapper.c:185
int npoint[2]
Definition: mapper.c:105
long ymin
unsigned long YSIZE
int max
Definition: rateint.c:95
float dmult[4]
Definition: misc.h:613
long xmin[4]
Definition: misc.h:607
long xmax[4]
Definition: misc.h:609
long ymax[4]
Definition: misc.h:610
long ymin[4]
Definition: misc.h:608
long ycen[4]
Definition: misc.h:612
long xcen[4]
Definition: misc.h:611
Definition: misc.h:470
double lo
Definition: misc.h:475
double a
Definition: misc.h:472
double yo
Definition: misc.h:474
double xo
Definition: misc.h:473
Definition: misc.h:23
Definition: misc.h:30
int tindex
Definition: misc_new.h:95
int zindex
Definition: misc_new.h:96
int pindex
Definition: misc_new.h:94
Definition: misc.h:16
Definition: misc.h:538
Definition: misc.h:255
Definition: misc.h:296
float lat
Definition: misc.h:303
float lon
Definition: misc.h:304
int yadd
Definition: misc.h:310
int xadd
Definition: misc.h:309
Definition: misc_new.h:61