From b988541d15b6ab23923c869fc08d1e3901709e3c Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Fri, 4 Jan 2019 10:12:55 +0100 Subject: [PATCH] implemented sunrise / sunset --- Weather.pde | 29 +++++++++++++++++++++++++++++ data/weather/today.json | 15 +++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 data/weather/today.json diff --git a/Weather.pde b/Weather.pde index 07e03f7..13382e6 100644 --- a/Weather.pde +++ b/Weather.pde @@ -1 +1,30 @@ +//sunrise / sunset API: https://sunrise-sunset.org/api +PVector v2_coordinates = new PVector(48.799337, 9.794482); //badmauer; x: latitude, y: longitude + boolean b_isRaining; + +void initWeather(){ + JSONObject sun; + if(b_loadSun) sun = loadJSONObject("https://api.sunrise-sunset.org/json?lat=" + v2_coordinates.x + " &lng=" + v2_coordinates.y); + else sun = loadJSONObject(dataPath("weather/today.json")); + println(sun); + +} + +/* backup json today (if api has yet to encounter limits) +{ + "results": { + "sunrise": "7:13:29 AM", + "solar_noon": "11:25:52 AM", + "day_length": "08:24:45", + "astronomical_twilight_end": "5:33:03 PM", + "astronomical_twilight_begin": "5:18:41 AM", + "sunset": "3:38:14 PM", + "civil_twilight_end": "4:14:48 PM", + "nautical_twilight_end": "4:54:50 PM", + "civil_twilight_begin": "6:36:55 AM", + "nautical_twilight_begin": "5:56:54 AM" + }, + "status": "OK" +} +*/ diff --git a/data/weather/today.json b/data/weather/today.json new file mode 100644 index 0000000..0b53456 --- /dev/null +++ b/data/weather/today.json @@ -0,0 +1,15 @@ +{ + "results": { + "sunrise": "7:13:29 AM", + "solar_noon": "11:25:52 AM", + "day_length": "08:24:45", + "astronomical_twilight_end": "5:33:03 PM", + "astronomical_twilight_begin": "5:18:41 AM", + "sunset": "3:38:14 PM", + "civil_twilight_end": "4:14:48 PM", + "nautical_twilight_end": "4:54:50 PM", + "civil_twilight_begin": "6:36:55 AM", + "nautical_twilight_begin": "5:56:54 AM" + }, + "status": "OK" +}