Mapper
get_zstation_list.c
Go to the documentation of this file.
1 #include "prototypes_new.h"
2 
4 
5 {
6 
7  extern char zstation_list_custom_file[100];
8  extern struct dval dval;
9  int i,ier,sflag,field,j,xadd,yadd;
10  extern struct station zstation[750];
11  extern int max_zstations;
12  FILE *fp;
13  char *p,kbuf[200],hb5[10],parm[10];
14  double dist1,dist2,dist,sorted[30];
15  int m,l,h,k;
16  int kk;
17  float lat,lon;
18  float conv=.0174;
19  long t,u;
20  float elev;
21 
22  max_zstations=0;
23 
24  fp=fopen(fname,"r");
25 
26  if(fp==NULL) {
27 
28  printf("could not open %s\n",fname);
29  exit(1);
30 
31  }
32 
33  i=0;
34  for(;;) {
35 
36  p=fgets(kbuf,120,fp);
37  if(p==NULL)
38  break;
39 
40  if(i==750)
41  break;
42 
43  p=strchr(kbuf,'\n');
44 
45  if(p!=NULL)
46  *p=0;
47 
48  j=0;
49  while(kbuf[j] != 0) {
50 
51  if(kbuf[j]=='\t')
52  kbuf[j]=' ';
53 
54  j++;
55 
56  }
57 
58  zstation[i].hb5=calloc(10,sizeof(char));
59  zstation[i].name=calloc(50,sizeof(char));
60  zstation[i].parm=calloc(10,sizeof(char));
61 
62  ier=sscanf(kbuf,"%s %s %f %f %f %d ",zstation[i].hb5,
63  zstation[i].parm,&zstation[i].lat,
64  &zstation[i].lon,&elev,&zstation[i].tip);
65 
66  if(strncasecmp("HZI",zstation[i].parm,3)!=0)
67  continue;
68 
69 
70  for(m=0;m<i;m++) {
71 
72  if(strcmp(zstation[i].hb5,zstation[m].hb5)==0 &&
73  zstation[i].parm[4]==zstation[m].parm[4]){
74 
75  printf("duplicate zstation %s\n",zstation[i].hb5);
76  break;
77 
78  }
79 
80  }
81 
82 
83  if(ier != 6)
84  continue;
85 
86  lat=zstation[i].lat;
87  lon=zstation[i].lon;
88 
89  t=dval.a * cos(lat*conv)/(1+sin(lat*conv))
90  * cos((lon-dval.lo-90)*conv) + dval.xo +.5;
91 
92  zstation[i].x=t;
93 
94  u=dval.a * cos(lat*conv)/(1+sin(lat*conv))
95  * sin((lon-dval.lo-90)*conv) + dval.yo + .5;
96 
97  zstation[i].y=u;
98 
99  sflag=1;
100  field=0;
101  for(j=0;j<strlen(kbuf);j++) {
102 
103  if(kbuf[j] !=' ' && sflag==1) {
104  sflag=0;
105  field++;
106 
107  }
108 
109  else if(kbuf[j]==' ')
110  sflag=1;
111 
112  if(field==7) {
113 
114  kbuf[j+49]=0;
115 
116  strcpy(zstation[i].name,&kbuf[j]);
117  break;
118 
119  }
120 
121  }
122 
123  i++;
124 
125  }
126 
127 max_zstations=i;
128 
129 fclose(fp);
130 
131 strcpy(kbuf,fname);
132 strcat(kbuf,".zcustom");
133 strcpy(zstation_list_custom_file,kbuf);
134 
135 fp=fopen(kbuf,"r");
136 
137 if(fp!=NULL) {
138 
139  for(;;) {
140 
141  p=fgets(kbuf,80,fp);
142  if(p==NULL)
143  break;
144 
145  p=strchr(kbuf,'\n');
146  *p=0;
147 
148  ier=sscanf(kbuf,"%s %s %d %d",hb5,parm,&xadd,&yadd);
149 
150  for(j=0;j<max_zstations;j++) {
151 
152  if(strcmp(hb5,zstation[j].hb5)==0) {
153 
154  if(strncmp(parm,zstation[j].parm,3)==0 &&
155  parm[4]==zstation[j].parm[4]) {
156 
157  zstation[j].xadd=xadd;
158  zstation[j].yadd=yadd;
159  break;
160 
161  }
162 
163  }
164 
165  }
166  }
167 
168  fclose(fp);
169 
170  }
171 
172 return;
173 
174 }
175 
176 
177 
178 
179 
180 
char name[35][30]
Definition: borshef.c:10
static int i
void get_zstation_list(char *fname)
fclose(fp)
printf("fbuf is %s\n", fbuf)
fp
Definition: make_NEXRAD.c:339
int j
Definition: mapp2h.h:48
int elev
Definition: mapp2h.h:48
double lat
Definition: mapp2h.h:41
double lon
Definition: mapp2h.h:41
int k
Definition: mapp2h.h:48
char fname[100]
Definition: send_afos.c:6
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:296
float lat
Definition: misc.h:303
int x
Definition: misc.h:307
char hb5[10]
Definition: misc.h:299
int tip
Definition: misc.h:306
float lon
Definition: misc.h:304
char name[50]
Definition: misc.h:300
int y
Definition: misc.h:308
int yadd
Definition: misc.h:310
char parm[10]
Definition: misc.h:301
int xadd
Definition: misc.h:309