30/12/2018

There are a lot of Weather conditions that can be presented on your watch face… so how do you boil those down into a relatively small subset?

You need to consider all the combinations… for reference, Pujie Black uses either OpenWeatherMap or YR as a provider… check out their respective lists of possible conditions here:

https://openweathermap.org/weather-conditions

https://hjelp.yr.no/hc/en-us/articles/203786121-Weather-symbols-on-Yr

Basically, you need to choose what is more important… if it is “heavy rain showers and thunder”, you may conclude “thunder” is the appropriate group.

To that end, this is the JavaScript I landed on for my hand rotation. The order of evaluation is very important here… if the if-condition tests for “rain” first then “thunderstorm with rain” will be matched with “rain” rather than the more appropriate “storm”. This is why my logic is in the order: thunder; drizzle; sleet/now; rain; cloud; and, clear/fair.

var w=[weather];
var r=52;
if(w.indexOf("thunder") !== -1){r=255;}
else if (w.indexOf("drizzle") !== -1) {r=155}
else if (w.indexOf("sleet") !== -1 || w.indexOf("snow") !== -1) {r=305}
else if (w.indexOf("rain") !== -1) {r=205}
else if (w.indexOf("cloud") !== -1) {r=102}
else if (w.indexOf("clear") !== -1 || w.indexOf("fair") !== -1) {r=0}
return r

In this case, since low visibility is the default position, I deliberately didn’t add a catch-all else.

Leave a Reply

Your email address will not be published. Required fields are marked *