private async Task <SMHIModel> GetWeatherDataAsync(Coordinate coordinate) { var model = new SMHIModel(); var lon = coordinate.Longitude.ToString().Replace(",", "."); var lat = coordinate.Latitude.ToString().Replace(",", "."); var url = $"{ApiUrl}{Constants.ApiMockUrl}/Weather/Point/lon/{lon}/lat/{lat}"; var res = await HttpManager.GetAsync(url); var obj = JsonConvert.DeserializeObject <SmhiGetPoint>(res); var earliestWeatherPrognosis = obj.timeSeries.OrderBy(a => a.validTime).FirstOrDefault(); var earliestWeatherPrognosisTemp = earliestWeatherPrognosis.parameters.Where(b => b.name == "t").FirstOrDefault(); model.ValidTime = earliestWeatherPrognosis.validTime; model.Temperature = decimal.Parse(earliestWeatherPrognosisTemp.values.FirstOrDefault(), CultureInfo.InvariantCulture); return(model); }
public static WeatherSymbol GetNowWeatherSymbol(this SMHIModel m) { Parameter param = GetParameterByName(m.timeSeries[0].parameters, "Wsymb2"); return((WeatherSymbol)param.values[0]); }
public static float GetNowTemperature(this SMHIModel m) { Parameter param = GetParameterByName(m.timeSeries[0].parameters, "t"); return(param.values[0]); }