Created
April 2, 2014 23:00
-
-
Save ericrallen/9945057 to your computer and use it in GitHub Desktop.
Weather Status Code Mapping for Open Weather Maps API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//convert the status id returned from openweathermap.org | |
function convertWeatherID(id) { | |
var returnWeather = ''; | |
//check the ID | |
switch(id) { | |
//STORM | |
case 200: | |
case 201: | |
case 210: | |
case 211: | |
case 212: | |
case 221: | |
case 230: | |
case 231: | |
case 232: | |
case 960: | |
case 961: | |
case 962: | |
case 902: | |
case 900: | |
case 781: | |
case 771: | |
//HAIL | |
case 906: | |
//WIND | |
case 905: | |
case 953: | |
case 954: | |
case 955: | |
case 956: | |
case 957: | |
case 958: | |
case 959: | |
returnWeather = 'storming'; | |
break; | |
//RAIN | |
case 300: | |
case 301: | |
case 302: | |
case 310: | |
case 311: | |
case 312: | |
case 313: | |
case 314: | |
case 321: | |
case 500: | |
case 501: | |
case 503: | |
case 504: | |
case 511: | |
case 520: | |
case 521: | |
case 522: | |
case 531: | |
returnWeather = 'raining'; | |
break; | |
//SNOW | |
case 600: | |
case 601: | |
case 602: | |
case 611: | |
case 612: | |
case 615: | |
case 616: | |
case 620: | |
case 621: | |
case 622: | |
case 903: | |
returnWeather = 'snowing'; | |
break; | |
//CLEAR | |
case 800: | |
case 951: | |
case 904: | |
returnWeather = 'clear'; | |
break; | |
//CLOUDS | |
case 801: | |
case 802: | |
case 803: | |
case 804: | |
//FOG | |
case 701: | |
case 711: | |
case 721: | |
case 741: | |
returnWeather = 'cloudy'; | |
break; | |
default: | |
returnWeather = 'cloudy'; | |
break; | |
} | |
return returnWeather; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment