This repository has been archived by the owner on Sep 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmetar34get.php
353 lines (351 loc) · 11.7 KB
/
metar34get.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
<?php
include('settings.php');include('livedata.php');error_reporting(0);
$result = date_sun_info(time(), $lat, $lon);
$suns2 =date('G.i', $result['sunset']);
$sunrs2 =date('G.i', $result['sunrise']);
$now =date('G.i');
//weather34 wxcheck API aviation metar script May 2018
$json_string = file_get_contents("jsondata/metar34.txt");
$parsed_json = json_decode($json_string);
$metar34time = $parsed_json->{'data'}[0]->{'observed'};
$metar34raw = $parsed_json->{'data'}[0]->{'raw_text'};
$metar34stationid = $parsed_json->{'data'}[0]->{'icao'};
$metar34stationname = $parsed_json->{'data'}[0]->{'station'}->{'name'};
$metar34pressurehg = $parsed_json->{'data'}[0]->{'barometer'}->{'hg'};
$metar34pressuremb = $parsed_json->{'data'}[0]->{'barometer'}->{'mb'};
$metar34conditions = $parsed_json->{'data'}[0]->{'conditions'}[0]->{'code'};
$metar34conditionstext = $parsed_json->{'data'}[0]->{'conditions'}[0]->{'text'};
$metar34clouds = $parsed_json->{'data'}[0]->{'clouds'}[0]->{'code'};
$metar34cloudstext = $parsed_json->{'data'}[0]->{'clouds'}[0]->{'text'};
$metar34dewpointc = $parsed_json->{'data'}[0]->{'dewpoint'}->{'celsius'};
$metar34dewpointf = $parsed_json->{'data'}[0]->{'dewpoint'}->{'fahrenheit'};
$metar34temperaturec = $parsed_json->{'data'}[0]->{'temperature'}->{'celsius'};
$metar34temperaturef = $parsed_json->{'data'}[0]->{'temperature'}->{'fahrenheit'};
$metar34humidity = $parsed_json->{'data'}[0]->{'humidity'}->{'percent'};
$metar34visibility = $parsed_json->{'data'}[0]->{'visibility'}->{'meters'};
$metar34visibilitymiles = $parsed_json->{'data'}[0]->{'visibility'}->{'miles'};
$metar34windir = $parsed_json->{'data'}[0]->{'wind'}->{'degrees'};
$metar34windspeedmph = $parsed_json->{'data'}[0]->{'wind'}->{'speed_mph'};
$metar34windspeedkmh = number_format($metar34windspeedmph*1.60934,0);//kmh
$metar34windspeedkts = $parsed_json->{'data'}[0]->{'wind'}->{'speed_kts'};
$metar34raininches = $parsed_json->{'data'}[0]->{'rain_in'};
$metar34rainmm = number_format($metar34raininches*25.4,2) ;
$metar34visibility=str_replace(',', '', $metar34visibility);
$metar34vismiles = number_format($metar34visibility*0.000621371,1) ;
$metar34viskm = number_format($metar34visibility*0.00099999969062399994,1) ;
// start the weather34 icon output and descriptions
if($metar34conditions =='-SHRA'){
if ($now >$suns2 ){$sky_icon='rain.svg';}
else if ($now <$sunrs2 ){$sky_icon='rain.svg';}
else $sky_icon='rain.svg';
$sky_desc='Light Rain <br>Showers';
}
//rain
else if($metar34conditions =='SHRA'){
if ($now >$suns2 ){$sky_icon='rain.svg';}
else if ($now <$sunrs2 ){$sky_icon='rain.svg';}
else $sky_icon='rain.svg';
$sky_desc='Light Rain <br>Showers';
}
//rain heavy
else if($metar34conditions =='+SHRA'){
if ($now >$suns2 ){$sky_icon='rain.svg';}
else if ($now <$sunrs2 ){$sky_icon='rain.svg';}
else $sky_icon='rain.svg';
$sky_desc='Heavy Rain <br>Showers';
}
//rain light
else if($metar34conditions=='-RA'){
if ($now >$suns2 ){$sky_icon='rain.svg';}
else if ($now <$sunrs2 ){$sky_icon='rain.svg';}
else $sky_icon='rain.svg';
$sky_desc='Light Rain <br>Showers';
}
//rain moderate
else if($metar34conditions=='+RA'){
if ($now >$suns2 ){$sky_icon='rain.svg';}
else if ($now <$sunrs2 ){$sky_icon='rain.svg';}
else $sky_icon='rain.svg';
$sky_desc='Moderate Rain <br>Showers';
}
//rain
else if($metar34conditions=='RA'){
if ($now >$suns2 ){$sky_icon='rain.svg';}
else if ($now <$sunrs2 ){$sky_icon='rain.svg';}
else $sky_icon='rain.svg';
$sky_desc='Light Rain <br>Showers';
}
//rain squalls
else if($metar34conditions=='SQ'){
if ($now >$suns2 ){$sky_icon='rain.svg';}
else if ($now <$sunrs2 ){$sky_icon='rain.svg';}
else $sky_icon='rain.svg';
$sky_desc='Rain Squall<br>Showers';
}
//snow light
else if($metar34conditions=='-SN'){
if ($now >$suns2 ){$sky_icon='snow.svg';}
else if ($now <$sunrs2 ){$sky_icon='snow.svg';}
else $sky_icon='snow.svg';
$sky_desc='Light Snow <br>Showers';
}
//snow moderate
else if($metar34conditions=='+SN'){
if ($now >$suns2 ){$sky_icon='snow.svg';}
else if ($now <$sunrs2 ){$sky_icon='snow.svg';}
else $sky_icon='snow.svg';
$sky_desc='Moderate Snow <br>Showers';
}
//snow
else if($metar34conditions=='SN'){
if ($now >$suns2 ){$sky_icon='snow.svg';}
else if ($now <$sunrs2 ){$sky_icon='snow.svg';}
else $sky_icon='snow.svg';
$sky_desc='Snow Showers <br>';
}
//snow grains
else if($metar34conditions=='SG'){
if ($now >$suns2 ){$sky_icon='snow.svg';}
else if ($now <$sunrs2 ){$sky_icon='snow.svg';}
else $sky_icon='snow.svg';
$sky_desc='Snow Grains <br>';
}
//snow grains
else if($metar34conditions=='SNINCR'){
if ($now >$suns2 ){$sky_icon='snow.svg';}
else if ($now <$sunrs2 ){$sky_icon='snow.svg';}
else $sky_icon='snow.svg';
$sky_desc='Snow Showers <br>';
}
//sleet
else if($metar34conditions=='IP'){
if ($now >$suns2 ){$sky_icon='sleet.svg';}
else if ($now <$sunrs2 ){$sky_icon='sleet.svg';}
else $sky_icon='sleet.svg';
$sky_desc='Sleet Showers';
}
//Haze
else if($metar34conditions=='HZ'){
if ($now >$suns2 ){$sky_icon='nt_haze.svg';}
else if ($now <$sunrs2 ){$sky_icon='nt_haze.svg';}
else $sky_icon='haze.svg';
$sky_desc='Hazy <br>Conditions';
}
//Batches Fog
else if($metar34conditions=='BCFG'){
if ($now >$suns2 ){$sky_icon='nt_fog.svg';}
else if ($now <$sunrs2 ){$sky_icon='nt_fog.svg';}
else $sky_icon='fog.svg';
$sky_desc='Foggy <br>Conditions';
}
//Fog
else if($metar34conditions=='FG'){
if ($now >$suns2 ){$sky_icon='nt_fog.svg';}
else if ($now <$sunrs2 ){$sky_icon='nt_fog.svg';}
else $sky_icon='fog.svg';
$sky_desc='Foggy <br>Conditions';
}
//Fog-NIGHT
else if($metar34conditions=='NFG'){
if ($now >$suns2 ){$sky_icon='nt_fog.svg';}
else if ($now <$sunrs2 ){$sky_icon='nt_fog.svg';}
else $sky_icon='fog.svg';
$sky_desc='Foggy <br>Conditions';
}
//Mist-Night
else if($metar34conditions=='BR'){
if ($now >$suns2 ){$sky_icon='nt_fog.svg';}
else if ($now <$sunrs2 ){$sky_icon='nt_fog.svg';}
else $sky_icon='fog.svg';
$sky_desc='Misty <br>Conditions';
}
//Mist
else if($metar34conditions=='NBR'){
if ($now >$suns2 ){$sky_icon='nt_fog.svg';}
else if ($now <$sunrs2 ){$sky_icon='nt_fog.svg';}
else $sky_icon='fog.svg';
$sky_desc='Misty <br>Conditions';
}
//Hail
else if($metar34conditions=='GR'){
if ($now >$suns2 ){$sky_icon='hail.svg';}
else if ($now <$sunrs2 ){$sky_icon='hail.svg';}
else $sky_icon='hail.svg';
$sky_desc='Hail and Rain <br>Conditions';
}
//Hail GS
else if($metar34conditions=='GS'){
if ($now >$suns2 ){$sky_icon='hail.svg';}
else if ($now <$sunrs2 ){$sky_icon='hail.svg';}
else $sky_icon='hail.svg';
$sky_desc='Hail <br>Conditions';
}
//ICE CYSTALS
else if($metar34conditions=='IC'){
if ($now >$suns2 ){$sky_icon='hail.svg';}
else if ($now <$sunrs2 ){$sky_icon='hail.svg';}
else $sky_icon='hail.svg';
$sky_desc='Ice Crystals';
}
//ICE PELLETS
else if($metar34conditions=='PL'){
if ($now >$suns2 ){$sky_icon='hail.svg';}
else if ($now <$sunrs2 ){$sky_icon='hail.svg';}
else $sky_icon='hail.svg';
$sky_desc='Ice Pellets <br>';
}
//Thunderstorms
else if($metar34conditions=='TS'){
if ($now >$suns2 ){$sky_icon='tstorm.svg';}
else if ($now <$sunrs2 ){$sky_icon='tstorm.svg';}
else $sky_icon='tstorm.svg';
$sky_desc='Thunderstorm <br>Conditions';
}
//Thunderstorms
else if($metar34conditions=='-TS'){
if ($now >$suns2 ){$sky_icon='tstorm.svg';}
else if ($now <$sunrs2 ){$sky_icon='tstorm.svg';}
else $sky_icon='tstorm.svg';
$sky_desc='Thunderstorm <br>Conditions';
}
//Thunderstorms
else if($metar34conditions=='+TS'){
if ($now >$suns2 ){$sky_icon='tstorm.svg';}
else if ($now <$sunrs2 ){$sky_icon='tstorm.svg';}
else $sky_icon='tstorm.svg';
$sky_desc='Heavy <br>Thunderstorms';
}
//Thunderstorms
else if($metar34conditions=='TSRA'){
if ($now >$suns2 ){$sky_icon='tstorm.svg';}
else if ($now <$sunrs2 ){$sky_icon='tstorm.svg';}
else $sky_icon='tstorm.svg';
$sky_desc='Thunderstorm <br>Conditions';
}
//Scattered Thunderstorms
else if($metar34conditions=='SCTTSRA'){
if ($now >$suns2 ){$sky_icon='tstorm.svg';}
else if ($now <$sunrs2 ){$sky_icon='tstorm.svg';}
else $sky_icon='tstorm.svg';
$sky_desc='Scattered <br>Thunderstorms';
}
//Scattered Thunderstorms
else if($metar34conditions=='NTSRA'){
if ($now >$suns2 ){$sky_icon='tstorm.svg';}
else if ($now <$sunrs2 ){$sky_icon='tstorm.svg';}
else $sky_icon='tstorm.svg';
$sky_desc='Scattered <br>Thunderstorms';
}
//Dust
else if($metar34conditions=='DS'){
if ($now >$suns2 ){$sky_icon='dust.svg';}
else if ($now <$sunrs2 ){$sky_icon='dust.svg';}
else $sky_icon='dust.svg';
$sky_desc='Dust Storm <br>Conditions';
}
//Widespread Dust
else if($metar34conditions=='DU'){
if ($now >$suns2 ){$sky_icon='dust.svg';}
else if ($now <$sunrs2 ){$sky_icon='dust.svg';}
else $sky_icon='dust.svg';
$sky_desc='Widespread Dust <br>Conditions';
}
//Dust-Sand Whirls
else if($metar34conditions=='PO'){
if ($now >$suns2 ){$sky_icon='dust.svg';}
else if ($now <$sunrs2 ){$sky_icon='dust.svg';}
else $sky_icon='dust.svg';
$sky_desc='Dust-Sand Whirls <br>Conditions';
}
//Sand
else if($metar34conditions=='SA'){
if ($now >$suns2 ){$sky_icon='dust.svg';}
else if ($now <$sunrs2 ){$sky_icon='dust.svg';}
else $sky_icon='dust.svg';
$sky_desc='Dust-Sand <br>Conditions';
}
//Sandstorm
else if($metar34conditions=='SS'){
if ($now >$suns2 ){$sky_icon='dust.svg';}
else if ($now <$sunrs2 ){$sky_icon='dust.svg';}
else $sky_icon='dust.svg';
$sky_desc='Sandstorm <br>Conditions';
}
//Volcanic Ash
else if($metar34conditions=='VA'){
if ($now >$suns2 ){$sky_icon='volcanoe.svg';}
else if ($now <$sunrs2 ){$sky_icon='volcanoe.svg';}
else $sky_icon='volcanoe.svg';
$sky_desc='Volcanic Ash <br>Conditions';
}
//+FC
else if($metar34conditions=='+FC'){
if ($now >$suns2 ){$sky_icon='nsvrtsa.svg';}
else if ($now <$sunrs2 ){$sky_icon='nsvrtsa.svg';}
else $sky_icon='nsvrtsat.svg';
$sky_desc='Tornado <br> Water Sprout';
}
//2nd part clouds
//clear
else if ($metar34clouds=='SKC') {
if ($now >$suns2 ){$sky_icon='nt_clear.svg';}
else if ($now <$sunrs2 ){$sky_icon='nt_clear.svg';}
else $sky_icon='clear.svg';
$sky_desc='Clear <br>Conditions';
}
//clear
else if($metar34clouds=='CLR'){
if ($now >$suns2 ){$sky_icon='nt_clear.svg';}
else if ($now <$sunrs2 ){$sky_icon='nt_clear.svg';}
else $sky_icon='clear.svg';
$sky_desc='Clear <br>Conditions';
}
//clear
else if($metar34clouds=='CAVOK'){
if ($now >$suns2 ){$sky_icon='nt_clear.svg';}
else if ($now <$sunrs2 ){$sky_icon='nt_clear.svg';}
else $sky_icon='clear.svg';
$sky_desc='Clear <br>Conditions';
}
//few
else if($metar34clouds=='FEW'){
if ($now >$suns2 ){$sky_icon='partlycloudy.svg';}
else if ($now <$sunrs2 ){$sky_icon='partlycloudy.svg';}
else $sky_icon='partlysunny.svg';
$sky_desc='Partly Cloudy <br>Conditions';
}
//scattered clouds
else if($metar34clouds=='SCT'){
if ($now >$suns2 ){$sky_icon='nt_scatteredclouds.svg';}
else if ($now <$sunrs2 ){$sky_icon='nt_scatteredclouds.svg';}
else $sky_icon='scatteredclouds.svg';
$sky_desc='Mostly Scattered <br>Clouds';
}
//mostly cloudy
else if($metar34clouds=='BKN'){
if ($now >$suns2 ){$sky_icon='nt_mostlycloudy.svg';}
else if ($now <$sunrs2 ){$sky_icon='nt_mostlycloudy.svg';}
else $sky_icon='mostlycloudy.svg';
$sky_desc='Mostly Cloudy <br>Conditions';
}
//overcast
else if($metar34clouds=='OVC'){
if ($now >$suns2 ){$sky_icon='nt_overcast.svg';}
else if ($now <$sunrs2 ){$sky_icon='nt_overcast.svg';}
else $sky_icon='overcast.svg';
$sky_desc='Overcast <br>Conditions';
}
//overcast
else if($metar34clouds=='OVX'){
if ($now >$suns2 ){$sky_icon='nt_overcast.svg';}
else if ($now <$sunrs2 ){$sky_icon='nt_overcast.svg';}
else $sky_icon='overcast.svg';
$sky_desc='Overcast Conditions';
}
//offline
else{
$sky_icon='offline.svg';
$sky_desc='Data Offline';
};
//end weather34 metar aviation script API
?>