예제 #1
0
        internal static List <WeatherForecastProjection> ConvertToWeatherForecastProjections(Rp5WeatherForecastRootObject deserializeObject)
        {
            var result = new List <WeatherForecastProjection>();

            foreach (var forecastItems in deserializeObject.Response.Forecast.Items)
            {
                foreach (var forecastItem in forecastItems)
                {
                    result.Add(new WeatherForecastProjection
                    {
                        ForecastDateTime = ModelExtensions.UnixTimeStampToDateTime(forecastItem.Gmt, false),
                        Temperature      = new TemperatureProjection {
                            Celsius = forecastItem.Temperature.C, Fahrenheit = forecastItem.Temperature.F
                        },
                        FeelTemperature = new TemperatureProjection {
                            Celsius = forecastItem.FeelTemperature.C, Fahrenheit = forecastItem.FeelTemperature.F
                        },
                        Cloudiness =
                            new CloudinessProjection
                        {
                            Percents = forecastItem.CloudCover.Pct,
                            Decimal  = forecastItem.CloudCover.Decimal,
                            Oktas    = forecastItem.CloudCover.Oktas
                        },
                        WindSpeed =
                            new WindProjection
                        {
                            Ms    = forecastItem.WindVelocity.Ms,
                            Kmh   = forecastItem.WindVelocity.Kmh,
                            Mph   = forecastItem.WindVelocity.Mph,
                            Knots = forecastItem.WindVelocity.Knots,
                            Bft   = forecastItem.WindVelocity.Bft
                        },
                        WindGusts =
                            new WindProjection
                        {
                            Ms    = forecastItem.WindGusts.Ms,
                            Kmh   = forecastItem.WindGusts.Kmh,
                            Mph   = forecastItem.WindGusts.Mph,
                            Knots = forecastItem.WindGusts.Knots,
                            Bft   = forecastItem.WindGusts.Bft
                        },
                        Pressure =
                            new PressureProjection
                        {
                            Hpa  = forecastItem.Pressure.Hpa,
                            Inhg = forecastItem.Pressure.Inhg,
                            Mbar = forecastItem.Pressure.Mbar,
                            Mmhg = forecastItem.Pressure.Mmhg
                        },
                        Precipitation = new PrecipitationProjection {
                            Mm = forecastItem.Precipitation.Mm, Inches = forecastItem.Precipitation.Inches
                        },
                        PrecipitationType = (PrecipitationType)forecastItem.PrecipitationType,
                        WindDirection     = GetWindDirection(forecastItem.WindDirection),
                        Humidity          = forecastItem.Humidity,
                        Sunrise           = ModelExtensions.UnixTimeStampToDateTime(forecastItem.Sunrise, false),
                        Sunset            = ModelExtensions.UnixTimeStampToDateTime(forecastItem.Sunset, false)
                    });
                }
            }
            return(result);
        }