Mapper
grid_data.c
Go to the documentation of this file.
1 #include "prototypes.h"
2 
3 void grid_data(int type)
4 
5 {
6 extern struct dval dval;
7 extern struct grid *grid;
8 extern struct saved *fsaved;
9 extern Widget top_level;
10 extern Cursor watch_cursor;
11 extern int method;
12 int i,j,htotal;
13 double distance,dist1,dist2,dist,value;
14 double temp;
15 extern struct hrap_grid *hrap_grid;
16 extern Window window;
17 extern Display *display;
18 struct saved *saved;
19 int dir,speed,gust;
20 float fvalue;
21 
22 XDefineCursor(display,window,watch_cursor);
23 XmUpdateDisplay(top_level);
24 
25 for(i=0;i<hrap_grid->maxi;i++) {
26 
27 for(j=0;j<hrap_grid->maxj;j++) {
28 
29  value=0.0;
30  distance=0.0;
31 
32  htotal=0;
33  saved=fsaved;
34 
35  while( saved!=NULL) {
36 
37  if(saved->data < -98)
38  goto nextseg;
39 
40  if(saved->lat < 0 || saved->lon < 0)
41  goto nextseg;
42 
43  dist1=(double)(hrap_grid->coord[i][j].x-saved->r);
44  dist2=(double)(hrap_grid->coord[i][j].y-saved->s);
45 
46  dist=pow(dist1,2)+pow(dist2,2);
47 
48  if(dist < 1.0)
49  dist=1.0;
50 
51  dist=1/dist;
52 
53  if(type==11) {
54 
55  dir=saved->data/1000000;
56  speed=(saved->data - dir*1000000)/1000;
57  gust=(saved->data - dir*1000000 - speed*1000);
58 
59  if(gust != 0)
60  fvalue=gust;
61 
62  else
63  fvalue=speed;
64 
65  }
66 
67  else
68  fvalue=saved->data;
69 
70 
71  temp=fvalue*dist;
72 /*
73  if(method==2 && station[h].isoh > 0)
74  temp=temp*(float)hrap_grid->isoh[i][j]/station[h].isoh;
75 */
77 
78  distance=distance+dist;
79  htotal++;
80 
81  nextseg:
82 
83  saved=saved->next;
84 
85  if(saved==NULL)
86  break;
87 
88  }
89 
90  if(htotal == 0)
91  grid->value[i][j]=0;
92 
93  else
94  grid->value[i][j]=value/distance;
95 
96  }
97 
98 
99 }
100 
101 }
static int i
Display * display
Definition: mapper.c:159
Widget top_level
Definition: display_rec.c:5
void grid_data(int type)
Definition: grid_data.c:3
int j
Definition: mapp2h.h:48
char temp[9]
Definition: mapp2h.h:66
struct saved * fsaved
Definition: mapper.c:128
struct grid * grid
Definition: mapper.c:127
Window window
Definition: mapper.c:190
Cursor watch_cursor
Definition: mapper.c:153
float value
struct hrap_grid * hrap_grid
Definition: mapper.c:142
short int y
Definition: misc.h:498
short int x
Definition: misc.h:497
Definition: misc.h:470
Definition: misc.h:538
float ** value
Definition: misc.h:540
short int maxi
Definition: misc.h:580
short int maxj
Definition: misc.h:581
struct coord ** coord
Definition: misc.h:584
Definition: misc.h:361
double data
Definition: misc.h:378
float lat
Definition: misc.h:376
int r
Definition: misc.h:369
int s
Definition: misc.h:370
struct saved * next
Definition: misc.h:379
float lon
Definition: misc.h:377