implemented sunrise / sunset
This commit is contained in:
29
Weather.pde
29
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"
|
||||
}
|
||||
*/
|
||||
|
||||
15
data/weather/today.json
Normal file
15
data/weather/today.json
Normal file
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user