private static Common.Weather.WeatherPoint ConvertToWeatherPoint(WeatherCurrentCondition source, WeatherArea area) {
            var destination = new Common.Weather.WeatherPoint();

            if (area != null) {
                destination.Location = new Common.Weather.Location();
                destination.Location.Country = area.Country;
                destination.Location.Locality = area.AreaName;
                destination.Location.Latitude = area.Latitude;
                destination.Location.Longitude = area.Longitude;
            }

            destination.Weather = new Common.Weather.WeatherPointData();
            destination.Weather.Condition = ConvertToWeatherCondition(source.WeatherCode);
            if (source.TemperatureCelsius.HasValue) {
                destination.Weather.Temperature = new Common.Weather.Temperature() { Celsius = source.TemperatureCelsius.Value };
            } else if (source.TemperatureFahrenheit.HasValue) {
                destination.Weather.Temperature = new Common.Weather.Temperature() { Fahrenheit = source.TemperatureFahrenheit.Value };
            }
            destination.Weather.Humidity = source.Humidity;
            destination.Weather.Pressure = source.Pressure;
            destination.Weather.WindDirection = source.WindDirection;
            destination.Weather.WindSpeed = source.WindspeedKmph;
            if (source.Precipitation.GetValueOrDefault(0) > 0) {
                destination.Weather.PrecipitationType = Common.Weather.PrecipitationType.Rain;
                destination.Weather.Precipitation = source.Precipitation;
            }
            destination.Weather.Visibility = source.Visibility;
            destination.Weather.CloudCover = source.CloudCover;

            return destination;
        }
        private static Common.Weather.WeatherPeriod ConvertToWeatherPeriod(WeatherForecast source, WeatherArea area) {
            var destination = new Common.Weather.WeatherPeriod();
            destination.TimeFrom = source.Date.ToUniversalTime().ToLocalTime();
            destination.TimeTo = destination.TimeFrom.AddDays(1);

            if (area != null) {
                destination.Location = new Common.Weather.Location();
                destination.Location.Country = area.Country;
                destination.Location.Locality = area.AreaName;
                destination.Location.Latitude = area.Latitude;
                destination.Location.Longitude = area.Longitude;
            }

            destination.Weather = new Common.Weather.WeatherPeriodData();
            destination.Weather.Condition = ConvertToWeatherCondition(source.WeatherCode);
            if (source.MinTemperatureCelsius.HasValue) {
                destination.Weather.MinTemperature = new Common.Weather.Temperature() { Celsius = source.MinTemperatureCelsius.Value };
            } else if (source.MinTemperatureFahrenheit.HasValue) {
                destination.Weather.MinTemperature = new Common.Weather.Temperature() { Fahrenheit = source.MinTemperatureFahrenheit.Value };
            }
            if (source.MaxTemperatureCelsius.HasValue) {
                destination.Weather.MaxTemperature = new Common.Weather.Temperature() { Celsius = source.MaxTemperatureCelsius.Value };
            } else if (source.MaxTemperatureFahrenheit.HasValue) {
                destination.Weather.MaxTemperature = new Common.Weather.Temperature() { Fahrenheit = source.MaxTemperatureFahrenheit.Value };
            }
            destination.Weather.WindDirection = source.WindDirection;
            destination.Weather.WindSpeed = source.WindspeedKmph;
            destination.Weather.Precipitation = source.Precipitation;

            return destination;
        }
Exemple #3
0
 public void SetUpParent()
 {
     parent = GetComponentInParent <WeatherArea>();
     if (rainMaker != null)
     {
         rainMaker.Stop();
         var rainMain = rainMaker.main;
         rainMain.duration = parent.GetWeatherTimer() - 10.0f;
         rainMaker.Play();
     }
     if (fogMachine != null)
     {
         fogMachine.Stop();
         var fogMain = fogMachine.main;
         fogMain.duration = parent.GetWeatherTimer() - 10.0f;
         fogMachine.Play();
     }
     windDir = parent.GetWindDir();
 }