Simulation von Bürgern
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Weather.pde 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. PVector v2_coordinates = new PVector(48.799337, 9.794482); //badmauer; x: latitude, y: longitude
  2. boolean b_isRaining;
  3. String S_sunrise;
  4. String S_sunset;
  5. Date d_sunrise;
  6. void initWeather(){
  7. //sunrise / sunset API: https://sunrise-sunset.org/api
  8. JSONObject sun;
  9. if(b_loadSun) sun = loadJSONObject("https://api.sunrise-sunset.org/json?lat=" + v2_coordinates.x + " &lng=" + v2_coordinates.y);
  10. else sun = loadJSONObject(dataPath("weather/today.json"));
  11. //println(sun);
  12. if (sun == null) {
  13. //println("JSONObject could not be parsed");
  14. } else {
  15. JSONObject results = sun.getJSONObject("results");
  16. S_sunrise = results.getString("sunrise");
  17. S_sunset = results.getString("sunset");
  18. }
  19. }
  20. /* backup json today (if api has yet to encounter limits)
  21. {
  22. "results": {
  23. "sunrise": "7:13:29 AM",
  24. "solar_noon": "11:25:52 AM",
  25. "day_length": "08:24:45",
  26. "astronomical_twilight_end": "5:33:03 PM",
  27. "astronomical_twilight_begin": "5:18:41 AM",
  28. "sunset": "3:38:14 PM",
  29. "civil_twilight_end": "4:14:48 PM",
  30. "nautical_twilight_end": "4:54:50 PM",
  31. "civil_twilight_begin": "6:36:55 AM",
  32. "nautical_twilight_begin": "5:56:54 AM"
  33. },
  34. "status": "OK"
  35. }
  36. */