-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
235 lines (209 loc) · 9.5 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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="description" content="Wind map.">
<title>Wind map</title>
<style>
* { margin: 0; padding: 0; }
body {font: 10pt "Helvetica Neue", Arial, Helvetica, sans-serif;}
html, #map {
position: absolute;
height: 100%;
width: 100vw;
padding: 0;
}
body > #sidebar {
display: none;
}
</style>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"
integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ=="
crossorigin=""/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/c3/0.7.20/c3.css"/>
<link rel="stylesheet" href="dist/L.Control.MousePosition.css"/>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"
integrity="sha512-/Nsx9X4HebavoBvEBuyp3I7od5tA0UzAxs+j83KgC8PU0kgB4XiK4Lfe4y4cgBtaRJQEIFCW+oC506aPT2L1zw=="
crossorigin="">
</script>
<script src="https://cdn.plot.ly/plotly-2.27.0.min.js" charset="utf-8"></script>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script src=https://cdnjs.cloudflare.com/ajax/libs/mathjs/12.2.1/math.min.js></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-ajax/2.1.0/leaflet.ajax.min.js"></script>
<script src='dist/L.Control.MousePosition.js'></script>
<!--leaflet-velocity-->
<link rel="stylesheet" href="dist/leaflet-velocity.css" />
<script src="dist/leaflet-velocity.js"></script>
<!--leaflet-sidebar-v2-->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/js/leaflet-sidebar.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/css/leaflet-sidebar.min.css" rel="stylesheet">
</head>
<body>
<!-- optionally define the sidebar content via HTML markup -->
<div id="sidebar" class="leaflet-sidebar collapsed">
<!-- nav tabs -->
<div class="leaflet-sidebar-tabs">
<!-- top aligned tabs -->
<ul role="tablist">
<li><a href="#home" role="tab"><i class="fa fa-bars active"></i></a></li>
<li><a href="#wind" role="tab"><i class="fa fa-wind active"></i></a></li>
<li><a href="https://github.com/1oly/wind"><i class="fa-brands fa-github"></i></a></li>
<li><a href="https://olly.dk"><i class="fa fa-home"></i></a></li>
</ul>
</div>
<!-- panel content -->
<div class="leaflet-sidebar-content">
<div class="leaflet-sidebar-pane" id="home">
<h1 class="leaflet-sidebar-header">
Wind map
<span class="leaflet-sidebar-close"><i class="fa fa-caret-left"></i></span>
</h1>
<h2>About wind map</h2>
<p>This wind map is made to show the current wind turbines and wind field in Denmark.
The aim is to have a near-real time presentation of the power production from each individual wind turbine and potentially also a forecast.</p>
<h3>Data sources</h3>
<ul>
<li>Basemap is courtesy of <a href="https://www.openstreetmap.org/copyright">OpenStreetMap contributors</a> and <a href="https://carto.com/attributions">CARTO</a>. </li>
<li>Wind data is from Harmonie forecast model run by <a href="https://www.dmi.dk">DMI</a> and <a href="https://opendatadocs.dmi.govcloud.dk/DMIOpenData">DMI Open Data</a>.</li>
<li>Wind turbine data is from <a href="https://ens.dk/service/statistik-data-noegletal-og-kort/download-gis-filer">Energistyrelsen</a> (the Danish Energy Agency). Opdated October 2024.</li>
</ul>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<p><a href="https://visitorbadge.io/status?path=https%3A%2F%2Fwind.olly.dk"><img src="https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fwind.olly.dk&label=VISITORS&countColor=%23263759&style=flat-square" /></a></p>
</div>
<div class="leaflet-sidebar-pane" id="wind">
<h1 class="leaflet-sidebar-header">
Wind turbine
<span class="leaflet-sidebar-close"><i class="fa fa-caret-left"></i></span>
</h1>
<h3>Wind turbine specs*</h3>
<ul style="list-style: none;">
<li><b>Model:</b> <div class="manufacturer" style="display: inline"></div> (<div class="model" style="display: inline"></div>)</li>
<li><b>Power:</b> <div class="power" style="display: inline"></div> MW.</li>
<li><b>Rotor diameter:</b> <div class="rotor_diam" style="display: inline"></div> m.</li>
<li><b>Hub height:</b> <div class="hub_height" style="display: inline"></div> m.</li>
<li><b>Date connected:</b> <div class="date_connect" style="display: inline"></div></li>
<li><b>Date decomissioned:</b> <div class="date_decom" style="display: inline"></div></li>
</ul>
<h3>Power production</h3>
<p></p>
<div id="chart" style="width:300px;height:200px;"></div>
<p><i>* Data is taken directly from Energistyrelsen and not quality assured before displaying it here. Wrong infomation may occur.</i></p>
<h3>Wind forecast</h3>
<p></p>
<b>Forecast time:</b> <div class="refDate" style="display: inline"></div> <div class="refTime" style="display: inline"></div>
</div>
</div>
</div>
<div id="map"></div>
<script>
var map = new L.Map('map',{ zoomControl: false })
map.attributionControl.addAttribution('<a href="https://confluence.govcloud.dk/display/FDAPI/Danish+Meteorological+Institute+-+Open+Data">© DMI</a>');
var layerControl = L.control.layers().addTo(map);
var CartoDB_DarkMatterNoLabels = L.tileLayer('https://{s}.basemaps.cartocdn.com/dark_nolabels/{z}/{x}/{y}{r}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>, © <a href="https://carto.com/attributions">CARTO</a>',
subdomains: 'abcd',
maxZoom: 20
}).addTo(map);
function getRad_wt(d) {
return d < 1 ? 1:
d**0.6;
}
function wt_style(feature) {
var kap = feature.properties.capacity_kW/1000
return {
radius: getRad_wt(kap),
fillColor: 'white',
weight: 0.0,
opacity: 0.0,
fillOpacity: 0.5
};
}
function onEachFeature(feature, layer) {
if (feature.properties && feature.properties.type) {
layer.on('click', function(e) {
sidebar.open('wind');
$(".model").html(feature.properties.type);
$(".manufacturer").html(feature.properties.manufacturer);
$(".power").html(feature.properties.capacity_kW/1000);
$(".hub_height").html(feature.properties.hub_height_m);
$(".rotor_diam").html(feature.properties.rotor_diam_m);
(feature.properties.date_connect !== null) ? feature.properties.date_connect : '';
$(".date_connect").html((feature.properties.date_connect !== null) ? feature.properties.date_connect.split('T')[0] : '');
$(".date_decom").html((feature.properties.date_decom !== null) ? feature.properties.date_decom.split('T')[0] : '');
//$(".wind_speed").html(getWindSpeed(e));
getData(feature);
});
}
}
function getWindSpeed(e) {
if ($('.leaflet-control-velocity').length > 0) {
var velocityValue = $('.leaflet-control-velocity').text();
}
return velocityValue
}
function circleMarker(feature, latlng) {
return L.circleMarker(latlng, wt_style(feature));
}
// WIND TURBINES
$.getJSON("https://raw.githubusercontent.com/1oly/wind/main/wt_2024oct.json", function(wt) {
wtlyr = L.geoJSON(wt, {
pointToLayer: circleMarker,
onEachFeature: onEachFeature
}).addTo(map);
layerControl.addOverlay(wtlyr, 'Wind turbines');
map.fitBounds(wtlyr.getBounds());
});
// WIND PARTICLES
$.getJSON("https://raw.githubusercontent.com/1oly/wind/main/script/wind10m.json", function(data) {
var velocityLayer = L.velocityLayer({
displayValues: true,
displayOptions: {
velocityType: "Wind",
position: "bottomleft",
emptyString: "No wind data",
},
data: data,
maxVelocity: 25
}).addTo(map);
$(".refDate").html(data[0].header.refTime.substr(0, 10));
$(".refTime").html(data[0].header.refTime.substr(11, 8));
layerControl.addOverlay(velocityLayer, "Wind 10m");
});
var sidebar = L.control.sidebar({
autopan: false, // whether to maintain the centered map point when opening the sidebar
closeButton: true, // whether t add a close button to the panes
container: 'sidebar', // the DOM container or #ID of a predefined sidebar container that should be used
position: 'left', // left or right
}).addTo(map);
function getData(d) {
var data = [];
const yearsN = [...Array(48)].map((_, i) => i+1977)
const years = [...Array(48)].map((_, i) => `Y${i+1977}`)
const keys = Object.keys(d.properties)
filteredArray = keys.filter( function( el ) {
return years.includes( el );
} );
for(i in filteredArray){
k = d.properties[filteredArray[i]]
if (k === null){
v = 0.0
}
else {
v = k/1000.0
}
data.push(v);
}
plot = document.getElementById('chart');
Plotly.newPlot( plot, [{
x: yearsN,
y: data,
type: 'bar'}], {
xaxis: {title:{text:'Year'},font:{family:'Helvetica Neue',size:10}},
yaxis: {title:{text:'MWh'},font:{family:'Helvetica Neue',size:10}},
margin: {l:50,r:10, t: 20 ,b:30} },{responsive: true});
}
</script>
</body>
</html>