shuishen
2023-04-09 85fb13abbeadc1765d2c0056ba99c6c19aa35dfd
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
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
<template>
    <div v-show="dialogVisible && isShowActivityEditBox" class="draw-btn-box">
        <div class="left">
            <h3>预案布置</h3>
            <div>
                <span>要素资源:</span>
                <ul>
                    <li>
                        <button @click="drawThreeArrow('billboard', 'police', 'policeman')" title="警员">
                            <img src="/img/icon/police-people-btn.png" style="height:100%" />
                        </button>
                    </li>
                    <li>
                        <button @click="drawThreeArrow('billboard', 'police', 'policecar')" title="警车">
                            <img src="/img/icon/car-btn.png" style="height:100%" />
                        </button>
                    </li>
                    <li>
                        <button @click="drawThreeArrow('billboard', 'icon', 'icon1')" title="普通群众">普通群众</button>
                    </li>
                    <li>
                        <button @click="drawThreeArrow('billboard', 'icon', 'icon2')" title="保护对象">保护对象</button>
                    </li>
                    <li>
                        <button @click="drawThreeArrow('billboard', 'icon', 'icon3')" title="危险人物">危险人物</button>
                    </li>
                    <li>
                        <button @click="drawThreeArrow('billboard', 'icon', 'icon4')" title="自定义图片标注">自定义图片标注</button>
                    </li>
                </ul>
            </div>
            <div>
                <span>作战标绘:</span>
                <ul>
                    <li>
                        <button @click="drawArrow('attack_arrow', 1)" title="进攻箭头">进攻箭头</button>
                    </li>
                    <li>
                        <button @click="drawArrow('double_arrow', 2)" title="双箭头">双箭头</button>
                    </li>
                    <li>
                        <button @click="drawArrow('fine_arrow', 3)" title="直箭头">直箭头</button>
                    </li>
                    <li>
                        <button @click="drawArrow('tailed_attack_arrow', 4)" title="燕尾箭头">燕尾箭头</button>
                    </li>
                    <li>
                        <button @click="drawThreeArrow('polygon', 'polygon', 'polygon')" title="多边形">多边形</button>
                    </li>
                    <li>
                        <button @click="drawThreeArrow('brokenline', 'brokenline', 'brokenline')" title="折线">折线</button>
                    </li>
                </ul>
            </div>
            <div>
                <span>巡逻路线:</span>
                <ul>
                    <li>
                        <!-- <el-button
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ></el-button>-->
                        <button @click="drawThreeArrow('polyline', 'policecar')" title="巡逻路线">
                            <img src="/img/icon/route1.png" style="height:100%" />
                        </button>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</template>
 
<script>
import {
    updateActivityCar, updateActivityPolice,
    updateSecurityPlot
} from '@/api/activity/index.js'
 
import Plot from "@/utils/plot/Plot.js"
 
let plotDrawEmit = null
 
let addPlotOverlayData = null
 
let currentEmitEl = null
let drawThreeTool = null
 
let drawFlag = false
let drawTwoFlag = false
 
let currentStatus = ''
 
