shuishen
2022-04-29 443c649303cc275f4ff07b3d2f5e589047f8054d
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
/* * @Author: Morpheus * @Name: 地图测距 * @Date: 2021-11-13 16:04:27 * @Last
Modified by: Morpheus * @Last Modified time: 2022-02-15 14:28:44 */
 
<template>
    <public-box class="technique-box">
        <template slot="public-box-header">
            <div class="title">
                <span>三维空间分析</span>
            </div>
            <img class="close deblurring" src="/img/navicon/close.png" alt @click="closeModel" />
        </template>
        <template slot="public-box-content">
            <ul>
                <li>
                    日照分析
                    <el-switch
                        v-model="sunlightShow"
                        :active-value="true"
                        :inactive-value="false"
                        @change="sunlightChange"
                    ></el-switch>
                </li>
                <li>
                    通视分析(圆)
                    <el-button type="primary" size="mini" @click="drawCircle">标绘</el-button>
                    <el-button type="primary" size="mini" @click="removeCircle">清除</el-button>
                </li>
                <li>
                    可视域分析
                    <el-switch
                        v-model="visualShow"
                        :active-value="true"
                        :inactive-value="false"
                        @change="visualChange"
                    ></el-switch>
                </li>
            </ul>
        </template>
    </public-box>
</template>
 
<script>
 
let sunlightLayer = null
let tileset = null
let plot = null
 
let visualLayer = null
let visualTileset = null
 
export default {
    data () {
        return {
            sunlightShow: false,
            visualShow: false
        }
    },
    mounted () {
        plot = new global.DC.Plot(global.viewer, {
            clampToGround: false
        })
 
        global.viewer.use(new global.DC.Analysis())
    },
    methods: {
        closeModel () {
            this.$router.push('/pcLayout/default')
        },
        loadSunlight () {
            sunlightLayer = new global.DC.TilesetLayer('sunlightLayer')
            global.viewer.addLayer(sunlightLayer)
            tileset = new global.DC.Tileset(
                'http://resource.dvgis.cn/data/3dtiles/ljz/tileset.json'
            )
            const style = new global.DC.TilesetStyle()
            style.color = {
                conditions: [
                    ['${Height} >= 300', 'rgba(45, 0, 75, 0.5)'],
                    ['${Height} >= 200', 'rgb(102, 71, 151)'],
                    ['${Height} >= 100', 'rgb(170, 162, 204)'],
                    ['${Height} >= 50', 'rgb(224, 226, 238)'],
                    ['${Height} >= 25', 'rgb(252, 230, 200)'],
                    ['${Height} >= 10', 'rgb(248, 176, 87)'],
                    ['${Height} >= 5', 'rgb(198, 106, 11)'],
                    ['true', 'rgb(127, 59, 8)']
                ]
            }
            tileset.setStyle(style)
            sunlightLayer.addOverlay(tileset)
            global.viewer.flyTo(tileset)
 
            global.viewer.analysis.shadows(new Date(), 1600)
        },
        removeSunlight () {
            global.viewer.analysis.deactivate(global.DC.AnalysisType.SHADOWS)
            tileset != null && sunlightLayer.removeOverlay(tileset)
            sunlightLayer != null && global.viewer.removeLayer(sunlightLayer)
            tileset = null
            sunlightLayer = null
        },
        sunlightChange (e) {
            if (e) {
                this.loadSunlight()
            } else {
                this.removeSunlight()
            }
        },
        drawCircle () {
            global.viewer.analysis.deactivate(global.DC.AnalysisType.SIGHT_CIRCLE)
            plot.draw(global.DC.OverlayType.CIRCLE, overlay => {
                global.viewer.analysis.sightCircle(overlay.center, overlay.radius, [])
            })
        },
        removeCircle () {
            global.viewer.analysis.deactivate(global.DC.AnalysisType.SIGHT_CIRCLE)
        },
        loadVisual () {
            this.$EventBus.$emit('chinaDx', 'remove')
            visualLayer = new global.DC.TilesetLayer('visualLayer').addTo(global.viewer)
            visualTileset = new global.DC.Tileset('http://resource.dvgis.cn/data/3dtiles/dayanta/tileset.json')
            visualTileset.setHeight(-420)
            visualLayer.addOverlay(visualTileset)
            global.viewer.flyTo(visualTileset)
            global.viewer.analysis.viewshed('108.95772292882747,34.22122559229137,20,130', 400, 60, 1.3)
        },
        removeVisual () {
            this.$EventBus.$emit('chinaDx', 'add')
            global.viewer.analysis.deactivate(global.DC.AnalysisType.VIEWSHED)
            visualTileset != null && visualLayer.removeOverlay(visualTileset)
            visualLayer != null && global.viewer.removeLayer(visualLayer)
            visualTileset = null
            visualLayer = null
        },
        visualChange (e) {
            if (e) {
                this.loadVisual()
            } else {
                this.removeVisual()
            }
        }
    },
    destroyed () {
        this.removeSunlight()
        this.removeCircle()
        this.removeVisual()
    }
}
</script>
 
<style lang="sass" scoped>
.move
    cursor: move
</style>