-
Notifications
You must be signed in to change notification settings - Fork 1
/
sketch.js
221 lines (181 loc) · 4.28 KB
/
sketch.js
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
var map2D;
var map2D_1;
// Malargüe 35°28′28″S 69°35′07″O
var lat;
var lon;
var TOKEN = "pk.eyJ1IjoiZmVybmFuZGV6Z2ZnIiwiYSI6ImNqbmhtMndpbjBmZHEzdXF6YmU4aHR2cHkifQ.qeUjbXz-KdhtFf-1G_KRiQ";
var SIZE_IMGX = 1280;
var SIZE_IMGY = 1000;
var MAP_ZOOM = 1;
var OFFSET = 0;
var MAP_TYPE = "dark-v9";
//var locationData;
function preload(){
map2D = loadImage("https://api.mapbox.com/styles/v1/mapbox/" + MAP_TYPE + "/static/0,0," + MAP_ZOOM + ",0,0/" + SIZE_IMGX + "x" + SIZE_IMGY + "?access_token=" + TOKEN);
map2D_1 = loadImage("https://api.mapbox.com/styles/v1/mapbox/" + MAP_TYPE + "/static/0,0," + MAP_ZOOM + "," + OFFSET + ",0/" + SIZE_IMGX + "x" + SIZE_IMGY + "?access_token=" + TOKEN);
// Carga de JSON asociado a los satélites
loadSatellites();
// Carga de JSON asociado a los meteoritos
loadMeteorite();
// Carga de JSON asociado a los incendios
loadWildfire();
// Carga de JSON asociado a los terremotos
loadEarthquake();
// ACTUAL LOCATION OF THE USER
//locationData = getCurrentPosition();
}
var map1;
var map2;
var C_LAT = 0;
var C_LON = 0;
var Cx;
var Cy;
var Xg;
var Yg;
var x;
var y;
var canvas;
var b_fire;
var b_satellite;
var b_meteorite;
var b_earthquake;
var b_clean;
var mode_fire;
var mode_satellite;
var mode_meteorite;
var mode_earthquake;
var mode_clean;
function setup() {
b_satellite = select("#satellite");
b_satellite.mousePressed(mode_satellite);
flag_satellite = 0;
b_meteorite = select("#meteorite");
b_meteorite.mousePressed(mode_meteorite);
flag_meteorite = 0;
b_earthquake = select("#earthquake");
b_earthquake.mousePressed(mode_earthquake);
flag_earthquake = 0;
b_fire = select("#fire");
b_fire.mousePressed(mode_fire);
flag_fire = 0;
b_clean = select("#clean");
b_clean.mousePressed(mode_clean);
flag_clean = 0;
canvas = createCanvas(2* SIZE_IMGX, SIZE_IMGY);
canvas.position(0, 25);
canvas.style('z-index', '-1');
translate(width / 2, height / 2);
// imageMode(CENTER); Esto es de Processing, no se que hace acá
Cx = convX(C_LON);
Cy = convY(C_LAT);
Xg = 0;
Yg = 0;
map1 = new Map(Xg, Yg);
map2 = new Map(Xg-SIZE_IMGX, Yg);
map1.display();
map2.display();
// RENDER DE LA POSICIÓN ACTUAL DEL USUARIO
/*
lon = locationData.longitude;
lat = locationData.latitude;
x = convX(lon) - Cx;
y = convY(lat) - Cy;
fill(0, 255, 0, 200);
ellipse(x, y, 30, 30);
*/
// RENDER DE SATËLITES IMPORTANTES
displaySatellite();
// RENDER DE METEORITOS
displayMeteorite();
// RENDER DE INCENDIOS
// displayWildfire();
// RENDER DE TERREMOTOS
displayEarthquake();
}
function Map(x, y){
this.x = x - SIZE_IMGX / 2;
this.y = y - SIZE_IMGY / 2;
this.display = function(){
image(map2D, this.x, this.y, width, height);
image(map2D_1, this.x+SIZE_IMGX, this.y);
};
}
var dim3D;
function draw() {
background(0);
map1.x = 0;
map1.y = 0;
map2.x = -SIZE_IMGX;
map2.y = 0;
map1.display();
map2.display();
Xg = SIZE_IMGX / 2;
Yg = SIZE_IMGY / 2;
if (flag_satellite){
// RENDER DE SATËLITES IMPORTANTES
displaySatellite();
}
if (flag_meteorite){
// RENDER DE METEORITOS
displayMeteorite();
}
if (flag_fire){
// RENDER DE INCENDIOS
displayWildfire();
}
if (flag_earthquake){
// RENDER DE TERREMOTOS
displayEarthquake();
}
}
/*
function mouseDragged(){
map1.x = mouseX;
map2.x = mouseX - SIZE_IMGX;
if (map1.x > 0){
map2.x = map1.x - SIZE_IMGX;
}
if (map2.x > 0){
map1.x = map2.x - SIZE_IMGX;
}
}
*/
var flag_fire;
function mode_fire(){
if (flag_fire){
flag_fire = 0;
} else {
flag_fire = 1;
}
}
var flag_earthquake;
function mode_earthquake(){
if (flag_earthquake){
flag_earthquake = 0;
} else {
flag_earthquake = 1;
}
}
var flag_satellite;
function mode_satellite(){
if (flag_satellite){
flag_satellite = 0;
} else {
flag_satellite = 1;
}
}
var flag_meteorite;
function mode_meteorite(){
if (flag_meteorite){
flag_meteorite = 0;
} else {
flag_meteorite = 1;
}
}
var flag_clean;
function mode_clean(){
flag_fire = 0;
flag_earthquake = 0;
flag_satellite = 0;
flag_meteorite = 0;
}