-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeteo.pde
134 lines (132 loc) · 4.34 KB
/
meteo.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
XML xml;
PrintWriter output;
String[] result;
String value, min, max, value2, name, risestr, setstr, sunrise, sunset, sunriseHour, sunsetHour, value3, number, icon;
void meteo()
{
if((run_once == true || minute()%10==0 && second()==0 && frameCount%30==0) && erreurGoogle != true)
{
if(netLaunch != true)
{
result = loadStrings(weatherLink);
netLaunch = false;
}
output = createWriter("data/text/meteo.xml");
for(int i=0; i<result.length; i++)
{
output.println(result[i]);
}
output.flush(); // Writes the remaining data to the file
output.close(); // Finishes the file
xml = loadXML("data/text/meteo.xml");
XML[] children2 = xml.getChildren("clouds");
XML[] children = xml.getChildren("temperature");
XML[] children3 = xml.getChildren("city");
XML[] children4 = children3[0].getChildren("sun");
XML[] children5 = xml.getChildren("weather");
for (int i = 0; i < children.length; i++)
{
value = children[i].getString("value");
min = children[i].getString("min");
max = children[i].getString("max");
}
for (int i=0; i<children2.length; i++)
{
value2 = children2[i].getString("value");
name = children2[i].getString("name");
}
for (int i=0; i<children4.length; i++)
{
risestr = children4[i].getString("rise");
setstr = children4[i].getString("set");
sunriseHour = str(Integer.parseInt(risestr.substring(risestr.indexOf("T")+1,risestr.indexOf(":")))+2);
sunsetHour = str(Integer.parseInt(setstr.substring(setstr.indexOf("T")+1,setstr.indexOf(":")))+2);
sunrise = sunriseHour +"h"+ risestr.substring(risestr.indexOf(":")+1,risestr.length());
sunset = sunsetHour +"h"+ setstr.substring(setstr.indexOf(":")+1,setstr.length());
}
for (int i = 0; i < children5.length; i++)
{
value3 = children5[i].getString("value");
icon = children5[i].getString("icon");
}
if(value == null)
{
value = "";
}
if(min == null)
{
min = "";
}
if(max == null)
{
max = "";
}
if(sunrise == null)
{
sunrise = "";
}
if(sunset == null)
{
sunset = "";
}
}
if(erreurGoogle != true)
{
textFont(Thin48);
text("T° actuelle : "+value,xref+width*5/3 - textWidth("T° actuelle : "+value)/2,yref + 100);
text("T° minimale : "+min,xref+width*5/3 - textWidth("T° actuelle : "+value)/2,yref + 150);
text("T° maximale : "+max,xref+width*5/3 - textWidth("T° actuelle : "+value)/2,yref+200);
text("Lever de soleil : "+sunrise,xref+width*3/2-textWidth("Lever de soleil : "+sunrise)/2,yref+250);
text("Coucher de soleil : "+sunset,xref+width*3/2-textWidth("Coucher de soleil : "+sunset)/2,yref+300);
tint(255,255);
if(icon.equals("01d")==true)
{
image(Soleil,xref+width*3/2-512/2,yref+height/2-512/2);
}
else if(icon.equals("02d")==true)
{
image(Fewclouds,xref+width*3/2-512/2,yref+height/2-512/2);
}
else if(icon.equals("03d")==true || icon.equals("03n")==true)
{
image(Scatteredclouds,xref+width*3/2-512/2,yref+height/2-512/2);
}
else if (icon.equals("04d")==true || icon.equals("04n")==true)
{
image(Brokenclouds,xref+width*3/2-512/2,yref+height/2-512/2);
}
else if(icon.equals("09d")==true || icon.equals("09n")==true)
{
image(Pluiediluvienne,xref+width*3/2-512/2,yref+height/2-512/2);
}
else if(icon.equals("10d")==true || icon.equals("10n")==true)
{
image(Pluiefine,xref+width*3/2-512/2,yref+height/2-512/2);
}
else if(icon.equals("11d")==true || icon.equals("11n")==true)
{
image(Orageviolent,xref+width*3/2-512/2,yref+height/2-512/2);
}
else if(icon.equals("13d")==true || icon.equals("13n")==true)
{
image(Snow,xref+width*3/2-512/2,yref+height/2-512/2);
}
else if(icon.equals("50d")==true || icon.equals("50n")==true)
{
image(Brouillard,xref+width*3/2-512/2,yref+height/2-512/2);
}
else if(icon.equals("01n")==true)
{
image(moon,xref+width*3/2-512/2,yref+height/2-512/2);
}
else if(icon.equals("02n")==true)
{
image(nightClouds,xref+width*3/2-512/2,yref+height/2-512/2);
}
}
else
{
textFont(Thin48);
text("Connexion internet indisponible...", xref+width*3/2-textWidth("Connexion internet indisponible...")/2, yref+200);
}
}