1
Surpriseplus
2022-09-16 8d1a91c23df335b090e38b2edd15203aa3b03da9
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
<template>
  <div id="sdkContainer">
    <div
      id="PopupTop"
      class="upEventContiner"
      v-show="isShow"
      style="position: absolute; left: 15%; top: 15%"
    >
      <div id="Popup_close" @click="PopupClose"><span>X</span></div>
      <div id="Popup_video">
        <video
          class="video-js"
          id="mapVideo"
          controls
          data-setup="{}"
          style="object-fit: fill; width: 100%; height: 100%; border-radius: 4%"
          autoplay="autoplay"
          muted
        >
          <source
            src="http://111.35.21.92:8002/stream/37078313001310604367/index.m3u8"
            type="application/x-mpegURL"
          />
        </video>
      </div>
    </div>
  </div>
</template>
 
<script>
import { GisServe, SgsServe } from "../utils/config";
import axios from "axios";
 
export default {
  name: "mapindex",
  props: ["toChild"],
  data() {
    return {
      earthimg: require("../assets/img/Map/earth.jpg"),
      imgurl: require("../assets/img/Map/dibiao.png"),
      Mapvideo: null,
      isShow: false,
      addrss: [
        {
          url: "/dist/A-1.591355/tileset.json",
        },
        {
          url: "/dist/A-2.591356/tileset.json",
        },
        {
          url: "/dist/B-2.591358/tileset.json",
        },
        {
          url: "/dist/C-1.591359/tileset.json",
        },
        {
          url: "/dist/C-2.591360/tileset.json",
        },
        {
          url: "/dist/D.591361/tileset.json",
        },
        {
          url: "/dist/E.591362/tileset.json",
        },
        {
          url: "/dist/F.591363/tileset.json",
        },
        {
          url: "/dist/G.591364/tileset.json",
        },
        {
          url: "/dist/H.591365/tileset.json",
        },
        {
          url: "/dist/I.591366/tileset.json",
        },
        {
          url: "/dist/_唐宁7号和园.591367/tileset.json",
        },
      ],
    };
  },
  watch: {
    toChild(oldval, newval) {
      if (oldval.platform != null && oldval.pointname != null) {
        var lat = parseFloat(oldval.platform);
        var lon = parseFloat(oldval.pointname);
        sgworld.Navigate.jumpTo({
          //跳转视角
          destination: new Cesium.Cartesian3.fromDegrees(lat, lon, 5000),
          orientation: {
            heading: 0,
            pitch: -45,
          },
        });
      }
    },
  },
  methods: {
    PopupClose() {},
 
    init3DMap() {
      //   window.sgworld = new SmartEarth.SGWorld("sdkContainer", Cesium, {
      //     url: this.earthimg, //不含单张地图图片url则使用在线地图
      //     sceneMode: Cesium.SceneMode.SCENE2D,
      //   });
      window.sgworld = new SmartEarth.SGWorld("sdkContainer");
      window.Viewer = sgworld._Viewer;
      sgworld.Navigate.Stop(); //取消飞行状态
 
      //显示fps
      sgworld._Viewer.scene.debugShowFramesPerSecond = false;
      window.Viewer = sgworld._Viewer;
      //   Viewer.imageryLayers.removeAll();
      //加载mpt影像数据
      //   this.getMPTDate();
      //加载3d模型
      this.getC3DModel();
      //   加载点数据
      this.getGisServerPoint();
      // 加载线数据
      //   this.getGisServerPline();
      // 加载面数据
      //   this.getGisServerPolygon();
      //跳转视角
      sgworld.Navigate.jumpTo({
        destination: new Cesium.Cartesian3.fromDegrees(
          118.78163769788802,
          36.858502654619926,
          237.73308962594658
        ),
 
        orientation: {
          heading: 5.8653385935931865,
          pitch: -0.24090990327488826,
          roll: 0.0,
        },
      });
      var arrLoc = [];
      var pickPosition = { x: null, y: null };
      var mhandler = new Cesium.ScreenSpaceEventHandler(sgworld.Viewer.canvas);
 
      mhandler.setInputAction(function (movement) {
        var cartesian = sgworld.Viewer.camera.pickEllipsoid(
          movement.position,
          sgworld.Viewer.scene.globe.ellipsoid
        );
        if (cartesian) {
          var cartographic = Cesium.Cartographic.fromCartesian(
            cartesian,
            sgworld.Viewer.scene.globe.ellipsoid
          );
 
          var longitudeString = Cesium.Math.toDegrees(
            cartographic.longitude
          ).toFixed(2); //要更高的精度就修改保留的小数位数
          var latitudeString = Cesium.Math.toDegrees(
            cartographic.latitude
          ).toFixed(2); //同上
          pickPosition.x = longitudeString;
          pickPosition.y = latitudeString;
          let cf = {
            x: parseFloat(pickPosition.x),
            y: parseFloat(pickPosition.y),
          };
 
          var a = {
            position: sgworld.Viewer.camera.position,
            heading: sgworld.Viewer.camera.heading,
            pitch: sgworld.Viewer.camera.pitch,
          };
        }
        var ellipsoid = sgworld.Viewer.scene.globe.ellipsoid;
 
        var lonlat = ellipsoid.cartesianToCartographic(a.position);
 
        var lat = Cesium.Math.toDegrees(lonlat.latitude);
        var lng = Cesium.Math.toDegrees(lonlat.longitude);
        var alt = lonlat.height;
 
        console.log("获取数据", lat, lng, alt); //当前视角
 
        console.log(a);
      }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
 
      this.Mapvideo = videojs(
        "mapVideo",
        {
          autoplay: true,
          controls: false, // 是否显示控制条
        },
        function onPlayerReady() {
          this.play();
        }
      );
    },
    getMPTDate() {
      var urls = SgsServe + "/streamer.ashx/Imagery";
      var dx = sgworld.Creator.createImageryProvider(
        "mpt影像",
        "wms",
        {
          url: urls,
          layers: "627.mpt.I.mpt",
        },
        "0",
        undefined,
        true,
        ""
      );
    },
    getC3DModel() {
      var url1 = "http://127.0.0.1:8099";
      var tiltModel1;
      for (var i in this.addrss) {
        var value_Address = url1 + this.addrss[i].url;
        var name = "dist" + i;
        tiltModel1 = sgworld.Creator.create3DTilesets(
          name,
          value_Address,
          {},
          {},
          "0",
          true,
          function (data) {}
        );
      }
    },
    getGisServerPolygon() {
      var httpURL =
        GisServe +
        "/wfsserver/寿光市面?version=1.3.0&request=GetFeature&typename=寿光市-面&propertyname=*&bbox=118.540020466,36.719702574,119.125701064,37.3274334030001&format=json";
      var data = {
        far: 20000000,
        heightReference: 1,
        layertype: "polygonlayer",
        near: 0,
        outline: true,
        outlineColor: "#fff",
        outlineWidth: 1,
        extrudedHeight: undefined,
        material: "#00f",
      };
      var dx = sgworld.Creator.createPolygonGeoJsonFeatureLayer(
        "SHOUGUANGCITY",
        httpURL,
        data,
        "0",
        true,
        function (layer_data) {}
      );
    },
    getGisServerPline() {
      var httpURL =
        GisServe +
        "/wfsserver/主干道路?version=1.3.0&request=GetFeature&typename=主干道路&propertyname=*&bbox=118.540060461,36.7391040247307,119.076533164318,37.2667331700001&format=json";
 
      var pathLayer = sgworld.Creator.createPathLayer({
        url: httpURL,
        color: "#8CF9FC", //线的颜色
        width: 4.0, //线的宽度
        pointColor: "#FFFFFF", //移动点的颜色
        speed: 2,
      });
      var httpURLone =
        GisServe +
        "/wfsserver/寿光市线?version=1.3.0&request=GetFeature&typename=寿光市线&propertyname=*&bbox=118.540060461,36.7391040247307,119.076533164318,37.2667331700001&format=json";
      var data = {
        arcType: 0,
        material: "#00f",
        clampToGround: true,
        far: 50000000,
        layertype: "Streetscape",
        near: 0,
        opacity: "1",
        width: 3,
      };
      var dx = sgworld.Creator.createStreetscapeGeoJsonFeatureLayer(
        "",
        httpURLone,
        data,
        "0",
        true,
        function (data) {}
      );
    },
    async getGisServerPoint() {
      const { data: dt } = await this.$http.get(
        "/jeecg-boot/rediotree/rediotree/queryall"
      );
      this.sendVideo(dt.result);
    },
    sendVideo(response) {
      var valuedata = response;
      var pointEntities = [];
      for (var i = 0; i < valuedata.length; i++) {
        var lng = parseFloat(valuedata[i].lon);
        var lat = parseFloat(valuedata[i].lat);
        var entity = new Cesium.Entity({
          id: valuedata[i].code,
          position: Cesium.Cartesian3.fromDegrees(lng, lat),
          name: valuedata[i].pointname,
          billboard: {
            image: this.imgurl,
            width: 70, // 宽高必须设置,否则首次无法聚合
            height: 70,
 
            heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
            horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
            verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
          },
        });
        pointEntities.push(entity);
      }
      var dataSourceMap = new Map();
      var dataSource = new Cesium.CustomDataSource("cluster");
      Viewer.dataSources.add(dataSource);
      for (var i = 0; i < pointEntities.length; i++) {
        dataSource.entities.add(pointEntities[i]);
      }
      var pixelRange = 25;
      var minimumClusterSize = 5;
      var enabled = true;
      dataSource.clustering.enabled = enabled;
      dataSource.clustering.pixelRange = pixelRange;
      dataSource.clustering.minimumClusterSize = minimumClusterSize;
      var removeListener;
      var singleDigitPins = new Array(5);
      customStyle();
      dataSourceMap.set(name, dataSource);
      function customStyle() {
        if (Cesium.defined(removeListener)) {
          removeListener();
          removeListener = undefined;
        } else {
          removeListener = dataSource.clustering.clusterEvent.addEventListener(
            function (clusteredEntities, cluster) {
              cluster.label.show = false;
              cluster.billboard.show = true;
              cluster.billboard.id = cluster.label.id;
              cluster.billboard.verticalOrigin = Cesium.VerticalOrigin.BOTTOM;
 
              var numArr = [
                1000, 940, 880, 820, 760, 700, 640, 580, 520, 460, 400, 340,
                280, 220, 160, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5,
              ];
              for (var i = 0; i < numArr.length; i++) {
                var num = clusteredEntities.length;
                if (num >= 5 && num < 10) {
                  cluster.billboard.image = singleDigitPins[num - 5];
                  break;
                }
                if (num >= numArr[i]) {
                  break;
                }
              }
            }
          );
        }
      }
      var mhandler = new Cesium.ScreenSpaceEventHandler(sgworld.Viewer.canvas);
      mhandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK); //解除绑定
      var that = this;
      mhandler.setInputAction(function (event) {
        //左键点击事件
        var pickedFeature = sgworld.Viewer.scene.pick(event.position);
        if (Cesium.defined(pickedFeature)) {
          // videoSend()
          // this.bus.$emit("videosend","PKQ")
          that.$emit("fromChild", pickedFeature);
        } else {
          console.log("未选中");
        }
      }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
    },
  },
 
  mounted() {
    this.init3DMap();
  },
};
</script>
 
<style scoped>
#sdkContainer {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}
 
.upEventContiner {
  height: 50%;
  width: 20%;
  background: url("../assets/img/Map/组 7790.png") no-repeat 100% 100%;
  background-size: cover;
  padding-left: 10px;
  padding-right: 10px;
  z-index: 31;
}
 
.up-event {
  /* width: 80px; */
  /* border: 1px solid red; */
  padding-top: 5px;
  height: 30px;
  line-height: 30px;
  font-size: 14px;
  font-family: Alibaba-PuHuiTi-B;
  line-height: 11px;
  color: #ffffff;
  opacity: 1;
  position: relative;
}
 
#Popup_close {
  width: 100%;
  height: 5%;
  border: 1px solid blue;
  /* position: absolute; 
   top: 10px;
  right: 10px;
  height: 500px;
 
  cursor: pointer;
  background: url("../assets/img/Map/路径 5179.png") no-repeat; */
}
#Popup_close span {
  font-size: 50px;
  color: white;
  right: 2%;
  position: absolute;
  cursor: pointer;
}
#Popup_video {
  width: 99%;
  border: 1px solid red;
  height: 93%;
  position: absolute;
}
</style>