const plotDrawType = 1
export default {
    props: [
        'dialogVisible', 'isShowActivityEditBox', 'showingSecurityId',
        'policeSwitch', 'polylineBtnSwitch',
        'arrowBtnSwitch', 'policeIconId', 'lineWidth'],
    data () {
        return {
            startDrawFlag: false,
            startTwoDrawFlag: false
        }
    },
 
    mounted () {
        this.$nextTick(() => {
 
            global.viewer.scene.globe.depthTestAgainstTerrain = false
 
            plotDrawEmit = new global.DC.Plot(global.viewer, {
                clampToModel: true
            })
 
            drawThreeTool = new Plot(global.viewer, {
                clampToModel: true
            })
 
        })
 
    },
 
    methods: {
        drawArrow (type, plotType) {
            let flag
            this.$EventBus.$emit('tilesetLayerFlag', plotDrawType, (e) => { flag = e })
            if (flag != true) return
 
            drawTwoFlag = false
            if (this.startDrawFlag == true) {
                drawFlag = true
                drawThreeTool && drawThreeTool.stop()
                drawFlag = false
                this.startDrawFlag = false
            }
            if (this.startTwoDrawFlag == true) {
                drawTwoFlag = true
                plotDrawEmit && plotDrawEmit.stop()
                drawTwoFlag = false
                this.startTwoDrawFlag = false
            }
            this.startTwoDrawFlag = true
 
            currentStatus == 'emit' && drawThreeTool.stop(currentEmitEl)
            currentStatus == 'twoEmit' && plotDrawEmit.stop()
            currentStatus = 'twoDraw'
 
            const that = this
            plotDrawEmit && plotDrawEmit.draw(type, overlay => {
                if (drawTwoFlag) return
                if (overlay) {
                    addPlotOverlayData = overlay
                    overlay.customType = 'polyArrows'
                    that.$parent.addArrowsListLayer(overlay)
                    let polygonPosition = overlay.positions.map(item => `${item.lng} ${item.lat}`).join()
                    const altitude = overlay.positions.map(item => item.alt).join()
 
                    setTimeout(() => {
                        that.$parent.addSaveNewDraw(polygonPosition, plotType, altitude)
                    }, 100)
 
                    currentStatus = ''
                    that.startTwoDrawFlag = true
                }
            }, { material: global.DC.Namespace.Cesium.Color.fromBytes(64, 158, 255, 122) })
        },
 
        drawThreeArrow (type, billboardType = '', typeValue = '') {
            let flag
            this.$EventBus.$emit('tilesetLayerFlag', plotDrawType, (e) => { flag = e })
            if (flag != true) return
 
            drawFlag = false
            if (this.startDrawFlag == true) {
                drawFlag = true
                drawThreeTool && drawThreeTool.stop()
                drawFlag = false
                this.startDrawFlag = false
            }
            if (this.startTwoDrawFlag == true) {
                drawTwoFlag = true
                plotDrawEmit && plotDrawEmit.stop()
                drawTwoFlag = false
                this.startTwoDrawFlag = false
            }
            this.startDrawFlag = true
 
            currentStatus == 'emit' && drawThreeTool.stop(currentEmitEl)
            currentStatus == 'twoEmit' && plotDrawEmit.stop()
            currentStatus = 'draw'
 
            const that = this
            let imgUrl
            let material
            switch (typeValue) {
                case 'policeman':
                    imgUrl = 'police-people'
                    material = global.DC.Namespace.Cesium.Color.fromBytes(30, 50, 230, 255)
                    break
                case 'policecar':
                    imgUrl = 'car'
                    material = global.DC.Namespace.Cesium.Color.fromBytes(30, 50, 230, 255)
                    break
                case 'icon1':
                    imgUrl = 'ptqz'
                    material = global.DC.Namespace.Cesium.Color.fromBytes(255, 0, 0, 255)
                    break
                case 'icon2':
                    imgUrl = 'bhdx'
                    material = global.DC.Namespace.Cesium.Color.fromBytes(255, 0, 0, 255)
                    break
                case 'icon3':
                    imgUrl = 'wxrw'
                    material = global.DC.Namespace.Cesium.Color.fromBytes(255, 0, 0, 255)
                    break
                case 'icon4':
                    imgUrl = 'custom'
                    material = global.DC.Namespace.Cesium.Color.fromBytes(255, 0, 0, 255)
                    break
            }
 
            if (type == 'polygon') {
                drawThreeTool && drawThreeTool.draw(type, overlay => {
                    if (drawFlag) return
                    if (overlay) {
                        addPlotOverlayData = overlay
                        overlay.customType = 'polygon'
                        that.$parent.addArrowsListLayer(overlay)
 
                        let polygonPosition = overlay.positions.map(item => `${item.lng} ${item.lat}`).join()
                        const altitude = overlay.positions.map(item => item.alt).join()
                        setTimeout(() => {
                            that.$parent.addSaveNewDraw(polygonPosition, 5, altitude)
                        }, 100)
                        currentStatus = ''
                        that.startDrawFlag = false
                    }
                }, {
                    material: global.DC.Namespace.Cesium.Color.fromBytes(64, 158, 255, 122),
                    outline: true,
                    outlineColor: global.DC.Namespace.Cesium.Color.fromBytes(64, 158, 255, 255),
                    outlineWidth: 1.0,
                    height: 0
                })
            } else if (type == 'brokenline') {
                drawThreeTool && drawThreeTool.draw('polyline', overlay => {
                    if (drawFlag) return
                    if (overlay) {
                        addPlotOverlayData = overlay
                        overlay.customType = 'brokenline'
                        that.$parent.addArrowsListLayer(overlay)
                        let polygonPosition = overlay.positions.map(item => `${item.lng} ${item.lat}`).join()
                        const altitude = overlay.positions.map(item => item.alt).join()
                        setTimeout(() => {
                            that.$parent.addSaveNewDraw(polygonPosition, 10, altitude)
                        }, 100)
                        currentStatus = ''
                        that.startDrawFlag = false
                    }
                }, {
                    material: global.DC.Namespace.Cesium.Color.fromBytes(64, 158, 255, 122),
                    width: 4
                })
            } else if (type == 'billboard') {
                drawThreeTool && drawThreeTool.draw(type, overlay => {
                    if (drawFlag) return
                    if (overlay) {
                        addPlotOverlayData = overlay
                        overlay.customType = 'billboard'
                        that.$parent.addPointCircleCarLayer(overlay)
                        if (billboardType == 'police') {
                            that.$parent.addSaveNewDrawPoint(typeValue, overlay)
                        } else {
                            that.$parent.addPointPopupShow(typeValue, overlay.position)
                        }
                        currentStatus = ''
                        that.startDrawFlag = false
                    }
                }, {
                    size: [32, 32],
                    color: material,
                    billboardImage: `/img/icon/${imgUrl}.png`
                })
            } else if (type == 'polyline') {
                drawThreeTool && drawThreeTool.draw(type, overlay => {
                    if (drawFlag) return
                    if (overlay) {
                        addPlotOverlayData = overlay
                        overlay.customType = 'polyline'
                        that.$parent.addLineLayer(overlay)
                        let polylinePosition = overlay.positions.map(item => `${item.lng} ${item.lat}`).join()
                        const altitude = overlay.positions.map(item => item.alt).join()
                        setTimeout(() => {
                            that.$parent.addSaveNewDrawLine(polylinePosition, altitude)
                        }, 100)
                        currentStatus = ''
                        that.startDrawFlag = false
                    }
                }, {
                    material: global.DC.Namespace.Cesium.Color.fromBytes(28, 160, 133, 122),
                })
            }
        },
 
        removeDrawArrow () {
            addPlotOverlayData != null && addPlotOverlayData.remove()
        },
 
        // 编辑标绘位置
        plotEdit (overlayData, type) {
            currentEmitEl = overlayData
            if (overlayData.customType == 'polygon' || overlayData.customType == 'brokenline') {
                currentStatus = 'emit'
                drawThreeTool.edit(overlayData, (e) => {
                    let polygonPosition = e.positions.map(item => `${item.lng} ${item.lat}`).join()
                    const altitude = e.positions.map(item => item.alt).join()
                    this.updateSecurityPlot({ id: overlayData.attrParams.id, position: polygonPosition, altitude })
                    currentStatus = ''
                })
            } else if (overlayData.customType == 'billboard') {
                currentStatus = 'emit'
                drawThreeTool.edit(overlayData, (e) => {
                    const position = `${e.position.lng} ${e.position.lat},${e.position.lng} ${e.position.lat}`
                    const altitude = `${e.position.alt},${e.position.alt}`
                    this.updateSecurityPlot({ id: overlayData.attrParams.id, position, altitude })
                    currentStatus = ''
                })
            } else if (overlayData.customType == 'polyArrows') {
                currentStatus = 'twoEmit'
                plotDrawEmit.edit(overlayData, (e) => {
                    let polygonPosition = e.positions.map(item => `${item.lng} ${item.lat}`).join()
                    const altitude = e.positions.map(item => item.alt).join()
                    this.updateSecurityPlot({ id: overlayData.attrParams.id, position: polygonPosition, altitude })
                    currentStatus = ''
                })
            } else if (overlayData.attrParams.lineObj.customType == 'polyline') {
                currentStatus = 'twoEmit'
                currentEmitEl = overlayData.attrParams.lineObj
                drawThreeTool.edit(overlayData.attrParams.lineObj, (e) => {
                    let linePosition = e.positions.map(item => `${item.lng} ${item.lat}`).join()
                    const altitude = e.positions.map(item => item.alt).join()
                    this.updateActivityCar({
                        id: overlayData.attrParams.id,
                        color: overlayData.attrParams.color,
                        width: overlayData.attrParams.width,
                        type: 1,
                        position: linePosition,
                        altitude
                    }, overlayData)
                    currentStatus = ''
                })
            }
        },
 
        // 保存新增标绘样式修改
        addNewPlot (item) {
            let r = parseInt(item.color.slice(1, 3), 16)
            let g = parseInt(item.color.slice(3, 5), 16)
            let b = parseInt(item.color.slice(5, 7), 16)
            let a = Math.floor(Number(item.color.split(',')[1]) * 2.55) ? Math.floor(Number(item.color.split(',')[1]) * 2.55) : 255
            let color = global.DC.Namespace.Cesium.Color.fromBytes(r, g, b, a)
 
            addPlotOverlayData.attrParams = { id: item.id, color: item.color, item }
 
            addPlotOverlayData.on(global.DC.MouseEventType.CLICK, this.$parent.reeditArrowClick)
            if (item.type == 6 || item.type == 7 || item.type == 8 || item.type == 11) {
                const height = item.altitude.split(',')
                let position = item.position.slice(12, item.position.length - 2).split(',')[0].split(' ')
 
                if (item.iconUrl != '') addPlotOverlayData.icon = item.iconUrl
 
                addPlotOverlayData.setStyle({
                    color: color
                })
 
                addPlotOverlayData.position = {
                    lng: Number(position[0]),
                    lat: Number(position[1]),
                    alt: Number(height[0]),
                }
 
                addPlotOverlayData.on(global.DC.MouseEventType.MOUSE_OVER, this.$parent.pointMouseOver)
                addPlotOverlayData.on(global.DC.MouseEventType.MOUSE_OUT, this.$parent.pointMouseOut)
 
                this.$parent.isHaveFactor = true
            } else {
                addPlotOverlayData.setStyle({
                    material: color
                })
 
                this.$parent.isHaveArrow = true
            }
        },
 
        // 保存新增警力资源
        addNewPolice (data, type, carType) {
            // 巡逻路线添加
            if (type == 'policecar' && carType == 1) {
                // 线坐标字符串
                let positionNewArr = this.$parent.convertPolylineOrPolygonPositionDate(data, 'add')
                // 范围面坐标串
                let coords = global.DC.GeoTools.polylineBuffer(positionNewArr, data.width != -1 ? data.width : 100)
                let positionStr = ''
                coords.forEach((item, index) => {
                    if (!(index == coords.length - 1)) {
                        positionStr += item[0] + ',' + item[1] + ';'
                    }
                })
                let polygonSavePositionStr = positionStr + coords[0][0] + ',' + coords[0][1] + ';'
                positionStr = positionStr.slice(0, positionStr.length - 1)
                // 面颜色
                let color = ''
                // 线颜色
                let lineColor = ''
                if (data.color == '') {
                    color = global.DC.Namespace.Cesium.Color.fromBytes(255, 0, 0, 150)
                } else {
                    let r = parseInt(data.color.slice(1, 3), 16)
                    let g = parseInt(data.color.slice(3, 5), 16)
                    let b = parseInt(data.color.slice(5, 7), 16)
                    color = global.DC.Namespace.Cesium.Color.fromBytes(r, g, b, 150)
                    lineColor = global.DC.Namespace.Cesium.Color.fromBytes(r, g, b, 255)
                }
                addPlotOverlayData.setStyle({
                    material: lineColor,
                    width: 3
                })
 
                data.linePositionStr = positionNewArr
                data.polygonPositionStr = polygonSavePositionStr
                data.lineObj = addPlotOverlayData
 
                addPlotOverlayData.attrParams = data
 
                this.$EventBus.$emit('layerPolygonAdd', {
                    layerName: 'newCarDrawLineLayers',
                    positions: positionStr,
                    material: color,
                    params: data,
                    incident: this.$parent.lineOverlayTypeClick
                })
 
                this.$parent.isHaveLine = true
            } else {
                let positionObj = this.$parent.convertBillboardPositionDate(data, type)
                positionObj.lng = positionObj.lng.slice(1, positionObj.lng.length - 1)
                positionObj.lat = positionObj.lat.slice(0, positionObj.lat.length - 2)
                let positionArr = data.position.slice(7, data.position.length - 2).split(',')[0].split(' ')
                let color = ''
                if (data.color == '') {
                    color = global.DC.Namespace.Cesium.Color.fromBytes(255, 0, 0, 150)
                } else {
                    let r = parseInt(data.color.slice(1, 3), 16)
                    let g = parseInt(data.color.slice(3, 5), 16)
                    let b = parseInt(data.color.slice(5, 7), 16)
                    color = global.DC.Namespace.Cesium.Color.fromBytes(r, g, b, 255)
                }
 
                addPlotOverlayData.attrParams = positionObj
                addPlotOverlayData.position = {
                    lng: Number(positionArr[0]),
                    lat: Number(positionArr[1]),
                    alt: Number(positionObj.alt)
                }
 
                addPlotOverlayData.setStyle({
                    color: color
                })
 
                addPlotOverlayData.on(global.DC.MouseEventType.MOUSE_OVER, this.$parent.pointMouseOver)
                addPlotOverlayData.on(global.DC.MouseEventType.MOUSE_OUT, this.$parent.pointMouseOut)
                addPlotOverlayData.on(global.DC.MouseEventType.CLICK, this.$parent.overlayTypeClick)
 
                this.$parent.isHaveFactor = true
            }
        },
 
        // 修改标绘样式
        editPlotStyle (params, overlay) {
            if ('color' in params) {
                let r = parseInt(params.color.slice(1, 3), 16)
                let g = parseInt(params.color.slice(3, 5), 16)
                let b = parseInt(params.color.slice(5, 7), 16)
                let a = Math.floor(Number(params.color.split(',')[1]) * 2.55) ? Math.floor(Number(params.color.split(',')[1]) * 2.55) : 255
                let color = global.DC.Namespace.Cesium.Color.fromBytes(r, g, b, a)
                let outColor = global.DC.Namespace.Cesium.Color.fromBytes(r, g, b, 255)
                overlay.attrParams.color = params.color
 
                if (overlay.customType == 'polygon') {
                    overlay.setStyle({
                        material: color,
                        outlineColor: outColor
                    })
                } else if (overlay.customType == 'billboard') {
                    overlay.setStyle({
                        color: color
                    })
                } else {
                    overlay.setStyle({
                        material: color
                    })
                }
 
                if ('pointOverlayData' in overlay.attrParams) {
                    let r = parseInt(params.color.slice(1, 3), 16)
                    let g = parseInt(params.color.slice(3, 5), 16)
                    let b = parseInt(params.color.slice(5, 7), 16)
                    let a = Math.floor(Number(params.color.split(',')[1]) * 2.55)
                    let color = global.DC.Namespace.Cesium.Color.fromBytes(r, g, b, a)
                    overlay.attrParams.pointOverlayData.setStyle({
                        "color": color, //颜色
                        "outlineColor": color, //边框颜色
                        "outlineWidth": 0, //边框大小,
                        "pixelSize": 32,
                    })
                }
            }
 
            if ('name' in params) {
                addPlotOverlayData.text = params.name
            }
 
            if ('width' in params) {
                overlay.setStyle({
                    "font": `${params.width}px sans-serif`
                })
            }
 
            if ('icon' in params && params.icon != '') {
                overlay.icon = params.icon
            }
 
            if ('remark' in params && params.remark != '') {
                overlay.attrParams.item.remark = params.remark
            }
        },
 
        // 修改警车样式
        editPoliceStyle (params, overlay) {
            if ('color' in params && overlay.customType == 'billboard') {
                overlay.attrParams.data.color = params.color
                let r = parseInt(params.color.slice(1, 3), 16)
                let g = parseInt(params.color.slice(3, 5), 16)
                let b = parseInt(params.color.slice(5, 7), 16)
                let color = global.DC.Namespace.Cesium.Color.fromBytes(r, g, b, 255)
                overlay.setStyle({
                    color: color, //颜色
                })
            }
 
            if ('carId' in params) {
                overlay.attrParams.data.carId = params.carId
            }
 
            if ('policemanId' in params) {
                overlay.attrParams.data.policemanId = params.policemanId
            }
 
            if ('width' in params) {
                if (overlay.attrParams && overlay.attrParams.data && overlay.attrParams.data.type && overlay.attrParams.data.type == 3) {
                    overlay.attrParams.data.width = params.width
                } else {
                    let linePosition = ''
                    if ('position' in params) {
                        linePosition = params.position.replace(/,/g, ";").replace(/ /g, ",")
                    } else {
                        linePosition = overlay.attrParams.linePositionStr
                    }
                    let coords = global.DC.GeoTools.polylineBuffer(linePosition, params.width)
                    let positionStr = ''
                    coords.forEach((item, index) => {
                        if (!(index == coords.length - 1)) {
                            positionStr += item[0] + ',' + item[1] + ';'
                        }
                    })
                    positionStr = positionStr.slice(0, positionStr.length - 1)
                    // 面颜色
                    let color = ''
                    // 线颜色
                    let lineColor = ''
 
                    if (params.color == '') {
                        color = global.DC.Namespace.Cesium.Color.fromBytes(255, 0, 0, 150)
                    } else {
                        let r = parseInt(params.color.slice(1, 3), 16)
                        let g = parseInt(params.color.slice(3, 5), 16)
                        let b = parseInt(params.color.slice(5, 7), 16)
                        color = global.DC.Namespace.Cesium.Color.fromBytes(r, g, b, 150)
                        lineColor = global.DC.Namespace.Cesium.Color.fromBytes(r, g, b, 255)
                    }
                    overlay.attrParams.lineObj.setStyle({
                        "material": lineColor,
                        'width': 3
                    })
                    overlay.attrParams.linePositionStr = linePosition
                    overlay.attrParams.polygonPositionStr = positionStr
                    overlay.attrParams.color = params.color
                    overlay.attrParams.width = params.width
 
                    this.$EventBus.$emit('layerPolygonAdd', {
                        layerName: 'newCarDrawLineLayers',
                        positions: positionStr,
                        material: color,
                        params: overlay.attrParams,
                        incident: this.$parent.lineOverlayTypeClick
                    })
 
                    overlay.remove()
                }
            }
 
            if ('remark' in params) {
                overlay.attrParams.data.remark = params.remark
            }
        },
 
        // 修改警车
        // idid, carId警车id, color颜色, width巡逻路线范围宽度, type线面类型, position坐标
        updateActivityCar (params, overlay) {
            updateActivityCar(params).then(res => {
                if (res.data.success) {
                    this.editPoliceStyle(params, overlay)
                    this.$message({
                        message: '保存成功',
                        type: 'success'
                    })
                } else {
                    this.$message({
                        message: '保存失败',
                        type: 'error'
                    })
                }
 
            })
        },
 
        // 修改警员
        // idid, policemanId警察id ,color颜色
        updateActivityPolice (params, overlay) {
            updateActivityPolice(params).then(res => {
                if (res.data.success) {
                    this.$message({
                        message: '保存成功',
                        type: 'success'
                    })
                    this.editPoliceStyle(params, overlay)
                } else {
                    this.$message({
                        message: '保存失败',
                        type: 'error'
                    })
                }
            })
        },
 
        updateSecurityPlot (params, overlay) {
            updateSecurityPlot(params).then(res => {
                if (res.data.success) {
                    this.editPlotStyle(params, overlay)
                    this.$message({
                        message: '修改成功',
                        type: 'success'
                    })
                } else {
                    this.$message({
                        message: '修改失败',
                        type: 'error'
                    })
                }
            })
        },
 
        stopDraw () {
            drawFlag = true
            drawTwoFlag = true
 
 
            if (plotDrawEmit) {
                plotDrawEmit.stop()
            }
 
            if (drawThreeTool) {
                currentStatus == 'draw' && drawThreeTool.stop()
                currentStatus == 'emit' && drawThreeTool.stop(currentEmitEl)
            }
        }
    },
 
    destroyed () {
        this.stopDraw()
        plotDrawEmit.destroy()
        plotDrawEmit = null
        drawThreeTool.destroy()
        drawThreeTool = null
    },
}
</script>
 
<style lang="scss" scoped>
.draw-btn-box {
    position: fixed;
    display: flex;
    // left: 50%;
    bottom: 40px;
    color: #fff;
    background: $bg-one-color;
    white-space: nowrap;
    // transform: translate(-50%, 0);
 
    .left,
    .right {
        height: 100%;
 
        &>div {
            display: flex;
        }
 
        ul {
            display: flex;
 
            li {
                button {
                    height: 30px;
                    margin: 0 5px;
                    background-color: $bg-color;
                    border: 1px solid #cecece;
                    border-radius: 4px;
                    color: #fff;
                    cursor: pointer;
                    outline: none;
                }
            }
        }
    }
 
    .left {
        width: 100%;
 
        h3 {
            font-size: 16px;
            height: 30px;
            line-height: 30px;
            width: 100%;
            // padding-left: 16%;
        }
    }
 
    .right {
        width: 20%;
        padding-top: 35px;
 
        ul {
            flex-direction: column;
 
            li {
                height: 50px;
 
                button {
                    background-color: #2a56cf;
                }
            }
        }
    }
}
</style>