Example #1
0
        public HourlyForecast(string description, double avgTemp, double feelTemp, double snowFall, double rainFall, int pressure, int humidity, double windSpeed,
                              int windAngle, string icon, string country = null, string cityName = null, string cityId = null, long?sunsetTime = null, long?sunriseTime = null,
                              double?longitude = null, double?latitude = null, string descriptionId = null, DateTime?date = null, long?dayTime = null)
        {
            PrepareDictionaries(Language.Polish, description, descriptionId, date, dayTime);
            PrepareDictionaries(Language.English, description, descriptionId, date, dayTime);

            Language      = Language.Polish;
            Units         = Units.Metric;
            DescriptionId = descriptionId;
            CityName      = cityName;
            CityId        = cityId;
            AvgTemp       = Convert.ToInt32(avgTemp);
            FeelTemp      = Convert.ToInt32(feelTemp);
            SnowFall      = Math.Round(Convert.ToDouble(snowFall), 1);
            RainFall      = Math.Round(Convert.ToDouble(rainFall), 1);
            WindAngle     = Convert.ToInt32(windAngle - 180);
            Icon          = icon;
            SunsetTime    = sunsetTime != null ? (GlobalUtils.UnixTimeStampToDateTime(sunsetTime.Value) + DateTimeOffset.Now.Offset).ToString("HH:mm") : null;
            SunriseTime   = sunriseTime != null ? (GlobalUtils.UnixTimeStampToDateTime(sunriseTime.Value) + DateTimeOffset.Now.Offset).ToString("HH:mm") : null;
            Longitude     = longitude != null?GlobalUtils.ConvertCoordinatesFromDecToDeg(longitude.Value, true) : null;

            Latitude = latitude != null?GlobalUtils.ConvertCoordinatesFromDecToDeg(latitude.Value, false) : null;

            Pressure  = Convert.ToInt32(pressure);
            Humidity  = Convert.ToInt32(humidity);
            Country   = country;
            WindSpeed = Convert.ToInt32(windSpeed * 3.6);
        }
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     return(GlobalUtils.ConvertCoordinatesFromDecToDeg(System.Convert.ToDouble(value?.ToString().Replace(",", "."), CultureInfo.InvariantCulture), false));
 }