-
Notifications
You must be signed in to change notification settings - Fork 10
/
model-old.js
74 lines (71 loc) · 1.91 KB
/
model-old.js
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
const weatherMap = ({
sunny: 'clear',
clear: 'clear',
mostlysunny: 'clear',
mostlyclear: 'clear',
partlysunny: 'partlycloudy',
partlysunnywshowers: 'partlycloudy',
partlysunnywtstorms: 'partlycloudy',
partlysunnywflurries: 'partlycloudy',
partlycloudy: 'partlycloudy',
partlycloudywshowers: 'partlycloudy',
partlycloudywtstorms: 'partlycloudy',
intermittentclouds: 'partlycloudy',
mostlycloudy: 'cloudy',
mostlycloudywshowers: 'cloudy',
mostlycloudywtstorms: 'cloudy',
mostlycloudywflurries: 'cloudy',
cloudy: 'cloudy',
hazysunshine: 'cloudy',
hazymoonlight: 'cloudy',
dreary: 'cloudy',
showers: 'rain',
rain: 'rain',
tstorms: 'rain',
thunderstorms: 'rain',
freezingrain: 'rain',
fog: 'fog',
rainandsnow: 'snow',
flurries: 'snow',
snow: 'snow',
windy: 'windy',
ice: 'clear',
}) // https://i.imgur.com/LgkxoJx.png
const thresholds = {
dominant: {
'rain': 60,
'snow': 60,
'wind': 55,
},
superficial: {
'rain': 50,
'snow': 50,
'wind': 16,
},
}
const aw2pogo = ({
label,
wind,
gust,
precip,
snow,
}) => {
const weather = weatherMap[label] ?? { dominant: 'unknown', superficial: {}, windyable: false }
return {
dominant:
['rain', 'snow'].includes(weather) ? weather
: snow >= thresholds.dominant.snow ? 'snow'
: precip >= thresholds.dominant.rain ? 'rain'
: label.search('wshowers') >= 0 ? weather
: wind + gust >= thresholds.dominant.wind ? 'windy' // DEBUG: This was our old wind model
: weather,
superficial: {
'snow': snow >= thresholds.superficial.snow,
'rain': precip >= thresholds.superficial.rain,
'windy': wind >= thresholds.superficial.wind
}
}
}
// NOTE: Apparently AW 'w/ showers' overrides this entirely:
// https://www.reddit.com/r/TheSilphRoad/comments/9uoz3r/the_usual_requirement_for_wind_seems_to_have/e95x731/
module.exports = aw2pogo