-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
281 lines (196 loc) · 8.8 KB
/
index.html
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MosquitoAlertBCN</title>
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png">
<link rel="manifest" href="site.webmanifest">
<link rel="mask-icon" href="safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
<meta name="description" content="Bringing together citizen science, artificial intelligence, the internet-of-things and traditional entomological trapping methods to create a novel and sophisticated tool for mosquito surveillance and public health decision-making.">
<meta property="og:title" content="MosquitoAlertBCN" />
<meta property="og:url" content="https://mosquito-alert.github.io/MosquitoAlertBCN" />
<meta property="og:description" content="Bringing together citizen science, artificial intelligence, the internet-of-things and traditional entomological trapping methods to create a novel and sophisticated tool for mosquito surveillance and public health decision-making.">
<meta property="og:image" content="time_profile_district_ytd.png">
<meta name="twitter:title" content="MosquitoAlertBCN">
<meta name="twitter:description" content="Bringing together citizen science, artificial intelligence, the internet-of-things and traditional entomological trapping methods to create a novel and sophisticated tool for mosquito surveillance and public health decision-making.">
<meta name="twitter:image" content="time_profile_district_ytd.png">
<meta name="twitter:card" content="summary_large_image">
<!--SOME CUSTOM CSS-->
<style>
#mapid{
position: absolute;
top: 55px;
bottom: 0;
width: 100%;
}
#legend {
color: #dddddd;
font-size:small;
}
#legend-colorbar {
background: linear-gradient(to bottom, #9e0142, #d53e4f, #f46d43, #fdae61, #fee08b, #ffffbf, #e6f598, #abdda4, #66c2a5, #3288bd, #5e4fa2);
height: 300px;
width:25px;
}
.navbar {
z-index: 10001;
}
</style>
<link rel="stylesheet" href="css/leaflet.css"/>
<!-- Make sure you put this AFTER Leaflet's CSS -->
<script src="js/leaflet.js"></script>
<!--bootstrap-->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
<link rel="stylesheet" href="css/datepicker.css"/>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container-fluid">
<a class="navbar-brand" href="index.html">#MosquitoAlertBCN</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="index.html">Risk Map</a>
</li>
<li class="nav-item">
<a class="nav-link" href="time_profiles.html">Time Profiles</a>
</li>
<li class="nav-item">
<a class="nav-link" href="daily.html">Daily Report</a>
</li>
<li class="nav-item">
<a class="nav-link" href="about.html">About</a>
</li>
</ul>
</ul>
</div>
</div>
</nav>
<div class="container" style="z-index:10000; position: absolute; right: 20px; width: 200px;">
<div class="row">
<p> <span id="cast_type" class="badge bg-success"style="width: 100px;">Nowcast</span> </p>
<div class="input-group date" data-provide="datepicker" data-date-end-date="+6d" id="datepicker_id">
<input type="text" class="form-control" value="Select Date">
<div class="input-group-addon">
<span class="glyphicon glyphicon-th"></span>
</div>
</div>
</div>
</div>
<div id="legend">
<div class="container" style="z-index:10000; position: absolute; bottom: 20px; right: 20px; width: 25px;">
<div class="row">
<div class="col-sm">
<span>VRI</span>
<div id="legend-colorbar">
</div>
</div>
</div>
</div>
<div class="container" style="z-index:10000; position: absolute; bottom: 15px; right: 42px; width: 5px">
<span>0.0</span>
</div>
<div class="container" style="z-index:10000; position: absolute; bottom: 305px; right: 42px; width: 5px;">
<span>0.3</span>
</div>
</div>
<div class="container-fluid">
<div class="row">
<div id="mapid"></div>
</div>
</div>
<!-- Date picker -->
<script src="js/jquery-1.12.4.js"></script>
<script src="js/bootstrap-datepicker.min.js"></script>
<script src="js/georaster.browser.bundle.min.js"></script>
<script src="js/georaster-layer-for-leaflet.browserify.min.js"></script>
<script src="js/chroma.min.js"></script>
<script type="text/javascript">
// function clamped_scale(v) { return v < 1 ? '#00000000' : chroma.scale(v); }
var mymap = L.map('mapid').setView([41.3851, 2.1734], 11);
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
attribution: 'Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
maxZoom: 19,
id: 'johnrbpalmer/cklcc4q673pe517k4n5co81sn',
tileSize: 512,
zoomOffset: -1,
accessToken: 'pk.eyJ1Ijoiam9obnJicGFsbWVyIiwiYSI6ImFRTXhoaHcifQ.UwIptK0Is5dJdN8q-1djww'
}).addTo(mymap);
</script>
<!--bootstrap-->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.bundle.min.js" integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0" crossorigin="anonymous"></script>
<script>
const max_vri = .6 // setting max for color scale. May need to revisit this later
function add_layer(a_date, remove_layer){
if(remove_layer == true){
if(mymap.hasLayer(layerGeo)){
mymap.removeLayer(layerGeo);
}
}
var url_to_geotiff_file = "https://raw.githubusercontent.com/Mosquito-Alert/bcn/main/data/vri" + a_date + ".tif";
fetch(url_to_geotiff_file)
.then(function(response){
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.arrayBuffer();
})
.then(arrayBuffer => {
parseGeoraster(arrayBuffer).then(georaster => {
// available color scales can be found by running console.log(chroma.brewer);
var scale = chroma.scale("Spectral").domain([1,0]);
layerGeo = new GeoRasterLayer({
georaster: georaster,
opacity: 1,
pixelValuesToColorFn: function(pixelValues) {
var pixelValue = pixelValues[0]; // there's just one band in this raster
// if there's a negative value
if (pixelValue < 0) return null;
//Making 0.3 the max
var scaledPixelValue = Math.min(pixelValue, max_vri) / max_vri;
var color = scale(scaledPixelValue).hex();
return color;
},
resolution: 256
});
// console.log("layer:", layer);
layerGeo.addTo(mymap);
});
});
}
$.fn.datepicker.defaults.autoclose = true;
var layerGeo;
$(document).ready(function() {
var date_today = new Date();
var date_today_fmt = date_today.getFullYear() + '-' + (1+date_today.getMonth()).toString().padStart(2, '0') + '-' + date_today.getDate().toString().padStart(2, '0');
add_layer(date_today_fmt, false);
$('#datepicker_id').datepicker({
format: 'dd/mm/yyyy',
todayHighlight: true,
})
.on('changeDate', function(e) {
var this_date = e.format('yyyy-mm-dd');
var this_date_fmt = e.date.getFullYear() + '-' + (1+e.date.getMonth()).toString().padStart(2, '0') + '-' + e.date.getDate().toString().padStart(2, '0');
if(e.date>date_today){
$("#cast_type").text("Forecast").removeClass().addClass("badge bg-warning text-dark");
};
if(e.date<date_today){
$("#cast_type").text("Historical").removeClass().addClass("badge bg-primary");
};
if(this_date_fmt.localeCompare(date_today_fmt) == 0){
$("#cast_type").text("Nowcast").removeClass().addClass("badge bg-success");
};
add_layer(this_date, true);
});
});
</script>
</body>
</html>