diff --git a/app/src/main/java/de/apps4ics/mountainnavigation/MyWeather.java b/app/src/main/java/de/apps4ics/mountainnavigation/MyWeather.java index 06d1650..b24192b 100644 --- a/app/src/main/java/de/apps4ics/mountainnavigation/MyWeather.java +++ b/app/src/main/java/de/apps4ics/mountainnavigation/MyWeather.java @@ -1,28 +1,113 @@ package de.apps4ics.mountainnavigation; +import android.location.Location; + import com.survivingwithandroid.weather.lib.model.DayForecast; -import com.survivingwithandroid.weather.lib.model.HistoricalWeather; import com.survivingwithandroid.weather.lib.model.Weather; -import com.survivingwithandroid.weather.lib.model.WeatherForecast; /** * Created by Vinz on 07.03.2016. */ public class MyWeather { - - public MyWeather(HistoricalWeather historicalWeather) { - ; //TODO - } - - public MyWeather(WeatherForecast weatherForecast) { - ; //TODO - } + private long timestamp; + private float minTemp; + private float maxTemp; + private Location location; + private long sunrise; + private long sunset; + private int weatherId; //OWM id + private int weatherCode; //OWM code + private float pressure; + private float humidity; + private float windSpeed; + private float windDir; + private int clouds; //percent of cloudiness + private float rain; //rain volume for the last 3 hours + private float snow; //snow volume for the last 3 hours public MyWeather(DayForecast dayForecast) { - ; //TODO + this(dayForecast.weather, dayForecast.timestamp); } - public MyWeather(Weather weather) { - ; //TODO + public MyWeather(Weather weather, long timestamp) { + this.timestamp = timestamp; + if(weather.location != null) { + location = new Location(""); + location.setLatitude(weather.location.getLatitude()); + location.setLongitude(weather.location.getLongitude()); + } + minTemp = weather.temperature.getMinTemp() > 0 ? weather.temperature.getMinTemp() : -1; + maxTemp = weather.temperature.getMaxTemp() > 0 ? weather.temperature.getMaxTemp() : -1; + sunrise = weather.location.getSunrise() > 0 ? weather.location.getSunrise() : -1; + sunset = weather.location.getSunset() > 0 ? weather.location.getSunset() : -1; + weatherId = weather.currentCondition.getWeatherId() > 0 ? weather.currentCondition.getWeatherId() : -1; + weatherCode = weather.currentCondition.getWeatherCode().getCode() > 0 ? weather.currentCondition.getWeatherCode().getCode() : -1; + pressure = weather.currentCondition.getPressure() > 0 ? weather.currentCondition.getPressure() : -1; + humidity = weather.currentCondition.getHumidity() > 0 ? weather.currentCondition.getHumidity() : -1; + windSpeed = weather.wind.getSpeed() > 0 ? weather.wind.getSpeed() : -1; + windDir = weather.wind.getDeg() > 0 ? weather.wind.getDeg() : -1; + clouds = weather.clouds.getPerc() > 0 ? weather.clouds.getPerc() : -1; + rain = weather.rain[0].getAmmount() > 0 ? weather.rain[0].getAmmount() : -1; + snow = weather.snow.getAmmount() > 0 ? weather.snow.getAmmount() : -1; + } + + public int getClouds() { + return clouds; + } + + public float getHumidity() { + return humidity; + } + + public Location getLocation() { + return location; + } + + public float getMaxTemp() { + return maxTemp; + } + + public float getMinTemp() { + return minTemp; + } + + public float getPressure() { + return pressure; + } + + public float getRain() { + return rain; + } + + public float getSnow() { + return snow; + } + + public long getSunrise() { + return sunrise; + } + + public long getSunset() { + return sunset; + } + + public long getTimestamp() { + return timestamp; + } + + public int getWeatherCode() { + return weatherCode; + } + + public long getWeatherId() { + return weatherId; + } + + public float getWindDir() { + return windDir; + } + + public float getWindSpeed() { + return windSpeed; } }