Mapper
plot_fstations.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 flf_on;
10 extern int qpf_on;
11 extern int fstation_focus;
12 extern int wfo_all;
13 struct tag tag[20];
14 extern int wfo_in_use[20];
15 extern int ifcst;
16 extern struct fstation fstation[500];
17 extern int max_fstations;
18 extern struct fdata fdata[60];
19 extern struct dval dval;
20 extern int npoint[2],zoom;
21 extern GC gc;
22 extern unsigned long qmap[16];
23 extern Widget drawing_area;
24 extern Display *display;
25 extern Font font[10];
26 extern XFontStruct *info_font[10];
27 extern struct station station[3000];
28 extern int max_stations;
29 extern int dflag[10];
30 extern int qflag[10];
31 extern long amap[16];
32 int i,xc,yc,text_width,length,m;
33 int x1,y1,xadd,yadd,MY=10;
34 float xrat,yrat,mult,dmult,cmult;
35 long xmin,xmax,ymin,ymax;
36 signed long xcen,ycen,lint1,lint2;
37 Dimension width,height;
38 Arg args[10];
39 signed long XSIZE,YSIZE;
40 extern struct display_set display_set[4];
41 long r,s;
42 float conv=.0174;
43 float lat,lon;
44 char tbuf[100],mbuf[100];
45 int yheight;
46 struct tm *gm;
47 int time_pos;
48 time_t ltime;
49 extern int funct[];
50 int mm,ii;
51 
52 XSetFont(display,gc,font[4]);
53 
54 yheight=info_font[4]->ascent;
55 
56 XtSetArg(args[0],XtNwidth,&width);
57 XtSetArg(args[1],XtNheight,&height);
58 XtGetValues(drawing_area,args,2);
59 
60 XSIZE=(long)width*10L;
61 YSIZE=(long)height*10L;
62 
63 xrat=(float)XSIZE/(float)12800;
64 yrat=(float)YSIZE/(float)9600;
65 
66 if(xrat < yrat)
67  mult=xrat;
68 
69 else
70  mult=yrat;
71 
79 
80 lint1=(long)npoint[0]*(long)MY;
81 lint2=(long)npoint[1]*(long)MY;
82 
84 
85 for(ii=0;ii<max_fstations;ii++) {
86 
87  if(wfo_all!=1) {
88 
89  for(h=0;h<20;h++) {
90 
91  if(wfo_in_use[h] == -1)
92  break;
93 
94  if(fstation[ii].owner==wfo_in_use[h])
95  break;
96 
97  }
98 
99  if(wfo_in_use[h]==-1)
100  continue;
101 
102  }
103 
104  if(qpf_on==1 && fstation[ii].qpf==-1)
105  continue;
106 
107 
108  if(flf_on==1 && fstation[ii].frz==-1)
109  continue;
110 
111  i=fstation[ii].index;
112 
113  lat=station[i].lat;
114  lon=station[i].lon;
115 
116  r=dval.a * cos(lat*conv)/(1+sin(lat*conv))
117  * cos((lon-dval.lo-90)*conv) + dval.xo +.5;
118 
119  s=dval.a * cos(lat*conv)/(1+sin(lat*conv))
120  * sin((lon-dval.lo-90)*conv) + dval.yo + .5;
121 
122  if(zoom==1) {
123 
124  x1=(xmin+(float)r * cmult)/MY;
125  y1=(ymin+(float)s * cmult)/MY;
126 
127  }
128 
129  else {
130 
131  x1=(((xmin+(float)r*cmult)-lint1)*zoom+xcen)/MY;
132  y1=(((ymin+(float)s*cmult)-lint2)*zoom+ycen)/MY;
133 
134  }
135 
136 
137  if(i==fstation_focus)
138  XSetForeground(display,gc,qmap[10]);
139 
140  else
141  XSetForeground(display,gc,qmap[15]);
142 
143  XDrawLine(display,pix,gc,x1+1,y1+1,x1+1,y1-1);
144  XDrawLine(display,pix,gc,x1+1,y1-1,x1-1,y1-1);
145  XDrawLine(display,pix,gc,x1-1,y1-1,x1-1,y1+1);
146  XDrawLine(display,pix,gc,x1-1,y1+1,x1+1,y1-1);
147 
148  if(type==1)
149  strcpy(tbuf,station[i].hb5);
150 
151  else if(type==2) {
152 
153  strcpy(tbuf,&station[i].parm[3]);
154  tbuf[2]=0;
155 
156  }
157 
158  else if(type==3)
159  strcpy(tbuf,station[i].name);
160 
161  else if(type==4 && qpf_on==1) {
162 
163  if(fdata[k].fstn[i].rain[ifcst] < -999)
164  strcpy(mbuf," M");
165 
166  else
167  sprintf(mbuf,"%5.2f",fdata[k].fstn[i].rain[ifcst]);
168 
169  if(mbuf[0]=='0')
170  strcpy(tbuf,&mbuf[1]);
171 
172  else
173  strcpy(tbuf,mbuf);
174 
175  }
176 
177  else if(type==4 && flf_on==1) {
178 
179  if(fdata[k].fstn[i].frz[ifcst] < 0)
180  strcpy(mbuf," M");
181 
182  else
183  sprintf(mbuf,"%5.2f",fdata[k].fstn[i].frz[ifcst]);
184 
185  if(mbuf[0]=='0')
186  strcpy(tbuf,&mbuf[1]);
187 
188  else
189  strcpy(tbuf,mbuf);
190 
191  }
192  length=strlen(tbuf);
193  text_width=XTextWidth(info_font[4],tbuf,length);
194 
195  xadd=station[i].xadd;
196  yadd=station[i].yadd;
197 
198  if(xadd < 0)
199  xc=x1 - text_width;
200 
201  else
202  xc=x1+3;
203 
204  if(yadd < 0)
205  yc=y1;
206 
207  else
208  yc=y1+yheight;
209 
210  XDrawString(display,pix,gc,xc,yc,tbuf,length);
211 
212 }
213 
214 }
215 
216 
217 
218 
219 
220 
221 
222 
223 
224 
225 
226 
227 
228 
229 
230 
231 
232 
233 
234 
235 
236 
237 
238 
239 
240 
241 
242 
243 
244 
245 
246 
247 
248 
249 
250 
251 
252 
253 
254 
255 
256 
257 
258 
259 
260 
261 
262 
263 
264 
265 
266 
267 
268 
269 
270 
271 
272 
273 
274 
275 
276 
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)
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)
Definition: plot_fstations.c:5
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
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 index
Definition: misc.h:33
Definition: misc.h:16
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