diff --git a/app/src/main/java/de/apps4ics/mountainnavigation/SimpleOpenWeatherApi.java b/app/src/main/java/de/apps4ics/mountainnavigation/SimpleOpenWeatherApi.java deleted file mode 100644 index 0a27c68..0000000 --- a/app/src/main/java/de/apps4ics/mountainnavigation/SimpleOpenWeatherApi.java +++ /dev/null @@ -1,220 +0,0 @@ -package de.apps4ics.mountainnavigation; - -import android.util.Log; - -import java.util.HashMap; -import java.util.Map; - -/** - * Created by Vinz on 04.10.2015. - */ -public class SimpleOpenWeatherApi { - private static final String WEATHER_API_URL = "http://api.openweathermap.org/data/2.5/weather"; - private static final String HISTORIC_WEATHER_API_URL = "http://api.openweathermap.org/data/2.5/history/city"; - //private Map parameterList; - - public SimpleOpenWeatherApi(){ - } - - public Weather getCurrentWeather(String cityId){ - return getCurrentWeather(cityId, 3, 1); - } - - public Weather getCurrentWeather(double lat, double lon){ - return getCurrentWeather(lat, lon, 3, 1); - } - - public Weather getCurrentWeather(String cityId, int numDays, int maxCities){ - Weather weather = new Weather(); - //TODO - return weather; - } - - public Weather getCurrentWeather(double lat, double lon, int numDays, int maxCities){ - Weather weather = new Weather(); - //TODO - return weather; - } - - public Weather getHistoricalWeather(String cityId){ - return getHistoricalWeather(cityId, 3, 1); - } - - public Weather getHistoricalWeather(String cityId, int numDays, int maxCities){ - Weather weather = new Weather(); - //TODO - return weather; - } - - public Weather getHistoricalWeather(double lat, double lon){ - return getHistoricalWeather(lat, lon, 3, 1); - } - - public Weather getHistoricalWeather(double lat, double lon, long start, long end){ - String options = String.format("lat=%f&lon=%f&type=hour&start=%d&end=%d", lat, lon, start, end); - Map parameterList = parseUrlToParameterList(HISTORIC_WEATHER_API_URL + "?" + options ); - return addParameterListToWeather(parameterList); - } - - private Map parseUrlToParameterList(String Url){ - Map parameterList = new HashMap<>(); - //TODO - return parameterList; - } - - private Weather addParameterListToWeather(Map parameterList){ - Weather weather = new Weather(); - //TODO - return weather; - } - - private String getParameter(Map parameterList, String key){ - String value = parameterList.get(key); - try { - if(value == null) throw new ParameterNotFoundException(); - } catch (ParameterNotFoundException pnfe){ - pnfe.printStackTrace(); - //TODO - } - return value; - } -} - -class ParameterNotFoundException extends Exception { - public ParameterNotFoundException(){ - - } - - public ParameterNotFoundException(String message){ - super(message); - } -} -/* -{"coord":{"lon":9.05,"lat":48.52},"weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04d"}] -,"base":"cmc stations","main":{"temp":286.31,"pressure":1019,"humidity":87,"temp_min":282.04,"temp_max":289.26}, -"wind":{"speed":1.5,"deg":140},"clouds":{"all":75},"dt":1443962615,"sys":{"type":1,"id":4891,"message":0.0042, -"country":"DE","sunrise":1443936456,"sunset":1443977789},"id":2820860,"name":"Tuebingen","cod":200} - */ -class Weather { - private double latitude; - private double longitude; - private float temp; - private float minTemp; - private float maxTemp; - private int weatherId; - private float pressure; - private float humidity; - //private ??? wind; TODO - private long time; - private String cityName; - private String country; - private String sunrise; - private String sunset; - public Weather(){ - - } - - public String getSunset() { - return sunset; - } - - public double getLatitude() { - return latitude; - } - - public double getLongitude() { - return longitude; - } - - public float getTemp() { - return temp; - } - - public float getMinTemp() { - return minTemp; - } - - public float getMaxTemp() { - return maxTemp; - } - - public int getWeatherId() { - return weatherId; - } - - public float getPressure() { - return pressure; - } - - public float getHumidity() { - return humidity; - } - - public long getTime() { - return time; - } - - public String getCityName() { - return cityName; - } - - public String getCountry() { - return country; - } - - public String getSunrise() { - return sunrise; - } - - public void setLatitude(double latitude) { - this.latitude = latitude; - } - - public void setLongitude(double longitude) { - this.longitude = longitude; - } - - public void setTemp(float temp) { - this.temp = temp; - } - - public void setMinTemp(float minTemp) { - this.minTemp = minTemp; - } - - public void setMaxTemp(float maxTemp) { - this.maxTemp = maxTemp; - } - - public void setWeatherId(int weatherId) { - this.weatherId = weatherId; - } - - public void setPressure(float pressure) { - this.pressure = pressure; - } - - public void setHumidity(float humidity) { - this.humidity = humidity; - } - - public void setTime(long time) { - this.time = time; - } - - public void setCityName(String cityName) { - this.cityName = cityName; - } - - public void setCountry(String country) { - this.country = country; - } - - public void setSunrise(String sunrise) { - this.sunrise = sunrise; - } - - public void setSunset(String sunset) { - this.sunset = sunset; - } -}