1
Surpriseplus
2022-09-16 a7e5110ef3f5fe3c9205f7d1a526b9fbbb55d826
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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
<template>
  <div class="box">
    <el-form :inline="true" :model="formInline" class="demo-form-inline">
      <el-form-item label="预案姓名" style="width: 45%">
        <el-input v-model="formInline.name" placeholder="预案姓名"></el-input>
      </el-form-item>
      <el-form-item label="预案类型" style="width: 45%">
        <el-input v-model="formInline.accidentTypeNames" placeholder="预案类型"></el-input>
      </el-form-item>
      <el-form-item label="预案等级" style="width: 45%">
        <el-input v-model="formInline.planLevelName" placeholder="预案等级"></el-input>
      </el-form-item>
      <el-form-item style="width: 45%; padding-top: 40px">
        <el-button type="primary" @click="onSubmit" style="background-color: transparent">提交</el-button>
      </el-form-item>
    </el-form>
    <div class="box_content">
      <el-radio-group v-model="labelPosition" style="width: 100%" @change="changelabel">
        <el-radio-button label="YJDW" style="width: 33.3%">应急队伍</el-radio-button>
        <el-radio-button label="YJZY" style="width: 33.3%">应急资源</el-radio-button>
        <el-radio-button label="YY" style="width: 33.3%">医院</el-radio-button>
      </el-radio-group>
      <div class="list">
        <el-table :data="tableData" border style="width: 100%" highlight-current-row
          @current-change="handleCurrentChange">
          <el-table-column prop="properties.name" label="名称">
          </el-table-column>
          <el-table-column prop="properties.address" label="位置">
          </el-table-column>
        </el-table>
      </div>
    </div>
  </div>
</template>
 
