Mapper
get_station_list.c
Go to the documentation of this file.
1
#include "
prototypes.h
"
2
3
void
get_station_list
(
char
*
fname
)
4
5
{
6
7
extern
char
station_list_custom_file[256];
8
int
i
,ier,sflag,field,
j
,xadd,yadd;
9
extern
struct
station
station
[1500];
10
extern
int
max_stations
;
11
FILE *
fp
;
12
char
*p,kbuf[100],
hb5
[10];
13
14
max_stations
=0;
15
16
fp
=fopen(
fname
,
"r"
);
17
18
if
(
fp
==NULL) {
19
20
printf
(
"could not open %s\n"
,
fname
);
21
exit(1);
22
23
}
24
25
i
=0;
26
for
(;;) {
27
28
p=fgets(kbuf,80,
fp
);
29
if
(p==NULL)
30
break
;
31
32
if
(
i
==1500)
33
break
;
34
p=strchr(kbuf,
'\n'
);
35
36
if
(p!=NULL)
37
*p=0;
38
39
ier=sscanf(kbuf,
"%s %s %f %f "
,
station
[
i
].
hb5
,
40
station
[
i
].
parm
,&
station
[
i
].
lat
,&
station
[
i
].
lon
);
41
42
if
(ier != 4)
43
continue
;
44
45
sflag=1;
46
field=0;
47
for
(
j
=0;
j
<strlen(kbuf);
j
++) {
48
49
if
(kbuf[
j
] !=
' '
&& sflag==1) {
50
sflag=0;
51
field++;
52
53
}
54
55
else
if
(kbuf[
j
]==
' '
)
56
sflag=1;
57
58
if
(field==5) {
59
60
strcpy(
station
[
i
].
name
,&kbuf[
j
]);
61
break
;
62
63
}
64
65
}
66
67
i
++;
68
69
}
70
71
max_stations
=
i
;
72
fclose
(
fp
);
73
74
strcpy(kbuf,
fname
);
75
strcat(kbuf,
".custom"
);
76
strcpy(station_list_custom_file,kbuf);
77
78
fp
=fopen(kbuf,
"r"
);
79
80
if
(
fp
!=NULL) {
81
82
for
(;;) {
83
84
p=fgets(kbuf,80,
fp
);
85
if
(p==NULL)
86
break
;
87
88
p=strchr(kbuf,
'\n'
);
89
*p=0;
90
91
ier=sscanf(kbuf,
"%s %d %d"
,
hb5
,&
xadd
,&
yadd
);
92
93
for
(
j
=0;
j
<
max_stations
;
j
++) {
94
95
if
(strcmp(
hb5
,
station
[
j
].
hb5
)==0) {
96
97
station
[
j
].
xadd
=
xadd
;
98
station
[
j
].
yadd
=
yadd
;
99
break
;
100
101
}
102
103
}
104
105
}
106
}
107
fclose
(
fp
);
108
109
return
;
110
111
}
112
113
114
115
116
117
118
name
char name[35][30]
Definition:
borshef.c:10
i
static int i
Definition:
get_apps_defaults.c:110
get_station_list
void get_station_list(char *fname)
Definition:
get_station_list.c:3
fclose
fclose(fp)
printf
printf("fbuf is %s\n", fbuf)
fp
fp
Definition:
make_NEXRAD.c:339
j
int j
Definition:
mapp2h.h:48
lat
double lat
Definition:
mapp2h.h:41
lon
double lon
Definition:
mapp2h.h:41
max_stations
int max_stations
Definition:
mapper.c:64
prototypes.h
fname
char fname[100]
Definition:
send_afos.c:6
station
Definition:
misc.h:296
station::hb5
char hb5[10]
Definition:
misc.h:299
station::yadd
int yadd
Definition:
misc.h:310
station::parm
char parm[10]
Definition:
misc.h:301
station::xadd
int xadd
Definition:
misc.h:309
Generated by
1.9.1