//------------------------------------------------------------------------------------------------ //------------------------------------Tomorrow's Weather------------------------------------------ //------------------------------------------------------------------------------------------------ public static void UpdateTomorrowsWeather() { //Read tomorrows weather data and process it into Tomorrow TomorrowsWeatherData tomorrowsData = ReadTomorrowsWeatherInformation(); if (tomorrowsData != null) { ProcessTomorrowsWeatherData(tomorrowsData); } }
private static void ProcessTomorrowsWeatherData(TomorrowsWeatherData tomorrowsData) { //Begin by clearing the list of tomorrows forecast Tomorrow.Clear(); //Init a high and low to ranges beyond what will ever be hit double daysHigh = -200, daysLow = 200; //Iterate through all weather data retrieved for (int i = 1; i < tomorrowsData.cnt; i++) { //Convert the UnixTime value to strings representing the day and time string date = ConvertUnixTimeToDate(tomorrowsData.list[i].dt); string time = ConvertUnixTimeToTime(tomorrowsData.list[i].dt); //If the current result is for tomorrow, process it and store it in Tomorrow if (ValidTimeTomorrow(date)) { TomorrowsWeather weather = new TomorrowsWeather(time); weather.SetWeather(tomorrowsData.list[i].weather[0].main); weather.SetWeatherIcon(tomorrowsData.list[i].weather[0].icon); weather.SetTemperature(tomorrowsData.list[i].main.temp); double low = tomorrowsData.list[i].main.temp_min; double high = tomorrowsData.list[i].main.temp_max; if (low < daysLow) { daysLow = low; } if (high > daysHigh) { daysHigh = high; } Tomorrow.Add(weather); } } //After processing all data we should have the accurate high and low, store them as strings TomorrowsHigh = Math.Round(daysHigh).ToString(); TomorrowsLow = Math.Round(daysLow).ToString(); }