Пример #1
0
        private static WeatherDay ProcessTodaysWeatherData(DaysWeatherData daysData, Location location)
        {
            WeatherDay today = new WeatherDay(DateTime.Now)
            {
                //Store tomorrow's date as 'long date' format: "Thursday, 10 April 2008"
                Date            = DateTime.Today,
                WeatherLocation = location
            };

            //Iterate through all weather data retrieved and create WeatherHour objects
            for (int i = 1; i < daysData.cnt; i++)
            {
                DateTime date = UnixTimeStampToDateTime(daysData.list[i].dt);
                //If the current result is for today, process it and store it in today
                if (ValidTimeToday(date))
                {
                    WeatherHour weather = new WeatherHour
                    {
                        Temperature = daysData.list[i].main.temp,
                        IconId      = daysData.list[i].weather[0].icon,
                        WeatherType = daysData.list[i].weather[0].main,
                        Time        = date
                    };
                    today.WeatherDays.Add(weather);
                }
            }
            return(today);
        }
Пример #2
0
        //--------------------------------------------------------------------------------
        //------------------------------End Current Weather-------------------------------
        //--------------------------------------------------------------------------------



        //--------------------------------------------------------------------------------
        //---------------------------------Today's Weather--------------------------------
        //--------------------------------------------------------------------------------
        //TODO set this method up to handle issues where the read fails.
        public static WeatherDay FetchTodaysWeather(Location location)
        {
            DaysWeatherData forecast = GetWeatherForecastData(location);
            WeatherDay      today    = null;

            if (forecast != null)
            {
                today = ProcessTodaysWeatherData(forecast, location);
            }
            return(today);
        }
Пример #3
0
        //--------------------------------------------------------------------------------
        //-------------------------------End Today's Weather------------------------------
        //--------------------------------------------------------------------------------



        //--------------------------------------------------------------------------------
        //-------------------------------Tomorrow's Weather-------------------------------
        //--------------------------------------------------------------------------------
        //TODO set this method up to handle issues where the read fails.
        public static WeatherDay FetchTomorrowsWeather(Location location)
        {
            //Read tomorrows weather data and process it into a Weather Day format
            DaysWeatherData forecast = GetWeatherForecastData(location);
            WeatherDay      tomorrow = null;

            if (forecast != null)
            {
                tomorrow = ProcessTomorrowsWeatherData(forecast, location);
            }
            return(tomorrow);
        }