|
|
@@ -39,15 +39,11 @@ export const mapMixin = {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- // 设置相机位置
|
|
|
- setCamera() {
|
|
|
- let center = CesiumUtil.degrees2Car3(104.1629, 30.0039, 3e3)
|
|
|
- this.cesiumUitl.setView(center)
|
|
|
- },
|
|
|
// 初始化
|
|
|
initDefectMap() {
|
|
|
- let psource = this.viewer.dataSources.getByName(this.pSname)[0],
|
|
|
- dsource = this.viewer.dataSources.getByName(this.dSname)[0]
|
|
|
+ console.log('加载管线')
|
|
|
+ let psource = this.getSource(this.pSname),
|
|
|
+ dsource = this.getSource(this.dSname)
|
|
|
if (psource && dsource && [...dsource.entities.values, ...psource.entities.values].length !== 0) {
|
|
|
this.setPipeAndDefectVisible()
|
|
|
} else {
|
|
|
@@ -58,9 +54,8 @@ export const mapMixin = {
|
|
|
let { strucDefectFeatures, funcDefectFeatures, pipeDefectFeatures } = this.getFeatures(data)
|
|
|
if ([...strucDefectFeatures, ...funcDefectFeatures, ...pipeDefectFeatures].length !== 0) {
|
|
|
let lines = [...strucDefectFeatures, ...funcDefectFeatures]
|
|
|
- lines.length = 1000
|
|
|
+ this.cesiumUitl.flyTo(lines[0])
|
|
|
this.addLines(lines)
|
|
|
- pipeDefectFeatures.length = 5000
|
|
|
this.addDefects(pipeDefectFeatures)
|
|
|
this.setPipeAndDefectVisible()
|
|
|
}
|
|
|
@@ -70,7 +65,7 @@ export const mapMixin = {
|
|
|
},
|
|
|
// 设置图层显隐
|
|
|
setSourceVisible (sourceName, visible) {
|
|
|
- let source = this.viewer.dataSources.getByName(sourceName)[0]
|
|
|
+ let source = this.getSource(sourceName)
|
|
|
let entities = source.entities.values
|
|
|
entities.forEach(e => { e.show = visible })
|
|
|
},
|
|
|
@@ -85,15 +80,10 @@ export const mapMixin = {
|
|
|
removeEvent () {
|
|
|
this.handleManage.remove(this.clkHanderIndex)
|
|
|
this.removeListener && this.removeListener()
|
|
|
- this.data.that.$refs.popupwindow.removePopupWindow()
|
|
|
+ this.data.that.$refs.popupwindow && this.data.that.$refs.popupwindow.removePopupWindow()
|
|
|
},
|
|
|
removeLightFeas () {
|
|
|
- let primitives = this.lightPrimitiveCollection
|
|
|
- let l = primitives.length
|
|
|
- for(let i = 0; i < l; i++) {
|
|
|
- let p = primitives.get(i)
|
|
|
- primitives.remove(p)
|
|
|
- }
|
|
|
+ this.lightPrimitiveCollection.removeAll()
|
|
|
},
|
|
|
// 初始化事件
|
|
|
initEvent () {
|
|
|
@@ -106,7 +96,6 @@ export const mapMixin = {
|
|
|
type = data[this.geometryType]
|
|
|
this.data.that.$refs.popupwindow.showPopupWindow(rayPoint, pick.id[this.propertyName], type)
|
|
|
}
|
|
|
-
|
|
|
this.removeLightFeas()
|
|
|
// 高亮
|
|
|
let fieldText = this.lightFeaText
|
|
|
@@ -146,7 +135,6 @@ export const mapMixin = {
|
|
|
let sFea = this.getEntity('line', lineCar3, { color: scolor }, { ...defect, lineCar3 })
|
|
|
sFea && features.strucDefectFeatures.push(sFea)
|
|
|
|
|
|
-
|
|
|
// 功能性
|
|
|
// let fcolor = findFuncColor ? findFuncColor.color : defaultColor
|
|
|
// let fFea = this.getPrimity('line', lineCar3, { color: fcolor }, { ...defect, lineCar3 })
|
|
|
@@ -193,21 +181,27 @@ export const mapMixin = {
|
|
|
if (!Array.isArray(lines)) {
|
|
|
lines = [lines]
|
|
|
}
|
|
|
+ let dataSource = this.getSource(this.pSname)
|
|
|
lines.forEach(line => {
|
|
|
- this.pDataSource.entities.add(line)
|
|
|
+ dataSource.entities.add(line)
|
|
|
})
|
|
|
},
|
|
|
+ // 获取图层
|
|
|
+ getSource(name) {
|
|
|
+ return this.viewer.dataSources.getByName(name)[0]
|
|
|
+ },
|
|
|
// 加载缺陷
|
|
|
addDefects (defects) {
|
|
|
if (!Array.isArray(defects)) {
|
|
|
defects = [defects]
|
|
|
}
|
|
|
+ let dataSource = this.getSource(this.dSname)
|
|
|
defects.forEach(defect => {
|
|
|
- this.dDataSource.entities.add(defect)
|
|
|
+ dataSource.entities.add(defect)
|
|
|
})
|
|
|
},
|
|
|
// 获取图元
|
|
|
- getPrimity (type, positions, style, data) {
|
|
|
+ getPrimity (type, positions, style, data = {}) {
|
|
|
data[this.geometryType] = 'line'
|
|
|
let primitive = this.graphicUtil.getPrimity(type, positions, style, {[this.propertyName]: data})
|
|
|
return primitive
|
|
|
@@ -219,13 +213,70 @@ export const mapMixin = {
|
|
|
entity[this.propertyName] = data
|
|
|
return entity
|
|
|
},
|
|
|
- cesiumDestroy (){
|
|
|
- this.removeEvent()
|
|
|
- let sources = this.viewer.dataSources
|
|
|
- let pS = sources.getByName(this.pSname)
|
|
|
- let dS = sources.getByName(this.dSname)
|
|
|
- pS.entities.values.forEach(e => pS.entities.remove(e))
|
|
|
- dS.entities.values.forEach(e => pS.entities.remove(e))
|
|
|
+ removeCesiumGraphics (){
|
|
|
+ let pS = this.getSource(this.pSname)
|
|
|
+ let dS = this.getSource(this.dSname)
|
|
|
+ pS.entities.removeAll()
|
|
|
+ dS.entities.removeAll()
|
|
|
+ },
|
|
|
+ // 高亮并设置相机位置
|
|
|
+ // 0: 缺陷 1: 管线 2: 报告
|
|
|
+ setViewFromFeas(id, type) {
|
|
|
+ this.data.that.$refs.popupwindow.removePopupWindow()
|
|
|
+ this.removeLightFeas()
|
|
|
+ let idText = ['id', 'expNo', 'wordId'][type],
|
|
|
+ height = [150, 500, 6000],
|
|
|
+ center,
|
|
|
+ findFeas = []
|
|
|
+ if (type) {
|
|
|
+ let pEntities = this.getSource(this.pSname).entities.values
|
|
|
+ findFeas = pEntities.filter(e => e[this.propertyName][idText] === id).map(i => i[this.propertyName])
|
|
|
+ let features = this.getLightFeatures(findFeas)
|
|
|
+ center = this.cesiumUitl.getCenterFormFeas(features.map(f => f.geometryInstances.id[this.propertyName].coors))
|
|
|
+ features.forEach(f => this.lightPrimitiveCollection.add(f))
|
|
|
+ } else {
|
|
|
+ let dEntities = this.getSource(this.dSname).entities.values
|
|
|
+ findFeas = dEntities.filter(e => e[this.propertyName][idText] === id).map(i => i[this.propertyName])
|
|
|
+ let { x, y } = JSON.parse(findFeas[0]['geometry'])
|
|
|
+ let [lon, lat] = this.projUtil.transform([x, y], this.currentDataProjName, 'proj84')
|
|
|
+ center = [lon, lat]
|
|
|
+ }
|
|
|
+
|
|
|
+ if (center) {
|
|
|
+ if (type !== 2) {
|
|
|
+ this.cesiumUitl.setView(CesiumUtil.degrees2Car3(center[0], center[1], height[type]), () => {
|
|
|
+ let car3 = CesiumUtil.degrees2Car3(center[0], center[1], 0)
|
|
|
+ let winPos = this.cesiumUitl.car32WindowPosition(car3)
|
|
|
+ let geotype = type ? 'line' : 'point'
|
|
|
+ let rayPoint = this.viewer.scene.globe.pick(this.viewer.scene.camera.getPickRay(winPos), this.viewer.scene);
|
|
|
+ this.data.that.$refs.popupwindow.showPopupWindow(rayPoint, findFeas[0], geotype)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.$message.error('该点无位置信息');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 获取高亮的要素
|
|
|
+ getLightFeatures(data) {
|
|
|
+ let that = this
|
|
|
+ let features = [], lightColor = 'rgba(0, 255, 255, 0.6)'
|
|
|
+ data.forEach(defect => {
|
|
|
+ let { endPointXLocation, endPointYLocation, startPointXLocation, startPointYLocation } = defect
|
|
|
+ if (startPointXLocation && startPointYLocation && endPointXLocation && endPointYLocation) {
|
|
|
+ let startPoint = this.projUtil.transform([Number(startPointXLocation), Number(startPointYLocation)], this.currentDataProjName, 'proj84')
|
|
|
+ let endPoint = this.projUtil.transform([Number(endPointXLocation), Number(endPointYLocation)], this.currentDataProjName, 'proj84')
|
|
|
+
|
|
|
+ let lineCar3 = CesiumUtil.degreesArray2Car3([startPoint, endPoint].flat())
|
|
|
+ let fea = this.getPrimity('line', lineCar3, { color: lightColor, width: 7 }, { ...defect, coors: [startPoint, endPoint]})
|
|
|
+ if (!isExist(defect.expNo)) {
|
|
|
+ features.push(fea)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return features
|
|
|
+ function isExist (expNo) {
|
|
|
+ return features.some(f => f.geometryInstances.id[that.propertyName].expNo === expNo)
|
|
|
+ }
|
|
|
},
|
|
|
},
|
|
|
mounted() {
|
|
|
@@ -248,17 +299,17 @@ export const mapMixin = {
|
|
|
this.viewer.scene.primitives.add(this.lightPrimitiveCollection)
|
|
|
|
|
|
// 缺陷,管道
|
|
|
- if (!dataSources.getByName(this.pSname)[0]) {
|
|
|
+ if (!this.getSource(this.pSname)) {
|
|
|
this.pDataSource = new Cesium.CustomDataSource(this.pSname)
|
|
|
dataSources.add(this.pDataSource)
|
|
|
}
|
|
|
- if (!dataSources.getByName(this.dSname)[0]) {
|
|
|
+ if (!this.getSource(this.dSname)) {
|
|
|
this.dDataSource = new Cesium.CustomDataSource(this.dSname)
|
|
|
dataSources.add(this.dDataSource)
|
|
|
}
|
|
|
|
|
|
// 设置相机
|
|
|
- this.setCamera()
|
|
|
+ // this.setCamera()
|
|
|
// 加载管线,缺陷
|
|
|
this.initDefectMap()
|
|
|
// 点击事件
|
|
|
@@ -271,6 +322,7 @@ export const mapMixin = {
|
|
|
},
|
|
|
watch: {
|
|
|
'$store.state.app.activeSideItem': function(n, o) {
|
|
|
+ if (n === '工程管理') { this.$store.dispatch('map/mapLaoding', false) }
|
|
|
this.setPipeAndDefectVisible()
|
|
|
}
|
|
|
}
|