Mapper
make_map.c
Go to the documentation of this file.
1 #include "prototypes.h"
2 
3 void make_map(int num)
4 
5 {
6 
7 extern int pcp_in_use[200];
8 extern struct map map[1500];
9 extern struct pcp *pcp;
10 extern struct hrap_grid *hrap_grid;
11 
12 char fbuf[100];
13 int x,y,ix,iy,l;
14 int minx,miny,totx,toty,uzpts,lzpts,mzpts,gzpts;
15 float lz,uz,mz,gz;
16 int ib;
17 
18 if(pcp_in_use[num]==-1)
19  return;
20 
21 strcpy(fbuf,"pcp");
22 
23 read_file(fbuf,num,pcp);
24 
25 minx=hrap_grid->hrap_minx;
26 miny=hrap_grid->hrap_miny;
27 totx=hrap_grid->maxi;
28 toty=hrap_grid->maxj;
29 
30 for(ib=0;map[ib].hb5[0]!=0;ib++) {
31 
32  mz=0;uz=0;lz=0;gz=0;uzpts=0;lzpts=0;mzpts=0;gzpts=0;
33 
34  for(l=0;l<map[ib].hrap_points;l++) {
35 
36  x=map[ib].hrap_data[l].x;
37  y=map[ib].hrap_data[l].y;
38 
39  ix=x-minx;
40  iy=y-miny;
41 
42  if(ix < 0 || iy < 0 || ix > totx || iy > toty) {
43 
44  continue;
45 
46  }
47 
48  if(map[ib].hrap_data[l].zone[3]==1) {
49 
50  gz=gz+(float)pcp->value[ix][iy]/100;
51  gzpts++;
52 
53  }
54 
55  if(map[ib].hrap_data[l].zone[2]==1) {
56 
57  uz=uz+(float)pcp->value[ix][iy]/100;
58  uzpts++;
59 
60  }
61 
62  if(map[ib].hrap_data[l].zone[1]==1) {
63 
64  mz=mz+(float)pcp->value[ix][iy]/100;
65  mzpts++;
66 
67  }
68 
69  if(map[ib].hrap_data[l].zone[0]==1){
70 
71  lz=lz+(float)pcp->value[ix][iy]/100;
72  lzpts++;
73 
74  }
75 
76 
77 
78  }
79 
80  if(gzpts ==0)
81  gz=-1;
82  else
83  gz=gz/(float)uzpts;
84 
85  if(uzpts ==0)
86  uz=-1;
87  else
88  uz=uz/(float)uzpts;
89 
90  if(mzpts==0)
91  mz=-1;
92  else
93  mz=mz/(float)mzpts;
94 
95  if(lzpts==0)
96  lz=-1;
97 
98  else
99  lz=lz/(float)lzpts;
100 
101  map[ib].uz[num]=uz;
102  map[ib].lz[num]=lz;
103  map[ib].mz[num]=mz;
104  map[ib].gz[num]=gz;
105 
106  map[ib].maps_done[num]=1;
107 
108  }
109 
110 return;
111 
112 }
113 
114 
char fbuf[100]
Definition: decode_HDP.c:2
void make_map(int num)
Definition: make_map.c:3
void read_file(char *, int, struct pcp *)
Definition: read_file.c:5
struct pcp * pcp
Definition: mapper.c:140
int pcp_in_use[50]
Definition: mapper.c:78
struct hrap_grid * hrap_grid
Definition: mapper.c:142
ib
Definition: shleap.cc:46
int x
Definition: misc.h:230
int y
Definition: misc.h:231
short int hrap_miny
Definition: misc.h:583
short int hrap_minx
Definition: misc.h:582
short int maxi
Definition: misc.h:580
short int maxj
Definition: misc.h:581
Definition: misc.h:236
char hb5[10]
Definition: misc.h:238
float lz[200]
Definition: misc.h:250
float uz[200]
Definition: misc.h:248
struct hrap_data * hrap_data
Definition: misc.h:245
int hrap_points
Definition: misc.h:244
float gz[200]
Definition: misc.h:247
float mz[200]
Definition: misc.h:249
int maps_done[200]
Definition: misc.h:246
Definition: misc.h:596
short int ** value
Definition: misc.h:599