Skip to content

Commit c12ef99

Browse files
committed
Merge branch 'dev'
2 parents 4f7aa28 + 9298e5b commit c12ef99

File tree

5 files changed

+151
-24
lines changed

5 files changed

+151
-24
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ conda remove -n <gndas_env> --all --y
102102

103103
<img src="./imgs/risk.png">
104104

105+
此外,系统还提供了基于聚类灾害中心的区域风险评估交互分析。
106+
107+
<img src="./imgs/buffer.png">
108+
105109
5. 进入用户论坛模块,用户可以在这里交流评论,该模块可以防御XSS攻击。
106110

107111
<img src="./imgs/discuss.png">

imgs/buffer.png

972 KB
Loading

webpage/risk.html

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@
6666
<!--缓冲区--><!--
6767
<label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;半径:</label>
6868
<input name="radius" id="radius" class="txt" value="radius"/>-->
69-
<button id="buffer_btn" class="buffer_btn" onclick="showbuffer()">缓冲区</button>
69+
<!--<button id="buffer_btn" class="buffer_btn" onclick="showbuffer()">缓冲区</button>-->
70+
<div class="buffer">
71+
<label>区域风险评估&nbsp;&nbsp;<input class="mui-switch mui-switch-animbg" type="checkbox" id="buffer_checkbox"></label>
72+
</div>
7073

7174
<script>
7275
let vol_o = {{ vol | tojson }}
@@ -197,6 +200,7 @@
197200
}
198201

199202
const heat_type = document.getElementsByClassName('heat_type');
203+
const box=document.getElementById("buffer_checkbox");
200204

201205
let flag = [true, false, false, false]
202206
heat_type[0].classList.add('clicked');
@@ -207,12 +211,21 @@
207211
switch (i) {
208212
case 0:
209213
Volcano_Charts();
214+
if(box.checked){
215+
showbuffer(vol_o,500)
216+
}
210217
break;
211218
case 1:
212219
Earthquake_Charts();
220+
if(box.checked){
221+
showbuffer(eqk_o,100)
222+
}
213223
break;
214224
case 2:
215225
Tsunami_Charts();
226+
if(box.checked){
227+
showbuffer(tnm_o,500)
228+
}
216229
break;
217230
}
218231
if (flag[i] === false) {
@@ -271,6 +284,28 @@
271284
}
272285
$('#slider').RangeSlider({min: 0, max: 100, step: 1, callback: change});
273286
let slide_value = document.getElementById("slider");
287+
288+
289+
//改变缓冲区状态
290+
$("#buffer_checkbox").change(function () {
291+
if(box.checked){
292+
let temp_buffer = flag.indexOf(true);
293+
switch (temp_buffer) {
294+
case 0:
295+
showbuffer(vol_o,500)
296+
break;
297+
case 1:
298+
showbuffer(eqk_o,100)
299+
break;
300+
case 2:
301+
showbuffer(tnm_o,500)
302+
break;
303+
}
304+
}
305+
else
306+
{RemoveLayers();
307+
}
308+
})
274309
</script>
275310
</body>
276311
</html>

webpage/risk/Risk_Func.js

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,11 @@ function Get_Cluster(pointdata) {
369369
}
370370

371371

