public List <DarkSkyDaily> getForecastDaily(string city)
        {
            OpenWeatherMapController openWeatherMap = new OpenWeatherMapController();
            OpenWeatherCoordinate    coords         = openWeatherMap.getCoordinates(city);
            List <DarkSkyDaily>      forecast       = new List <DarkSkyDaily>();

            restClient.endpoint = darkSkyEndpoint.getForecastEndpoint(coords.lon, coords.lat);

            string response = restClient.makeRequest();

            JSONParser <DarkSkyForecastModel> jsonParser = new JSONParser <DarkSkyForecastModel>();

            var deserialisedModelList = jsonParser.parseJSON(response, Parser.Version.NETCore2);

            foreach (DarkSkyDailyData deserialisedModel in deserialisedModelList.daily.data)
            {
                forecast.Add(new DarkSkyDaily(
                                 deserialisedModel.time,
                                 deserialisedModel.temperatureHigh,
                                 deserialisedModel.temperatureLow)
                             );
            }

            return(forecast);
        }
예제 #2
0
        public OpenWeather ConvertOpenWeatherDtoInOpenWeather(OpenWeatherDto weatherDto)
        {
            OpenWeatherCoordinate coordinate = new OpenWeatherCoordinate(
                weatherDto.Coord.Lon,
                weatherDto.Coord.Lat);

            OpenWeatherMain weatherMain = new OpenWeatherMain(
                weatherDto.Main.Temp,
                weatherDto.Main.FeelsLike,
                weatherDto.Main.TempMin,
                weatherDto.Main.TempMax,
                weatherDto.Main.Pressure,
                weatherDto.Main.Humidity);

            OpenWeather openWeather = new OpenWeather(
                weatherDto.Base,
                weatherDto.Visibility,
                weatherDto.Dt,
                weatherDto.Timezone,
                weatherDto.Name,
                weatherDto.Cod);

            openWeather.AddCoordinate(coordinate);
            openWeather.AddWeatherMain(weatherMain);

            return(openWeather);
        }
        public DarkSky getForecastCurrentTemperature(string city)
        {
            OpenWeatherMapController openWeatherMap = new OpenWeatherMapController();
            OpenWeatherCoordinate    coords         = openWeatherMap.getCoordinates(city);

            restClient.endpoint = darkSkyEndpoint.getForecastEndpoint(coords.lon, coords.lat);

            string response = restClient.makeRequest();

            JSONParser <DarkSkyForecastModel> jsonParser = new JSONParser <DarkSkyForecastModel>();

            var deserialisedModelList = jsonParser.parseJSON(response, Parser.Version.NETCore2);

            return(new DarkSky(deserialisedModelList.currently.time, deserialisedModelList.currently.temperature));
        }
예제 #4
0
        public ClimaCell getCurrent(string city)
        {
            OpenWeatherMapController openWeatherMap = new OpenWeatherMapController();
            OpenWeatherCoordinate    coords         = openWeatherMap.getCoordinates(city);

            restClient.endpoint = climaCellEndpoint.getCurrentEndpoint(coords.lon, coords.lat);

            string response = restClient.makeRequest();

            JSONParser <ClimaCellCurrentModel> jsonParser = new JSONParser <ClimaCellCurrentModel>();

            var deserialisedModelList = jsonParser.parseJSON(response, Parser.Version.NETCore2);

            return(new ClimaCell(deserialisedModelList.observation_time.value, deserialisedModelList.temp.value));
        }
예제 #5
0
        public List <Weather2020> getForecast(string city)
        {
            OpenWeatherMapController openWeatherMap = new OpenWeatherMapController();
            OpenWeatherCoordinate    coords         = openWeatherMap.getCoordinates(city);
            List <Weather2020>       forecast       = new List <Weather2020>();

            restClient.endpoint = weather2020Endpoint.getForecastEndpoint(coords.lon, coords.lat);
            string response = restClient.makeRequest();

            JSONParser <List <Weather2020Model> > jsonParser = new JSONParser <List <Weather2020Model> >();

            List <Weather2020Model> deserialisedModelList = jsonParser.parseJSON(response, Version.NETCore2);

            foreach (Weather2020Model deserialisedModel in deserialisedModelList)
            {
                forecast.Add(new Weather2020(deserialisedModel.startDate, deserialisedModel.temperatureHighCelcius, deserialisedModel.temperatureLowCelcius));
            }

            return(forecast);
        }
예제 #6
0
        public List <ClimaCellForecast> getForecast(string city)
        {
            OpenWeatherMapController openWeatherMap = new OpenWeatherMapController();
            OpenWeatherCoordinate    coords         = openWeatherMap.getCoordinates(city);
            List <ClimaCellForecast> forecast       = new List <ClimaCellForecast>();

            restClient.endpoint = climaCellEndpoint.getForecastEndpoint(coords.lon, coords.lat);

            string response = restClient.makeRequest();

            JSONParser <List <ClimaCellForecastModel> > jsonParser = new JSONParser <List <ClimaCellForecastModel> >();

            var deserialisedModelList = jsonParser.parseJSON(response, Parser.Version.NETCore2);

            foreach (ClimaCellForecastModel model in deserialisedModelList)
            {
                forecast.Add(new ClimaCellForecast(model.observation_time.value, model.temp));
            }

            return(forecast);
        }