Skip to content

Instantly share code, notes, and snippets.

View mromanoff's full-sized avatar

Michael Romanoff mromanoff

View GitHub Profile
@Shivabeach
Shivabeach / #OpenWeathermap wind direction
Last active July 27, 2021 15:29
Open #weathermap conversion from degrees to direction. #degrees #direction #javascript
$.getJSON("https://api.openweathermap.org/data/2.5/weather?id=4614214&units=imperial&APPID=openweathermap api code", function(data) {
var icon = "http://openweathermap.org/img/w/" + data.weather[0].icon + ".png";
var temp = Math.floor(data.main.temp);
var weather = data.weather[0].description;
var humid = data.main.humidity;
var windspeed = data.wind.speed + " mph";
var deg = Math.floor(data.wind.deg);
switch (true) {
case deg >= 360 && deg <= 21:
deg = "N";