Mapper
draw_wind.c
Go to the documentation of this file.
1 
2 #include "prototypes.h"
3 
4 void draw_wind(Pixmap pix,int r,int s,double data)
5 
6 {
7 
8 extern GC gc;
9 extern Display *display;
10 extern unsigned long qmap[16];
11 int i,x[3],y[3],dir,speed,gust,x0,y0;
12 int nul,mul,staff,barb;
13 double angle,rad;
14 char kbuf[10];
15 
16 dir=data/1000000;
17 speed=(data - dir*1000000)/1000;
18 gust=(data - dir*1000000 - speed*1000);
19 
20 x[0]=r;
21 y[0]=s;
22 rad=.0174533;
23 
24 XSetForeground(display,gc,qmap[15]);
25 
26 if(speed==0) {
27 
28  x0=x[0];
29  y0=y[0]-1;
30  XDrawLine(display,pix,gc,x0+2,y0+2,x0+2,y0-2);
31  XDrawLine(display,pix,gc,x0+2,y0+2,x0-2,y0+2);
32  XDrawLine(display,pix,gc,x0-2,y0-2,x0+2,y0-2);
33  XDrawLine(display,pix,gc,x0-2,y0-2,x0-2,y0+2);
34 
35  }
36 
37 speed=speed+2;
38 staff=25;
39 staff=staff + (speed/50) * 10;
40 barb=10;
41 
42 angle=(double)(90-(dir));
43 
44 x[1]= (double)staff*cos(angle*rad) +x[0];
45 y[1]=-(double)staff*sin(angle*rad) +y[0];
46 
47 XDrawLine(display,pix,gc,x[0],y[0],x[1],y[1]);
48 
49 if(gust > 0 ) {
50 
51  sprintf(kbuf,"%d",gust);
52 
53  XDrawString(display,pix,gc,x[0]+4,y[0]+4,kbuf,strlen(kbuf));
54 
55  }
56 
57 mul=speed/50;
58 
59 for(i=0;i<mul;i++) {
60 
61  x[2]= (double)barb*cos((angle-90)*rad) +x[1];
62  y[2]=-(double)barb*sin((angle-90)*rad) +y[1];
63  XDrawLine(display,pix,gc,x[1],y[1],x[2],y[2]);
64 
65  staff=staff-10;
66 
67  x[1]= (double)staff*cos(angle*rad) + x[0];
68  y[1]=-(double)staff*sin(angle*rad) + y[0];
69  XDrawLine(display,pix,gc,x[1],y[1],x[2],y[2]);
70 
71  }
72 
73 nul=speed-mul*50;
74 
75 nul=nul/10;
76 
77 for(i=0;i<nul;i++) {
78 
79  x[1]= (double)staff*cos(angle*rad) + x[0];
80  y[1]=-(double)staff*sin(angle*rad) + y[0];
81 
82  x[2]= (double)barb*cos((angle-90)*rad) +x[1];
83  y[2]=-(double)barb*sin((angle-90)*rad) +y[1];
84 
85  XDrawLine(display,pix,gc,x[1],y[1],x[2],y[2]);
86 
87  staff=staff-5;
88 
89  }
90 
91 mul=speed- mul*50 - nul*10;
92 
93 if(mul >= 5) {
94 
95  if(speed < 10)
96  staff=staff-5;
97 
98  x[1]= (double)staff*cos(angle*rad) + x[0];
99  y[1]=-(double)staff*sin(angle*rad) + y[0];
100 
101  x[2]= (double)barb/2*cos((angle-90)*rad) +x[1];
102  y[2]=-(double)barb/2*sin((angle-90)*rad) +y[1];
103  XDrawLine(display,pix,gc,x[1],y[1],x[2],y[2]);
104 
105  }
106 
107 }
108 
static int i
Display * display
Definition: mapper.c:159
void draw_wind(Pixmap pix, int r, int s, double data)
Definition: draw_wind.c:4
sprintf(fbuf,"/usr/mapper/nexrad/ngrid.%02d-%02d-%02d-%02d", year, month, day, hour)
unsigned long qmap[16]
Definition: mapper.c:116
GC gc
Definition: mapper.c:163