private static Common.Weather.WeatherPointData ConvertToWeatherPointData(Weather source) { var destination = new Common.Weather.WeatherPointData(); destination.Temperature = new Common.Weather.Temperature { Celsius = source.Temperature }; destination.DewPoint = new Common.Weather.Temperature { Celsius = source.DewPoint }; destination.Pressure = source.Pressure; destination.WindDirection = source.WindDirection; destination.WindSpeed = source.WindSpeed; destination.Visibility = source.Visibility; if (source.Precipitation > 0) { destination.Precipitation = source.Precipitation; } destination.Ozone = source.Ozone; destination.Humidity = source.Humidity; destination.CloudCover = source.CloudCover; return destination; }
private static Common.Weather.WeatherPointData ConvertToWeatherPointData(CurrentWeatherResponse source) { var destination = new Common.Weather.WeatherPointData(); if (source.Main != null) { destination.Pressure = source.Main.Pressure; if (source.Main.Temperature.HasValue) { destination.Temperature = new Temperature() { Kelvin = source.Main.Temperature.Value }; } destination.Humidity = source.Main.Humidity; if (source.Clouds != null) { destination.CloudCover = source.Clouds.CloudCover; } if (source.WeatherConditions != null && source.WeatherConditions.Count > 0) { destination.Condition = ConvertToWeatherCondition(source.WeatherConditions[0].Id); } else { destination.Condition = WeatherCondition.Unknown; } if (source.Wind != null) { destination.WindDirection = source.Wind.Direction; destination.WindSpeed = source.Wind.Speed; } if (source.Snow != null) { destination.PrecipitationType = PrecipitationType.Snow; destination.Precipitation = source.Snow.Last3Hours; } else if (source.Rain != null) { destination.PrecipitationType = PrecipitationType.Rain; destination.Precipitation = source.Rain.Last3Hours; } destination.DewPoint = null; destination.FeltHumidity = null; destination.FeltIntensity = null; destination.FeltTemperature = null; destination.FeltVisibility = null; destination.FeltWindIntensity = null; destination.Ozone = null; destination.Visibility = null; destination.WindChill = null; } return destination; }
private static Common.Weather.WeatherPointData ConvertToWeatherPointData(HourlyWeather source) { var destination = new Common.Weather.WeatherPointData(); if (source.Main != null) { destination.Pressure = source.Main.Pressure; if (source.Main.Temperature.HasValue) { destination.Temperature = new Temperature() { Kelvin = source.Main.Temperature.Value }; } } destination.Humidity = source.Main.Humidity; if (source.WeatherConditions != null && source.WeatherConditions.Count > 0) { destination.Condition = ConvertToWeatherCondition(source.WeatherConditions[0].Id); } else { destination.Condition = WeatherCondition.Unknown; } destination.DewPoint = null; destination.FeltHumidity = null; destination.FeltIntensity = null; destination.FeltTemperature = null; destination.FeltVisibility = null; destination.FeltWindIntensity = null; destination.Ozone = null; destination.Visibility = null; destination.WindChill = null; return destination; }