372-
function showbuffer() {
373-
const buffer_Id = "polygon"
374-
const center_Id = "point"
375-
for(let k=0;k<100;k++){
372+
const buffer_Id = "polygon"
373+
const center_Id = "point"
374+
375+
function RemoveLayers() {
376+
for (let k = 0; k < 100; k++) {
376377

377378
if (heatmap.getLayer(buffer_Id + k)) // 不存在 source => undefined
378379
{
@@ -389,20 +390,25 @@ function showbuffer() {
389390
if (heatmap.getSource(center_Id + k)) // 不存在 source => undefined
390391
{
391392
heatmap.removeSource(center_Id + k)
392-
}}
393-
let temp_buffer = flag.indexOf(true);
394-
let cluster_center=Get_Cluster(vol_o);
395-
switch (temp_buffer) {
396-
case 0:
397-
cluster_center = Get_Cluster(vol_o)
398-
break;
399-
case 1:
400-
cluster_center = Get_Cluster(eqk_o)
401-
break;
402-
case 2:
403-
cluster_center = Get_Cluster(tnm_o)
404-
break;
405393
}
394+
}
395+
}
396+
397+
398+
function showbuffer(pointdata,rr) {
399+
400+
RemoveLayers();
401+
cc = turf.clustersKmeans(pointdata)
402+
cluster_num = []
403+
cluster_center = []
404+
for (let i = 0; i < cc.features.length; i++) {
405+
let temp_id = cc['features'][i]['properties']["cluster"];
406+
let temp_center = cc['features'][i]['properties']["centroid"];
407+
if (cluster_num.indexOf(temp_id) == -1) {
408+
cluster_num.push(temp_id)
409+
cluster_center.push(temp_center)
410+
}
411+
}
406412

407413
for (let i = 0; i < cluster_center.length; i++) {
408414
let temp_lng = cluster_center[i][0]
@@ -411,7 +417,7 @@ function showbuffer() {
411417
var point = turf.point([parseFloat(temp_lng), parseFloat(temp_lat)]);
412418

413419
//创建缓冲区面
414-
var buffered = turf.buffer(point, 500, {units: "miles"});/*parseFloat(radius), {steps:2,units: units});*/
420+
var buffered = turf.buffer(point, radius=rr, {units: "miles"});/*parseFloat(radius), {steps:2,units: units});*/
415421
//获取缓冲区面坐标数组
416422
var coordinates = buffered.geometry.coordinates[0];
417423
// 获取缓冲区四至
@@ -435,7 +441,7 @@ function showbuffer() {
435441
}
436442
//计算左下角到右上角的距离
437443
//var distance = turf.distance(turf.point(es), turf.point(wn), {units: "miles"});
438-
//添加资源和图层
444+
//添加资源和图层
439445

440446
heatmap.addSource(buffer_Id + i, {
441447
'type': 'geojson',
@@ -460,7 +466,7 @@ function showbuffer() {
460466
'type': 'circle',
461467
'source': center_Id + i,
462468
'paint': {
463-
'circle-radius': 6,
469+
'circle-radius': 4,
464470
'circle-color': '#B42222'
465471
}
466472
});

webpage/styles/risk.css

Lines changed: 85 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,89 @@ input.ne-range[type=range]::-webkit-slider-thumb {
235235
}
236236

237237
#amount::-webkit-outer-spin-button,
238-
#amount::-webkit-inner-spin-button{
239-
-webkit-appearance: none !important;
240-
margin: 0;
238+
#amount::-webkit-inner-spin-button {
239+
-webkit-appearance: none !important;
240+
margin: 0;
241+
}
242+
243+
.buffer {
244+
position: absolute;
245+
bottom: 10%;
246+
left: 23%;
247+
width: 200px;
248+
height: 40px;
249+
color: rgba(255, 255, 255, 0.7);
250+
font-family: Ubuntu, "Microsoft YaHei", serif;
251+
font-weight: bold;
252+
font-size: 20px;
253+
backdrop-filter: blur(3px);
254+
background-color: rgba(0, 0, 0, 0.3);
255+
256+
display: flex;
257+
align-items: center;
258+
justify-content: center;
259+
}
260+
261+
label {
262+
display: block;
263+
vertical-align: middle;
264+
}
265+
266+
label, input, select {
267+
vertical-align: middle;
268+
}
269+
270+
.mui-switch {
271+
width: 50px;
272+
height: 30px;
273+
position: relative;
274+
background-color: rgba(253, 253, 253, 0.7);
275+
border-radius: 20px;
276+
background-clip: content-box;
277+
display: inline-block;
278+
-webkit-appearance: none;
279+
user-select: none;
280+
outline: none;
281+
282+
cursor: pointer;
283+
}
284+
285+
.mui-switch:before {
286+
content: '';
287+
width: 29px;
288+
height: 29px;
289+
position: absolute;
290+
top: 0px;
291+
left: 0;
292+
border-radius: 20px;
293+
background-color: rgba(255, 255, 255, 0.7);
294+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
295+
}
296+
297+
.mui-switch:checked {
298+
border-color: #1da1f2;
299+
/*box-shadow: #1da1f2 0 0 0 16px inset;*/
300+
background-color: #1da1f2;
301+
}
302+
303+
.mui-switch:checked:before {
304+
left: 21px;
305+
}
306+
307+
.mui-switch.mui-switch-animbg {
308+
transition: background-color ease 0.4s;
309+
}
310+
311+
.mui-switch.mui-switch-animbg:before {
312+
transition: left 0.3s;
313+
}
314+
315+
.mui-switch.mui-switch-animbg:checked {
316+
/*box-shadow: #dfdfdf 0 0 0 0 inset;*/
317+
background-color: #1da1f2;
318+
transition: border-color 0.4s, background-color ease 0.4s;
319+
}
320+
321+
.mui-switch.mui-switch-animbg:checked:before {
322+
transition: left 0.3s;
241323
}

0 commit comments

Comments
 (0)