public void GetBestCloudyWeather() { string json = "{\"cod\":\"200\",\"message\":0.0074,\"cnt\":40,\"list\":[{\"dt\":1562662800,\"main\":{\"temp\":289.15,\"temp_min\":289.15,\"temp_max\":289.3,\"pressure\":1014.16,\"sea_level\":1014.16,\"grnd_level\":983.85,\"humidity\":47,\"temp_kf\":-0.15},\"weather\":[{\"id\":800,\"main\":\"Clouds\",\"description\":\"few clouds\",\"icon\":\"02d\"}],\"clouds\":{\"all\":18},\"wind\":{\"speed\":3.98,\"deg\":34.536},\"sys\":{\"pod\":\"d\"},\"dt_txt\":\"2019-07-09 09:00:00\"},{\"dt\":1562673600,\"main\":{\"temp\":292.25,\"temp_min\":292.25,\"temp_max\":292.363,\"pressure\":1014.1,\"sea_level\":1014.1,\"grnd_level\":983.48,\"humidity\":38,\"temp_kf\":-0.11},\"weather\":[{\"id\":801,\"main\":\"Clouds\",\"description\":\"few clouds\",\"icon\":\"02n\"}],\"clouds\":{\"all\":9},\"wind\":{\"speed\":3.53,\"deg\":38.008},\"sys\":{\"pod\":\"d\"},\"dt_txt\":\"2019-07-09 12:00:00\"},{\"dt\":1562684400,\"main\":{\"temp\":292.66,\"temp_min\":292.66,\"temp_max\":292.732,\"pressure\":1013.35,\"sea_level\":1013.35,\"grnd_level\":982.83,\"humidity\":38,\"temp_kf\":-0.07},\"weather\":[{\"id\":802,\"main\":\"Clouds\",\"description\":\"few clouds\",\"icon\":\"02n\"}],\"clouds\":{\"all\":30},\"wind\":{\"speed\":2.96,\"deg\":38.436},\"sys\":{\"pod\":\"d\"},\"dt_txt\":\"2019 - 07 - 09 15:00:00\"},{\"dt\":1562695200,\"main\":{\"temp\":290.8,\"temp_min\":290.8,\"temp_max\":290.832,\"pressure\":1013.73,\"sea_level\":1013.73,\"grnd_level\":983.38,\"humidity\":52,\"temp_kf\":-0.04},\"weather\":[{\"id\":803,\"main\":\"Clouds\",\"description\":\"scattered clouds\",\"icon\":\"03d\"}],\"clouds\":{\"all\":32},\"wind\":{\"speed\":1.26,\"deg\":25.08},\"sys\":{\"pod\":\"d\"},\"dt_txt\":\"2019-07-09 18:00:00\"},{\"dt\":1562706000,\"main\":{\"temp\":286.032,\"temp_min\":286.032,\"temp_max\":286.032,\"pressure\":1014.25,\"sea_level\":1014.25,\"grnd_level\":983.85,\"humidity\":71,\"temp_kf\":0},\"weather\":[{\"id\":804,\"main\":\"Clouds\",\"description\":\"overcast clouds\",\"icon\":\"04n\"}],\"clouds\":{\"all\":92},\"wind\":{\"speed\":2.04,\"deg\":351.245},\"sys\":{\"pod\":\"n\"},\"dt_txt\":\"2019-07 - 09 21:00:00\"},{\"dt\":1562716800,\"main\":{\"temp\":282.9,\"temp_min\":282.9,\"temp_max\":282.9,\"pressure\":1014.48,\"sea_level\":1014.48,\"grnd_level\":984.05,\"humidity\":81,\"temp_kf\":0},\"weather\":[{\"id\":803,\"main\":\"Clouds\",\"description\":\"broken clouds\",\"icon\":\"04n\"}],\"clouds\":{\"all\":79},\"wind\":{\"speed\":2.15,\"deg\":321.144},\"sys\":{\"pod\":\"n\"},\"dt_txt\":\"2019 - 07 - 10 00:00:00\"},{\"dt\":1562727600,\"main\":{\"temp\":283.3,\"temp_min\":283.3,\"temp_max\":283.3,\"pressure\":1014.12,\"sea_level\":1014.12,\"grnd_level\":983.5,\"humidity\":76,\"temp_kf\":0},\"weather\":[{\"id\":804,\"main\":\"Clouds\",\"description\":\"overcast clouds\",\"icon\":\"04d\"}],\"clouds\":{\"all\":100},\"wind\":{\"speed\":1.79,\"deg\":294.001},\"sys\":{\"pod\":\"d\"},\"dt_txt\":\"2019-07-10 03:00:00\"},{\"dt\":1562738400,\"main\":{\"temp\":289.3,\"temp_min\":289.3,\"temp_max\":289.3,\"pressure\":1013.31,\"sea_level\":1013.31,\"grnd_level\":983.04,\"humidity\":55,\"temp_kf\":0},\"weather\":[{\"id\":804,\"main\":\"Clouds\",\"description\":\"overcast clouds\",\"icon\":\"04d\"}],\"clouds\":{\"all\":90},\"wind\":{\"speed\":1.99,\"deg\":357.286},\"sys\":{\"pod\":\"d\"},\"dt_txt\":\"2019-07-10 06:00:00\"},{\"dt\":1562749200,\"main\":{\"temp\":293,\"temp_min\":293,\"temp_max\":293,\"pressure\":1012.91,\"sea_level\":1012.91,\"grnd_level\":982.98,\"humidity\":43,\"temp_kf\":0},\"weather\":[{\"id\":805,\"main\":\"Clouds\",\"description\":\"scattered clouds\",\"icon\":\"03d\"}],\"clouds\":{\"all\":38},\"wind\":{\"speed\":2.79,\"deg\":42.715},\"sys\":{\"pod\":\"d\"},\"dt_txt\":\"2019 - 07 - 10 09:00:00\"},{\"dt\":1562760000,\"main\":{\"temp\":295.2,\"temp_min\":295.2,\"temp_max\":295.2,\"pressure\":1012.05,\"sea_level\":1012.05,\"grnd_level\":982.36,\"humidity\":35,\"temp_kf\":0},\"weather\":[{\"id\":806,\"main\":\"Clouds\",\"description\":\"broken clouds\",\"icon\":\"04d\"}],\"clouds\":{\"all\":63},\"wind\":{\"speed\":2.29,\"deg\":50.335},\"sys\":{\"pod\":\"d\"},\"dt_txt\":\"2019-07-10 12:00:00\"},{\"dt\":1562770800,\"main\":{\"temp\":294.6,\"temp_min\":294.6,\"temp_max\":294.6,\"pressure\":1011.42,\"sea_level\":1011.42,\"grnd_level\":981.73,\"humidity\":37,\"temp_kf\":0},\"weather\":[{\"id\":807,\"main\":\"Clouds\",\"description\":\"overcast clouds\",\"icon\":\"04d\"}],\"clouds\":{\"all\":99},\"wind\":{\"speed\":1.43,\"deg\":73.305},\"sys\":{\"pod\":\"d\"},\"dt_txt\":\"2019-07-10 15:00:00\"},{\"dt\":1562781600,\"main\":{\"temp\":292.042,\"temp_min\":292.042,\"temp_max\":292.042,\"pressure\":1011.39,\"sea_level\":1011.39,\"grnd_level\":981.38,\"humidity\":52,\"temp_kf\":0},\"weather\":[{\"id\":808,\"main\":\"Clouds\",\"description\":\"overcast clouds\",\"icon\":\"04d\"}],\"clouds\":{\"all\":87},\"wind\":{\"speed\":1.1,\"deg\":174.951},\"sys\":{\"pod\":\"d\"},\"dt_txt\":\"2019-07-10 18:00:00\"},{\"dt\":1562792400,\"main\":{\"temp\":288.5,\"temp_min\":288.5,\"temp_max\":288.5,\"pressure\":1011.96,\"sea_level\":1011.96,\"grnd_level\":981.97,\"humidity\":59,\"temp_kf\":0},\"weather\":[{\"id\":809,\"main\":\"Clouds\",\"description\":\"overcast clouds\",\"icon\":\"04n\"}],\"clouds\":{\"all\":95},\"wind\":{\"speed\":0.51,\"deg\":100.113},\"sys\":{\"pod\":\"n\"},\"dt_txt\":\"2019-07-10 21:00:00\"},{\"dt\":1562803200,\"main\":{\"temp\":285.412},\"weather\":[{\"id\":810,\"main\":\"Clouds\",\"description\":\"broken clouds\",\"icon\":\"04n\"}],\"clouds\":{\"all\":77},\"wind\":{\"speed\":1.51,\"deg\":292.055},\"sys\":{\"pod\":\"n\"},\"dt_txt\":\"2019-07-11 00:00:00\"},{\"dt\":1562814000,\"main\":{\"temp\":286.093},\"weather\":[{\"id\":811,\"main\":\"Clouds\",\"description\":\"broken clouds\",\"icon\":\"04d\"}],\"clouds\":{\"all\":81},\"wind\":{\"speed\":1.53,\"deg\":301.446},\"sys\":{\"pod\":\"d\"},\"dt_txt\":\"2019-07-11 03:00:00\"},{\"dt\":1562824800,\"main\":{\"temp\":288.815},\"weather\":[{\"id\":812,\"main\":\"Clouds\",\"description\":\"overcast clouds\",\"icon\":\"04d\"}],\"clouds\":{\"all\":90},\"wind\":{\"speed\":0.93,\"deg\":321.119},\"sys\":{\"pod\":\"d\"},\"dt_txt\":\"2019 - 07 - 11 06:00:00\"},{\"dt\":1562835600,\"main\":{\"temp\":292.9},\"weather\":[{\"id\":813,\"main\":\"Clouds\",\"description\":\"overcast clouds\",\"icon\":\"04d\"}],\"clouds\":{\"all\":95},\"wind\":{\"speed\":1.49,\"deg\":82.306},\"sys\":{\"pod\":\"d\"},\"dt_txt\":\"2019-07-11 09:00:00\"},{\"dt\":1562846400,\"main\":{\"temp\":294},\"weather\":[{\"id\":814,\"main\":\"Clouds\",\"description\":\"overcast clouds\",\"icon\":\"04d\"}],\"clouds\":{\"all\":87},\"wind\":{\"speed\":2.43,\"deg\":159.751},\"sys\":{\"pod\":\"d\"},\"dt_txt\":\"2019-07-11 12:00:00\"},{\"dt\":1562857200,\"main\":{\"temp\":294.1},\"weather\":[{\"id\":815,\"main\":\"Clouds\",\"description\":\"overcast clouds\",\"icon\":\"04d\"}],\"clouds\":{\"all\":91},\"wind\":{\"speed\":1.76,\"deg\":128.665},\"sys\":{\"pod\":\"d\"},\"dt_txt\":\"2019-07-11 15:00:00\"},{\"dt\":1562868000,\"main\":{\"temp\":291.6},\"weather\":[{\"id\":816,\"main\":\"Clouds\",\"description\":\"broken clouds\",\"icon\":\"04d\"}],\"clouds\":{\"all\":84},\"wind\":{\"speed\":3.93,\"deg\":128.557},\"sys\":{\"pod\":\"d\"},\"dt_txt\":\"2019-07-11 18:00:00\"},{\"dt\":1562878800,\"main\":{\"temp\":285.847},\"weather\":[{\"id\":816,\"main\":\"Rain\",\"description\":\"light rain\",\"icon\":\"10n\"}],\"clouds\":{\"all\":75},\"wind\":{\"speed\":2.78,\"deg\":102.477},\"rain\":{\"3h\":0.188},\"sys\":{\"pod\":\"n\"},\"dt_txt\":\"2019-07-11 21:00:00\"}],\"city\":{\"id\":2696650,\"name\":\"Alvik\",\"coord\":{\"lat\":60.7477,\"lon\":14.8746},\"country\":\"SE\",\"population\":5861,\"timezone\":7200}}"; var weather = ForecastAPI.GetBestWeather("Alvik", json, 1).Weather; Assert.AreEqual("Clouds", weather); }
public void GetBestSunnyWeather() { string json = "{\"list\":[{\"dt\" : 1562619600,\"main\":{\"temp\" : 285.15,\"temp_min\" : 283.498,\"temp_max\" : 285.15,\"pressure\" : 1012.9,\"sea_level\" : 1012.9,\"grnd_level\" : 982.46,\"humidity\" : 90,\"temp_kf\" : 1.66},\"weather\" : [{\"id\" : 802,\"main\" : \"Rain\",\"description\" : \"light rain\",\"icon\" : \"04n\"}],\"clouds\" : {\"all\" : 100},\"wind\" : {\"speed\" : 2.32,\"deg\" : 12.022},\"sys\" : {\"pod\" : \"n\"},\"dt_txt\" : \"2019-07-08 21:00:00\"},{\"dt\" : 1562619600,\"main\":{\"temp\" : 285.15,\"temp_min\" : 283.498,\"temp_max\" : 285.15,\"pressure\" : 1012.9,\"sea_level\" : 1012.9,\"grnd_level\" : 982.46,\"humidity\" : 90,\"temp_kf\" : 1.66},\"weather\" : [{\"id\" : 803,\"main\" : \"Clouds\",\"description\" : \"overcast clouds\",\"icon\" : \"04n\"}],\"clouds\" : {\"all\" : 100},\"wind\" : {\"speed\" : 2.32,\"deg\" : 12.022},\"sys\" : {\"pod\" : \"n\"},\"dt_txt\" : \"2019-07-08 22:00:00\"}, {\"dt\" : 1562619600,\"main\":{\"temp\" : 285.15,\"temp_min\" : 283.498,\"temp_max\" : 285.15,\"pressure\" : 1012.9,\"sea_level\" : 1012.9,\"grnd_level\" : 982.46,\"humidity\" : 90,\"temp_kf\" : 1.66},\"weather\" : [{\"id\" : 804,\"main\" : \"Clouds\",\"description\" : \"overcast clouds\",\"icon\" : \"04n\"}],\"clouds\" : {\"all\" : 100},\"wind\" : {\"speed\" : 2.32,\"deg\" : 12.022},\"sys\" : {\"pod\" : \"n\"},\"dt_txt\" : \"2019-07-08 23:00:00\"},{\"dt\" : 1562619600,\"main\":{\"temp\" : 265.15,\"temp_min\" : 283.498,\"temp_max\" : 285.15,\"pressure\" : 1012.9,\"sea_level\" : 1012.9,\"grnd_level\" : 982.46,\"humidity\" : 90,\"temp_kf\" : 1.66},\"weather\" : [{\"id\" : 805,\"main\" : \"Clouds\",\"description\" : \"scattered clouds\",\"icon\" : \"04n\"}],\"clouds\" : {\"all\" : 100},\"wind\" : {\"speed\" : 2.32,\"deg\" : 12.022},\"sys\" : {\"pod\" : \"n\"},\"dt_txt\" : \"2019-07-09 00:00:00\"},{\"dt\" : 1562619600,\"main\":{\"temp\" : 255.15,\"temp_min\" : 283.498,\"temp_max\" : 285.15,\"pressure\" : 1012.9,\"sea_level\" : 1012.9,\"grnd_level\" : 982.46,\"humidity\" : 90,\"temp_kf\" : 1.66},\"weather\" : [{\"id\" : 806,\"main\" : \"Clouds\",\"description\" : \"overcast clouds\",\"icon\" : \"04n\"}],\"clouds\" : {\"all\" : 100},\"wind\" : {\"speed\" : 2.32,\"deg\" : 12.022},\"sys\" : {\"pod\" : \"n\"},\"dt_txt\" : \"2019-07-09 01:00:00\"}, {\"dt\" : 1562619600,\"main\":{\"temp\" : 285.15,\"temp_min\" : 283.498,\"temp_max\" : 285.15,\"pressure\" : 1012.9,\"sea_level\" : 1012.9,\"grnd_level\" : 982.46,\"humidity\" : 90,\"temp_kf\" : 1.66},\"weather\" : [{\"id\" : 806,\"main\" : \"Clear\",\"description\" : \"overcast clouds\",\"icon\" : \"04n\"}],\"clouds\" : {\"all\" : 100},\"wind\" : {\"speed\" : 2.32,\"deg\" : 12.022},\"sys\" : {\"pod\" : \"n\"},\"dt_txt\" : \"2019-07-09 02:00:00\"}],\"city\": {\"id\" : 2696650,\"name\" : \"Alvik\",\"coord\" : { \"lat\" : 60.7477,\"lon\" : 14.8746 },\"country\" : \"SE\",\"population\" : 5861,\"timezone\" : 7200} }"; var weather = ForecastAPI.GetBestWeather("Alvik", json, 1).Weather; Assert.AreEqual("Clear", weather); }
public void GetBestFoggyWeather() { string json = "{\"list\":[{\"dt\" : 1562619600,\"main\":{\"temp\" : 285.15,\"temp_min\" : 283.498,\"temp_max\" : 285.15,\"pressure\" : 1012.9,\"sea_level\" : 1012.9,\"grnd_level\" : 982.46,\"humidity\" : 90,\"temp_kf\" : 1.66},\"weather\" : [{\"id\" : 800,\"main\" : \"Rain\",\"description\" : \"light rain\",\"icon\" : \"04n\"}],\"clouds\" : {\"all\" : 100},\"wind\" : {\"speed\" : 2.32,\"deg\" : 12.022},\"sys\" : {\"pod\" : \"n\"},\"dt_txt\" : \"2019-07-08 21:00:00\"},{\"dt\" : 1562619600,\"main\":{\"temp\" : 285.15,\"temp_min\" : 283.498,\"temp_max\" : 285.15,\"pressure\" : 1012.9,\"sea_level\" : 1012.9,\"grnd_level\" : 982.46,\"humidity\" : 90,\"temp_kf\" : 1.66},\"weather\" : [{\"id\" : 801,\"main\" : \"Fog\",\"description\" : \"fog\",\"icon\" : \"04n\"}],\"clouds\" : {\"all\" : 100},\"wind\" : {\"speed\" : 2.32,\"deg\" : 12.022},\"sys\" : {\"pod\" : \"n\"},\"dt_txt\" : \"2019-07-08 22:00:00\"}, {\"dt\" : 1562619600,\"main\":{\"temp\" : 285.15,\"temp_min\" : 283.498,\"temp_max\" : 285.15,\"pressure\" : 1012.9,\"sea_level\" : 1012.9,\"grnd_level\" : 982.46,\"humidity\" : 90,\"temp_kf\" : 1.66},\"weather\" : [{\"id\" : 802,\"main\" : \"Drizzle\",\"description\" : \"light intensity drizzle\",\"icon\" : \"04n\"}],\"clouds\" : {\"all\" : 100},\"wind\" : {\"speed\" : 2.32,\"deg\" : 12.022},\"sys\" : {\"pod\" : \"n\"},\"dt_txt\" : \"2019-07-08 23:00:00\"},{\"dt\" : 1562619600,\"main\":{\"temp\" : 265.15,\"temp_min\" : 283.498,\"temp_max\" : 285.15,\"pressure\" : 1012.9,\"sea_level\" : 1012.9,\"grnd_level\" : 982.46,\"humidity\" : 90,\"temp_kf\" : 1.66},\"weather\" : [{\"id\" : 803,\"main\" : \"Rain\",\"description\" : \"light rain\",\"icon\" : \"04n\"}],\"clouds\" : {\"all\" : 100},\"wind\" : {\"speed\" : 2.32,\"deg\" : 12.022},\"sys\" : {\"pod\" : \"n\"},\"dt_txt\" : \"2019-07-09 00:00:00\"},{\"dt\" : 1562619600,\"main\":{\"temp\" : 255.15,\"temp_min\" : 283.498,\"temp_max\" : 285.15,\"pressure\" : 1012.9,\"sea_level\" : 1012.9,\"grnd_level\" : 982.46,\"humidity\" : 90,\"temp_kf\" : 1.66},\"weather\" : [{\"id\" : 806,\"main\" : \"Rain\",\"description\" : \"moderate rain\",\"icon\" : \"04n\"}],\"clouds\" : {\"all\" : 100},\"wind\" : {\"speed\" : 2.32,\"deg\" : 12.022},\"sys\" : {\"pod\" : \"n\"},\"dt_txt\" : \"2019-07-09 01:00:00\"}, {\"dt\" : 1562619600,\"main\":{\"temp\" : 285.15,\"temp_min\" : 283.498,\"temp_max\" : 285.15,\"pressure\" : 1012.9,\"sea_level\" : 1012.9,\"grnd_level\" : 982.46,\"humidity\" : 90,\"temp_kf\" : 1.66},\"weather\" : [{\"id\" : 806,\"main\" : \"Drizzle\",\"description\" : \"heavy intensity drizzle\",\"icon\" : \"04n\"}],\"clouds\" : {\"all\" : 100},\"wind\" : {\"speed\" : 2.32,\"deg\" : 12.022},\"sys\" : {\"pod\" : \"n\"},\"dt_txt\" : \"2019-07-09 02:00:00\"},{\"dt\":1562878800,\"main\":{\"temp\":285.847},\"weather\":[{\"id\":816,\"main\":\"Rain\",\"description\":\"light rain\",\"icon\":\"10n\"}],\"clouds\":{\"all\":75},\"wind\":{\"speed\":2.78,\"deg\":102.477},\"rain\":{\"3h\":0.188},\"sys\":{\"pod\":\"n\"},\"dt_txt\":\"2019-07-11 22:00:00\"},{\"dt\":1562878800,\"main\":{\"temp\":285.847},\"weather\":[{\"id\":816,\"main\":\"Rain\",\"description\":\"light rain\",\"icon\":\"10n\"}],\"clouds\":{\"all\":75},\"wind\":{\"speed\":2.78,\"deg\":102.477},\"rain\":{\"3h\":0.188},\"sys\":{\"pod\":\"n\"},\"dt_txt\":\"2019-07-11 23:00:00\"}],\"city\":{\"id\":2696650,\"name\":\"Alvik\",\"coord\":{\"lat\":60.7477,\"lon\":14.8746 },\"country\":\"SE\",\"population\":5861,\"timezone\":7200} }"; var weather = ForecastAPI.GetBestWeather("Alvik", json, 1).Weather; Assert.AreEqual("Fog", weather); }
public JsonResult GetWeatherForecast(string Destination, string DaysRange) { // Here we get latitude and longitude from the destination Geolocation geolocation = MapFunctions.Locate(Destination); string json = ""; int daysrange = int.Parse(DaysRange); // We use WebClient to get the information from the Open WeatheMap API using (WebClient web = new WebClient()) { var query = "http://api.openweathermap.org/data/2.5/forecast?lat=" + geolocation.Latitude + "&lon=" + geolocation.Longitude + "&appid=" + APIKEY; json = web.DownloadString(query); } return(Json(ForecastAPI.GetBestWeather(Destination, json, daysrange), JsonRequestBehavior.AllowGet)); }