<script>
var fireParticlePrimitive = null
var waterParticlePrimitive = null
var entity = null
var emitterModelMatrix = null
var translation = null
var rotation = null
var hpr = null
var trs = null
var gravityScratch = null
var model;
import axios from "axios";
import { axios_get, axios_post } from "../../../until/request.js";
import HttpUrl from "../../../config/http.js";
export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {
      labelPosition: "YJDW",
      toickTime: null,
      formInline: {
        planFileUrls:
          "http://120.201.201.87:8081//appfiles/uploadfile/plan/appendix/1656909336155.doc",
      },
      tableData: [],
      //2022.9.14
      fireParticlePrimitive: null,
      waterParticlePrimitive: null,
      entity: null,
      emitterModelMatrix: null,
      translation: null,
      rotation: null,
      hpr: null,
      trs: null,
      gravityScratch: null,
    };
  },
  //方法集合
  methods: {
    // 最短路径
    amapRoute(x1, y1, x2, y2) {
      // var jsonurl =
      //    HttpUrl.GISERVEER +
      //   "/gisserver/wnsserver/JKQ_LJGH2?start=" +
      //   x1 +
      //   "," +
      //   y1 +
      //   "&end=" +
      //   x2 +
      //   "," +
      //   y2 +
      //   "&propertyName=Shape&tolerance=500&request=FindPath&format=json";
      // var jsonurl =
      //   "http://103.85.165.98:9055/gisserver/wnsserver/JKQroad_wns?start=" +
      //   x1 +
      //   "," +
      //   y1 +
      //   "&end=" +
      //   x2 +
      //   "," +
      //   y2 +
      //   "&propertyName=Shape&tolerance=500&request=FindPath&format=json";
      var routeList = [
 
        [120.54698294618969, 41.65921572158251],
 
        [120.54628609106244, 41.65713535288827],
 
        [120.54380554395682, 41.65737759808522],
 
        [120.5429852961289, 41.65752681351214],
 
        [120.54057724410904, 41.657697812935886],
      ]
      var jsonurl =
        "http://172.16.0.71:8090/gisserver/wnsserver/road_wns?start=" +
        "120.50077550962,41.635292371096" +
        "&end=" +
        "120.49901325448,41.636802875499" +
        "&propertyName=Shape&tolerance=500&request=FindPath&format=json";
      $.ajax({
        url: jsonurl,
        async: false,
        type: "GET",
        dataType: "json",
 
        contentType: "application/json;charset=utf-8",
        success: (data) => {
          data.features.forEach((e) => {
            if (e.geometry.type == "LineString") {
 
              //this.executeFly3D(e.geometry.coordinates);
              this.executeFly3D(routeList);
 
            }
          });
        },
      });
    },
    // closeWaterAll() {
    //   this.waterParticlePrimitive.emissionRate = 0;
    //   sgworld.Viewer.scene.primitives.remove(this.waterParticlePrimitive);
    // },
    // startWater() {
    //  
 
    //   var fireParticlePrimitive = null;
    //   var waterParticlePrimitive = null;
    //   var entity = null;
    //   var emitterModelMatrix = new Cesium.Matrix4();
    //   var translation = new Cesium.Cartesian3();
    //   var rotation = new Cesium.Quaternion();
    //   // var hpr = new Cesium.HeadingPitchRoll();  
    //   var hpr = {
    //     heading: 120.6325362317272143,
    //     pitch: -100.44926908149976796,
    //     roll: 30
    //   };
    //   var trs = new Cesium.TranslationRotationScale();
    //   var gravityScratch = new Cesium.Cartesian3();
    //   Viewer.scene.preUpdate.addEventListener(update);
    //   entity = sgworld.Viewer.entities.add({
    //     position: Cesium.Cartesian3.fromDegrees(120.540723, 41.657735, 100)
    //   });
 
    //   waterParticlePrimitive = sgworld.Viewer.scene.primitives.add(new Cesium.ParticleSystem({
    //     image: SmartEarthRootUrl + 'Workers/image/penquan.png',
    //     startColor: new Cesium.Color(1, 1, 1, 0.6),
    //     endColor: new Cesium.Color(0.80, 0.86, 1, 0.4),
    //     startScale: 1,
    //     endScale: 7,
    //     minimumParticleLife: 6,
    //     maximumParticleLife: 7,
    //     minimumSpeed: 26,
    //     maximumSpeed: 26,
    //     imageSize: new Cesium.Cartesian2(10, 10),
    //     emissionRate: 200,
    //     lifetime: 16.0,
    //     emitter: new Cesium.CircleEmitter(0.2),
    //     emitterModelMatrix: computeEmitterModelMatrix(),
    //     updateCallback: applyGravity
    //   }));
    //   Viewer.scene.preUpdate.addEventListener(update);
    //   this.waterParticlePrimitive = waterParticlePrimitive;
 
    //   function computeModelMatrix(entity, time) {
    //     return entity.computeModelMatrix(time, new Cesium.Matrix4());
    //   }
 
    //   function computeEmitterModelMatrix() {
 
    //     hpr = Cesium.HeadingPitchRoll.fromDegrees(110.0, 40.0, 0.0, hpr); // 倾斜角度
    //     trs.translation = Cesium.Cartesian3.fromElements(0, 0, 80, translation); // 发高度
    //     trs.rotation = Cesium.Quaternion.fromHeadingPitchRoll(hpr, rotation);
    //     return Cesium.Matrix4.fromTranslationRotationScale(trs, emitterModelMatrix);
    //   }
 
    //   function applyGravity(p, dt) {
    //     var position = p.position;
    //     Cesium.Cartesian3.normalize(position, gravityScratch);
    //     Cesium.Cartesian3.multiplyByScalar(gravityScratch, -4 * dt, gravityScratch);
    //     p.velocity = Cesium.Cartesian3.add(p.velocity, gravityScratch, p.velocity);
    //   }
    //   function update(scene, time) {
    //     waterParticlePrimitive.modelMatrix = computeModelMatrix(entity, time);
    //     waterParticlePrimitive.emitterModelMatrix = computeEmitterModelMatrix();
    //   }
    //   this.waterParticlePrimitive = waterParticlePrimitive;
    //   this.waterentity = entity;
    // },
    //单击列表路径规划
    handleCurrentChange(val) {
 
      this.amapRoute(
        val.properties.longitude,
        val.properties.latitude,
        120.541223,
        41.658835
      );
    },
    // 清空模型路线
    clearFly3DPaths() {
      sgworld.Viewer.trackedEntity = undefined;
      // bxmap.FlyCesium.isDrawFly = false;
      // bxmap.FlyCesium.draw3DObj = null;
      model = null;
      sgworld.Viewer.entities.removeAll(); //清空所有模型
      //清空绘制飞行路线
      // if (this.drawPolyline) {
      //     this.cesiumViewer.scene.primitives.remove(this.drawPolyline);
      //     this.drawPolyline = null;
      // }
    },
    // 停止漫游
    stopFly3DPaths() {
      var start = Cesium.JulianDate.fromDate(new Date());
      sgworld.Viewer.clock.startTime = start.clone();
      var stop = Cesium.JulianDate.addSeconds(
        start,
        300000000,
        new Cesium.JulianDate()
      );
      sgworld.Viewer.clock.stopTime = stop.clone();
 
      this.clearFly3DPaths();
    },
    // 创建漫游
    executeFly3D(pathsData) {
      this.stopFly3DPaths();
      this.HideWater();
      if (pathsData) {
        var positionA = pathsData;
        var position = [];
        if (positionA.length > 0) {
          for (var i = 0; i < positionA.length; i++) {
            var x = positionA[i][0];
            var y = positionA[i][1];
            position.push({ x: x, y: y });
          }
        } else {
          return;
        }
        var timevial = null;
        function computeCirclularFlight() {
          var property = new Cesium.SampledPositionProperty();
          for (var i = 0; i < position.length; i++) {
            if (i === 0) {
              var time = Cesium.JulianDate.addSeconds(
                start,
                i,
                new Cesium.JulianDate()
              );
              //var _position = Cesium.Cartesian3.fromDegrees(position[i].x, position[i].y, 1170);
              var _position = Cesium.Cartesian3.fromDegrees(
                position[i].x,
                position[i].y,
                193
              );
              property.addSample(time, _position);
            }
            if (i < 10000 && i > 0) {
              var position_a = new Cesium.Cartesian3(
                property._property._values[i * 3 - 3],
                property._property._values[i * 3 - 2],
                property._property._values[i * 3 - 1]
              );
              if (i < 976) {
                var _position = Cesium.Cartesian3.fromDegrees(
                  position[i].x,
                  position[i].y,
                  193
                );
              } else if (i > 975 && i < 986) {
                var _position = Cesium.Cartesian3.fromDegrees(
                  position[i].x,
                  position[i].y,
                  193
                );
              } else if (i > 985) {
                var _position = Cesium.Cartesian3.fromDegrees(
                  position[i].x,
                  position[i].y,
                  193
                );
              }
 
              var positions = [
                Cesium.Ellipsoid.WGS84.cartesianToCartographic(position_a),
                Cesium.Ellipsoid.WGS84.cartesianToCartographic(_position),
              ];
              var a = new Cesium.EllipsoidGeodesic(positions[0], positions[1]);
              var long = a.surfaceDistance;
              var _time = long / 50;
              var time = Cesium.JulianDate.addSeconds(
                property._property._times[i - 1],
                _time,
                new Cesium.JulianDate()
              );
              if (i == (position.length - 1)) {
                timevial = time;
              }
              property.addSample(time, _position);
            }
          }
          return property;
        }
        this.toickTime = timevial;
        var start = Cesium.JulianDate.fromDate(new Date());
        var stop = Cesium.JulianDate.addSeconds(
          start,
          120,
          new Cesium.JulianDate()
        );
        sgworld.Viewer.clock.startTime = start.clone();
        sgworld.Viewer.clock.stopTime = stop.clone();
        sgworld.Viewer.clock.currentTime = start.clone();
        // sgworld.Viewer.clock.clockRange = Cesium.ClockRange.LOOP_STOP;
        sgworld.Viewer.clock.multiplier = 1; //值越大,飞行越快
        sgworld.Viewer.clock.canAnimate = false;
        sgworld.Viewer.clock.shouldAnimate = true; //设置时间轴动态效果
 
        var _position = computeCirclularFlight();
 
        let model = sgworld.Viewer.entities.add({
          availability: new Cesium.TimeIntervalCollection([
            new Cesium.TimeInterval({
              start: start,
              stop: stop,
            }),
          ]),
          position: _position,
          orientation: new Cesium.VelocityOrientationProperty(_position),
          model: {
            uri: SmartEarthRootUrl + "Workers/Model/xiaofangche.gltf",
            scale: 1,
            minimumPixelSize: 90,
            //  heightReference: Cesium.HeightReference.CLAMP_TO_GROUND // 让模型在地形上紧贴
          },
          //Show the path as a pink line sampled in 1 second increments.
          path: {
            resolution: 1,
            material: new Cesium.PolylineGlowMaterialProperty({
              glowPower: 0.1,
              color: Cesium.Color.YELLOW,
            }),
            //width: 30
            width: 10,
            heightReference: Cesium.HeightReference.CLAMP_TO_GROUND, // 让模型在地形上紧贴
          },
        });
 
        sgworld.Viewer.trackedEntity = model;
        var that = this;
        function onTickCallback(tick) {
          if (parseFloat(tick._currentTime.secondsOfDay).toFixed(2) > parseFloat(timevial.secondsOfDay).toFixed(2)) {
 
            that.ShowWater();
            sgworld.Viewer.clock.onTick.removeEventListener(onTickCallback)
          }
        }
        sgworld.Viewer.clock.onTick.addEventListener(onTickCallback)
 
 
        setTimeout(function () {
          sgworld.Viewer.camera.zoomOut(700.0); //缩小地图,避免底图没有数据
        }, 100);
      } else {
        return;
      }
    },
 
    changelabel(res) {
      this.getList(res);
    },
    formatDate(date) {
      var date = new Date(date);
      var YY = date.getFullYear() + "-";
      var MM =
        (date.getMonth() + 1 < 10
          ? "0" + (date.getMonth() + 1)
          : date.getMonth() + 1) + "-";
      var DD = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
      var hh =
        (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
      var mm =
        (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) +
        ":";
      var ss =
        date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
      return YY + MM + DD + " " + hh + mm + ss;
      // return YY + MM + DD;
    },
    getList(res) {
      axios
        .get(
          `http://172.16.0.71:8090/gisserver/wfsserver/JKQ_YJ?version=1.3.0&request=GetFeature&typename=${res}&propertyname=*&format=json`
        )
        .then((response) => {
          this.tableData = response.data.features;
        });
    },
    onSubmit() {
      this.formInline.time = this.formatDate(new Date().getTime());
      var jsonData = JSON.stringify(this.formInline);
      $.ajax({
        url: "/LC/emergency/addDisposalPlans",
        async: false,
        type: "POST",
        dataType: "json",
        data: jsonData,
        contentType: "application/json;charset=utf-8",
        success: (data) => {
          this.$message({
            message: "添加成功",
            type: "success",
          });
          this.$store.commit("setchildState", true);
          // if (data.isSuccess) {
 
          //   //成功处理方式
          // } else if ("403" == data) {
          //   //失败方式处理
          // }
        },
      });
    },
    changeWater() {
 
      fireParticlePrimitive = null;
      waterParticlePrimitive = null;
      entity = null;
      emitterModelMatrix = new Cesium.Matrix4();
      translation = new Cesium.Cartesian3();
      rotation = new Cesium.Quaternion();
      hpr = {
        heading: 120.6325362317272143,
        pitch: -100.44926908149976796,
        roll: 30,
      };
      trs = new Cesium.TranslationRotationScale();
      gravityScratch = new Cesium.Cartesian3();
    },
    HideWater() {
      sgworld.Viewer.entities.removeAll();
      sgworld.Viewer.scene.primitives.remove(waterParticlePrimitive);
    },
    ShowWater() {
      function applyGravity(p, dt) {
        var position = p.position;
        Cesium.Cartesian3.normalize(position, gravityScratch);
        Cesium.Cartesian3.multiplyByScalar(
          gravityScratch,
          -4 * dt,
          gravityScratch
        );
        p.velocity = Cesium.Cartesian3.add(
          p.velocity,
          gravityScratch,
          p.velocity
        );
      }
      this.changeWater();
      let that = this
      entity = sgworld.Viewer.entities.add({
        position: Cesium.Cartesian3.fromDegrees(120.540723, 41.657735, 100)
      });
      waterParticlePrimitive = sgworld.Viewer.scene.primitives.add(
        new Cesium.ParticleSystem({
          image: SmartEarthRootUrl + "Workers/image/penquan.png",
          startColor: new Cesium.Color(1, 1, 1, 0.6),
          endColor: new Cesium.Color(0.8, 0.86, 1, 0.4),
          startScale: 1,
          endScale: 7,
          minimumParticleLife: 6,
          maximumParticleLife: 7,
          minimumSpeed: 26,
          maximumSpeed: 26,
          imageSize: new Cesium.Cartesian2(10, 10),
          emissionRate: 200,
          lifetime: 16.0,
          emitter: new Cesium.CircleEmitter(0.2),
          emitterModelMatrix: that.computeEmitterModelMatrix(),
          updateCallback: applyGravity,
        })
      );
      Viewer.scene.preUpdate.addEventListener(that.update());
    },
 
 
    update(scene, time) {
      waterParticlePrimitive.modelMatrix = this.computeModelMatrix(
        entity,
        time
      );
      waterParticlePrimitive.emitterModelMatrix =
        this.computeEmitterModelMatrix();
    },
    computeModelMatrix(entities, time) {
      return entities.computeModelMatrix(time, new Cesium.Matrix4());
    },
    computeEmitterModelMatrix() {
      hpr = Cesium.HeadingPitchRoll.fromDegrees(
        110.0,
        40.0,
        0.0,
        hpr
      ); // 倾斜角度
      trs.translation = Cesium.Cartesian3.fromElements(
        0,
        0,
        80,
        translation
      ); // 发射高度
      trs.rotation = Cesium.Quaternion.fromHeadingPitchRoll(
        hpr,
        rotation
      );
      return Cesium.Matrix4.fromTranslationRotationScale(
        trs,
        emitterModelMatrix
      );
    },
  },
  created() { },
  mounted() {
    this.getList("YJDW");
 
    this.$bus.$on("closerWater", (res) => {
 
      this.HideWater();
    });
 
  },
  beforeDestroy() {
    this.stopFly3DPaths()
    this.HideWater();
  }
};
</script>
<style lang='less' scoped>
//@import url(); 引入公共css类
.box {
  width: 100%;
  height: 100%;
 
  .el-form-item {
    /deep/ .el-form-item__label {
      color: #fff;
    }
  }
 
  .el-form /deep/ .el-input__inner,
  .el-form /deep/ .el-textarea__inner {
    background-color: rgba(134, 132, 132, 0.5);
    border-radius: 0;
    color: white;
  }
 
  .box_content {
    width: 100%;
 
    .el-table {
      background-color: transparent;
    }
 
    .el-table /deep/ th,
    .el-table /deep/ tr {
      background-color: transparent;
      color: white;
    }
 
    .el-table /deep/ tr:hover>td {
      background-color: rgba(0, 0, 0, 0.8) !important;
    }
 
    .el-table /deep/ .el-table__body tr.current-row>td.el-table__cell {
      background-color: rgba(0, 0, 0, 0.8) !important;
    }
  }
}
</style>
<style lang='less'>
.box_content {
  //   /deep/ .el-radio-button__inner {
  //     width: 100% !important;
  //   }
 
  .el-radio-group .el-radio-button .el-radio-button__inner {
    //修改按钮样式
    width: 99% !important;
    color: white;
    background-color: transparent;
  }
 
  .el-radio-button__orig-radio:checked+.el-radio-button__inner {
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid #98b5ca;
    color: #fff;
    line-height: 14px;
    outline: none;
    box-shadow: none;
  }
}
</style>