forked from sopac/cifdp-map
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
188 lines (165 loc) · 7.93 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
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>CIFDP Forecast Web Mapping Application</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
<link rel="stylesheet" href="node_modules/leaflet/dist/leaflet.css" />
<link rel="stylesheet" href="node_modules/leaflet-timedimension/dist/leaflet.timedimension.control.min.css" />
<link rel="preconnect" href="https://fonts.gstatic.com">
<link rel="stylesheet" href="modal.css" />
<link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
<script src='https://cdn.plot.ly/plotly-latest.min.js'></script>
<style>
body {
font-family: 'Roboto', sans-serif;
}
</style>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div align="center">
<table style="width: 96%;">
<tr>
<td>
<img style="height: 80px;" src="logos/fj_arms.png" />
<img style="height: 63px; margin-right: 10px; margin-top: 10px;" src="logos/spc.png" />
<img style="height: 84px;" src="logos/cosppac.png" />
<img style="height: 70px;" src="logos/wmo.png" />
<img style="height: 90px;" src="logos/kma.png" />
</td>
<td style="text-align: right;">
<h3>Coastal Inundation Forecast Demostration Project (CIFDP)</h3>
<p>High Resolution <b>Inundation</b> Forecast</p>
</td>
</tr>
</table>
<hr />
<div class="img-thumbnail" align="left" style="height: 70%; width: 800px">
<div id="map" style="height: 100%; width: 100%"></div>
</div>
<div id='myDiv' style="height:500px;"></div>
<br />
<button id="modal-btn" style="display: none;"> click me, I make a modal</button><div class="modal">
<div class="modal-content">
<span class="close-btn">×</span>
<p id="msg"></p>
</div>
</div>
<iframe src="/chart/" title="iframe Example 1" width="100%" height="500">
</iframe>
<!--footer-->
<hr />
© 2021 Geoscience, Energy and Maritime Division, Pacific Community (SPC)<br /><br />
</div>
<script type="text/javascript" src="node_modules/leaflet/dist/leaflet.js"></script>
<script type="text/javascript" src="node_modules/iso8601-js-period/iso8601.js"></script>
<script type="text/javascript" src="node_modules/leaflet-timedimension/dist/leaflet.timedimension.min.js"></script>
<script type="text/javascript" src="node_modules/leaflet.nontiledlayer/dist/NonTiledLayer.js"></script>
<script type="text/javascript" src="node_modules/leaflet-bing-layer/leaflet-bing-layer.min.js"></script>
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=Promise"></script>
<script type="text/javascript" src="baselayers.js"></script>
<!--
<script type="text/javascript" src="node_modules/pym.js/dist/pym.v1.min.js"></script>
<script type="text/javascript" src="Leaflet-WMS.min.js"></script>
<script type="text/javascript" src="leaflet.timedimension.circlelabelmarker.js"></script>
<script type="text/javascript" src="leaflet.timedimension.layer.wms.timeseries.js"></script>
-->
<script type="text/javascript" src="app.js"></script>
<script type="text/javascript" src="warning.js"></script>
<script type="text/javascript" src="index.js"></script>
<script>
let url = host+"ncWMS2/wms?REQUEST=GetTimeseries&LAYERS=1/Hswell&QUERY_LAYERS=1/Hswell,1/Tp,1/L,1/Hs&BBOX=176.7314,-19.385,178.8734,-17.6714&SRS=CRS:84&FEATURE_COUNT=5&HEIGHT=500&WIDTH=950&X=229&Y=214&STYLES=default/default&VERSION=1.1.1&TIME=2021-02-18T00:00:00.000Z/2021-02-25T00:00:00.000Z&INFO_FORMAT=text/json&CHARTWIDTH=790";
let xl = [];
let yl = [];
let hs = [];
let tp = [];
let L = [];
Plotly.d3.json(url, function(figure){
let dt = figure.domain['axes']['t']['values']
let hswell = figure.ranges['Hswell']['values']
let hs_dat = figure.ranges['Hs']['values']
let tp_dat = figure.ranges['Tp']['values']
let L_dat = figure.ranges['L']['values']
for (var i=0; i< dt.length; i++){
xl.push(dt[i])
yl.push(hswell[i])
hs.push(hs_dat[i])
tp.push(tp_dat[i])
L.push(L_dat[i])
}
console.log(xl);
var trace = {
x: xl,
y: yl,
name: 'Swell Height(m)'
};
let trace2 = {
x: xl,
y: hs,
name: 'Wave Height(m)'
};
let trace3 = {
x: xl,
y: tp,
name: 'Wave Period(s)',
yaxis: 'y3'
};
let trace4 = {
x: xl,
y: L,
name: 'Wave Length(m)',
yaxis: 'y4'
};
var data = [trace, trace2, trace3, trace4];
console.log(trace);
var layout = {
title: 'Timeseries of variable: Hswell, Hs, Tp and L',
width: 1300,
xaxis: {domain: [0.1, 0.92]},
yaxis: {
title: 'Swell & Wave Height (m)',
titlefont: {color: '#1f77b4'},
tickfont: {color: '#1f77b4'}
},
yaxis3: {
title: 'Peak wave Period (s)',
titlefont: {color: '#d62728'},
tickfont: {color: '#d62728'},
anchor: 'x',
overlaying: 'y',
side: 'right'
},
yaxis4: {
title: 'Peak Wave Length (m)',
titlefont: {color: '#008000'},
tickfont: {color: '#008000'},
anchor: 'free',
overlaying: 'y',
side: 'right',
position: 0.97
}
};
let graphD = document.getElementById("myDiv");
Plotly.plot(document.getElementById("myDiv"), data, layout);
document.getElementById("myDiv").on('plotly_click', function(data){
var pts = '';
var dt = data.points[0].x;
var swellheight = data.points[0].y.toFixed(2);
var waveheight = data.points[1].y.toFixed(2);
var waveperiod = data.points[2].y.toFixed(2);
var wavelength = data.points[3].y.toFixed(2);
var msg = "<table style='color: #0000ff; border: 1px solid #dddddd; text-align: center; width:100%; border-collapse: collapse;'><tr><th style=' padding:8px; color:#0000EE;'>Datetime</th><th style='color:#0000EE;'>"+dt+"</th></tr>";
msg += "<tr style='border: 1px solid #dddddd;'><td style='border: 1px solid #dddddd; padding:5px;'>Swell Height (m)</td><td>"+swellheight+"<td></tr>";
msg += "<tr style='border: 1px solid #dddddd;'><td style='border: 1px solid #dddddd; padding:5px;'>Wave Height (m)</td><td>"+waveheight+"<td></tr>";
msg += "<tr style='border: 1px solid #dddddd;'><td style='border: 1px solid #dddddd; padding:5px;'>Wave Period (s)</td><td>"+waveperiod+"<td></tr>";
msg += "<tr style='border: 1px solid #dddddd;'><td style='border: 1px solid #dddddd; padding:5px;'>Wave Length (m)</td><td>"+wavelength+"<td></tr>";
document.getElementById("msg").innerHTML = msg;
modal.style.display = "block";
});
});
</script>
</body>
</html>