From 20ab73af5e79f91a82fe0235b1554abe6774fff0 Mon Sep 17 00:00:00 2001 From: Dekalo Stanislav Date: Mon, 20 Oct 2014 21:50:13 +0300 Subject: [PATCH] Added rain and snow precipitation for daily forecast. --- .../java/api/owm/DailyForecastData.java | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/net/aksingh/java/api/owm/DailyForecastData.java b/src/net/aksingh/java/api/owm/DailyForecastData.java index fdd21e8..cda1647 100644 --- a/src/net/aksingh/java/api/owm/DailyForecastData.java +++ b/src/net/aksingh/java/api/owm/DailyForecastData.java @@ -535,6 +535,14 @@ public class DailyForecastData { * Key for JSON variable Percentage of clouds */ private final String JSON_FORECAST_CLOUDS = "clouds"; + /** + * Key for JSON variable Rain precipitation + */ + private final String JSON_FORECAST_RAIN = "rain"; + /** + * Key for JSON variable Snow precipitation + */ + private final String JSON_FORECAST_SNOW = "snow"; /** * Pressure @@ -556,6 +564,14 @@ public class DailyForecastData { * Percentage of clouds */ private final float cloudsPercent; + /** + * Precipitation of rain in mm. + */ + private final float rain; + /** + * Precipitation of snow in mm. + */ + private final float snow; private final Temperature temp; @@ -567,7 +583,6 @@ public class DailyForecastData { * Count (number) of elements in list of weather information */ private final int weatherListCount; - /** * Non-parameterized constructor *

@@ -586,6 +601,8 @@ public class DailyForecastData { this.windSpeed = Float.NaN; this.windDegree = Float.NaN; this.cloudsPercent = Float.NaN; + this.rain = Float.NaN; + this.snow = Float.NaN; this.temp = new Temperature(); @@ -611,6 +628,8 @@ public class DailyForecastData { this.windSpeed = (jsonObj != null) ? (float) jsonObj.optDouble(this.JSON_FORECAST_WIND_SPEED, Double.NaN) : Float.NaN; this.windDegree = (jsonObj != null) ? (float) jsonObj.optDouble(this.JSON_FORECAST_WIND_DEGREE, Double.NaN) : Float.NaN; this.cloudsPercent = (jsonObj != null) ? (float) jsonObj.optDouble(this.JSON_FORECAST_CLOUDS, Double.NaN) : Float.NaN; + this.rain = (jsonObj != null) ? (float) jsonObj.optDouble(this.JSON_FORECAST_RAIN, Double.NaN) : Float.NaN; + this.snow = (jsonObj != null) ? (float) jsonObj.optDouble(this.JSON_FORECAST_SNOW, Double.NaN) : Float.NaN; JSONArray jsonArrWeather = (jsonObj != null) ? jsonObj.optJSONArray(this.JSON_WEATHER) : null; this.weatherList = (jsonArrWeather != null) ? new ArrayList(jsonArrWeather.length()) : Collections.EMPTY_LIST; @@ -645,6 +664,14 @@ public class DailyForecastData { return (this.cloudsPercent != Float.NaN); } + public boolean hasRain() { + return (this.rain != Float.NaN); + } + + public boolean hasSnow() { + return (this.snow != Float.NaN); + } + public float getHumidity() { return this.humidity; } @@ -665,6 +692,14 @@ public class DailyForecastData { return this.cloudsPercent; } + public float getRain() { + return this.rain; + } + + public float getSnow() { + return this.snow; + } + // Objects public Temperature getTemperature_Object() { return this.temp;