|
|
|
/**
|
|
|
|
* 加载区域
|
|
|
|
* 用于EarthComp.vue
|
|
|
|
*/
|
|
|
|
import { defHttp } from '/@/utils/http/axios';
|
|
|
|
import { addPin } from '@/utils/earthMap/earthObj';
|
|
|
|
import { useUserStore } from '/@/store/modules/user';
|
|
|
|
import { useEarthMapStore } from '/@/store/modules/earthMap';
|
|
|
|
import { earthMapUrl } from '@/api/earth/earthMap'
|
|
|
|
import hidePng from '@/assets/earthMap/hide.png';
|
|
|
|
import { nextTick } from 'vue';
|
|
|
|
import $ from 'jquery';
|
|
|
|
|
|
|
|
let userStore = useUserStore();
|
|
|
|
let store = useEarthMapStore();
|
|
|
|
export default function getLineInfo(models, type) {
|
|
|
|
console.log("加载区域");
|
|
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
//请求线路信息
|
|
|
|
defHttp
|
|
|
|
.get(
|
|
|
|
{
|
|
|
|
url: earthMapUrl.queryLineList,
|
|
|
|
params: {
|
|
|
|
pageNo: 1,
|
|
|
|
pageSize: 99999,
|
|
|
|
sceneId: userStore.userInfo?.sceneId + '*',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ isTransformResponse: false }
|
|
|
|
)
|
|
|
|
.then(async (res) => {
|
|
|
|
// console.log('加载区域',res);
|
|
|
|
if (res.success) {
|
|
|
|
//一级区域
|
|
|
|
let parentArea: any = [];
|
|
|
|
//二级区域
|
|
|
|
let childArea: any = [];
|
|
|
|
res.result.records.forEach((data) => {
|
|
|
|
if (data.parentCode) {
|
|
|
|
childArea.push(data);
|
|
|
|
} else {
|
|
|
|
parentArea.push(data);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
parentArea.forEach((data) => {
|
|
|
|
// console.log(data);
|
|
|
|
|
|
|
|
// data.sceneId
|
|
|
|
let updatedPositions: any = [];
|
|
|
|
let positionsData = JSON.parse(data.positions);
|
|
|
|
if (!positionsData) {
|
|
|
|
positionsData = [];
|
|
|
|
}
|
|
|
|
updatedPositions = positionsData;
|
|
|
|
|
|
|
|
let lineOptions: any = {
|
|
|
|
maxShowHeight: 30000,
|
|
|
|
customProp: data.lineCode,
|
|
|
|
};
|
|
|
|
lineOptions.name = data.name;
|
|
|
|
lineOptions.xbsjType = 'Polyline';
|
|
|
|
lineOptions.width = data.width;
|
|
|
|
lineOptions.positions = updatedPositions;
|
|
|
|
lineOptions.loop = Boolean(data.isLoop);
|
|
|
|
lineOptions.depthTest = Boolean(data.isDepthCheck);
|
|
|
|
lineOptions.arcType = data.interpolation;
|
|
|
|
let material: any = {};
|
|
|
|
switch (data.materialType) {
|
|
|
|
// 实线
|
|
|
|
case 0:
|
|
|
|
material.type = 'XbsjColorMaterial';
|
|
|
|
material.XbsjColorMaterial = {};
|
|
|
|
if (!data.color || data.color.length <= 0) {
|
|
|
|
data.color = '[1,1,1,1]';
|
|
|
|
}
|
|
|
|
material.XbsjColorMaterial.color = JSON.parse(data.color);
|
|
|
|
break;
|
|
|
|
// 虚线
|
|
|
|
case 1:
|
|
|
|
material.type = 'XbsjPolylineDashMaterial';
|
|
|
|
material.XbsjPolylineDashMaterial = {};
|
|
|
|
material.XbsjPolylineDashMaterial.color = JSON.parse(data.color);
|
|
|
|
material.XbsjPolylineDashMaterial.gapColor = JSON.parse(data.intervalColor);
|
|
|
|
material.XbsjPolylineDashMaterial.dashLength = data.dashLength;
|
|
|
|
material.XbsjPolylineDashMaterial.dashPattern = data.dashStyle;
|
|
|
|
break;
|
|
|
|
// 箭头线
|
|
|
|
case 2:
|
|
|
|
material.type = 'XbsjPolylineArrowMaterial';
|
|
|
|
material.XbsjPolylineArrowMaterial = {};
|
|
|
|
material.XbsjPolylineArrowMaterial.color = JSON.parse(data.color);
|
|
|
|
break;
|
|
|
|
// 轨迹线
|
|
|
|
case 3:
|
|
|
|
material.type = 'XbsjODLineMaterial';
|
|
|
|
material.XbsjODLineMaterial = {};
|
|
|
|
material.XbsjODLineMaterial.color = JSON.parse(data.color);
|
|
|
|
material.XbsjODLineMaterial.totoalFrameCount = data.cycleFrame;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
lineOptions.material = material;
|
|
|
|
let currentChildArea: any = [];
|
|
|
|
if (childArea.length) {
|
|
|
|
childArea.forEach((element) => {
|
|
|
|
let obj = {};
|
|
|
|
if (data.id == element.parentCode) {
|
|
|
|
obj = {
|
|
|
|
expand: false,
|
|
|
|
title: element.name,
|
|
|
|
ref: 'nodeSecondary_' + element.id,
|
|
|
|
children: [],
|
|
|
|
};
|
|
|
|
let updatedPositions: any = [];
|
|
|
|
let positionsData = JSON.parse(element.positions);
|
|
|
|
if (!positionsData) {
|
|
|
|
positionsData = [];
|
|
|
|
}
|
|
|
|
updatedPositions = positionsData;
|
|
|
|
let lineOptions: any = {
|
|
|
|
maxShowHeight: 30000,
|
|
|
|
customProp: element.lineCode,
|
|
|
|
};
|
|
|
|
lineOptions.name = element.name;
|
|
|
|
lineOptions.xbsjType = 'Polyline';
|
|
|
|
lineOptions.width = element.width;
|
|
|
|
lineOptions.positions = updatedPositions;
|
|
|
|
lineOptions.loop = Boolean(element.isLoop);
|
|
|
|
lineOptions.depthTest = Boolean(element.isDepthCheck);
|
|
|
|
lineOptions.arcType = element.interpolation;
|
|
|
|
let material: any = {};
|
|
|
|
switch (element.materialType) {
|
|
|
|
// 实线
|
|
|
|
case 0:
|
|
|
|
material.type = 'XbsjColorMaterial';
|
|
|
|
material.XbsjColorMaterial = {};
|
|
|
|
if (!element.color || element.color.length <= 0) {
|
|
|
|
element.color = '[1,1,1,1]';
|
|
|
|
}
|
|
|
|
material.XbsjColorMaterial.color = JSON.parse(element.color);
|
|
|
|
break;
|
|
|
|
// 虚线
|
|
|
|
case 1:
|
|
|
|
material.type = 'XbsjPolylineDashMaterial';
|
|
|
|
material.XbsjPolylineDashMaterial = {};
|
|
|
|
material.XbsjPolylineDashMaterial.color = JSON.parse(element.color);
|
|
|
|
material.XbsjPolylineDashMaterial.gapColor = JSON.parse(element.intervalColor);
|
|
|
|
material.XbsjPolylineDashMaterial.dashLength = element.dashLength;
|
|
|
|
material.XbsjPolylineDashMaterial.dashPattern = element.dashStyle;
|
|
|
|
break;
|
|
|
|
// 箭头线
|
|
|
|
case 2:
|
|
|
|
material.type = 'XbsjPolylineArrowMaterial';
|
|
|
|
material.XbsjPolylineArrowMaterial = {};
|
|
|
|
material.XbsjPolylineArrowMaterial.color = JSON.parse(element.color);
|
|
|
|
break;
|
|
|
|
// 轨迹线
|
|
|
|
case 3:
|
|
|
|
material.type = 'XbsjODLineMaterial';
|
|
|
|
material.XbsjODLineMaterial = {};
|
|
|
|
material.XbsjODLineMaterial.color = JSON.parse(element.color);
|
|
|
|
material.XbsjODLineMaterial.totoalFrameCount = element.cycleFrame;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
let pos = [0, 0, 0];
|
|
|
|
positionsData.forEach((element) => {
|
|
|
|
pos[0] += element[0];
|
|
|
|
pos[1] += element[1];
|
|
|
|
pos[2] += element[2];
|
|
|
|
});
|
|
|
|
pos[0] = pos[0] / positionsData.length;
|
|
|
|
pos[1] = pos[1] / positionsData.length;
|
|
|
|
pos[2] = pos[2] / positionsData.length;
|
|
|
|
let pinBuilder = {
|
|
|
|
extTextFont: '30px 宋体',
|
|
|
|
extTextPixelOffset: [-40, 10],
|
|
|
|
fillColor: [0, 0.3450980392156863, 1, 0.9],
|
|
|
|
outlineColor: [1, 1, 1, 1],
|
|
|
|
extText: element.name,
|
|
|
|
};
|
|
|
|
let pin = addPin(element.name, hidePng, { position: pos, scale: 0.8, pinBuilder, far: 107374 });
|
|
|
|
lineOptions.pinXbsjGuid = pin.xbsjGuid;
|
|
|
|
lineOptions.material = material;
|
|
|
|
// that._earth.sceneTree.root.children.push({ czmObject: lineOptions, ref: element.id });
|
|
|
|
window.$earth.sceneTree.root.children.push({ czmObject: lineOptions, ref: element.id });
|
|
|
|
currentChildArea.push(obj);
|
|
|
|
// 如果是总部
|
|
|
|
if (type == 1) {
|
|
|
|
store.nodeConfigByRef.set('nodeSecondary_' + element.id, obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
//配置信息
|
|
|
|
const node = {
|
|
|
|
ref: 'node_' + data.id,
|
|
|
|
expand: false,
|
|
|
|
title: '<防区>' + data.name,
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
expand: false,
|
|
|
|
title: '监控点位',
|
|
|
|
ref: 'monitor_' + window.guid(),
|
|
|
|
children: [],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
expand: false,
|
|
|
|
title: '雷达点位',
|
|
|
|
ref: 'ldList_' + window.guid(),
|
|
|
|
children: currentChildArea,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
expand: false,
|
|
|
|
title: '微波点位',
|
|
|
|
ref: 'wbList_' + window.guid(),
|
|
|
|
children: [],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
if (data.sceneId == models.ref) {
|
|
|
|
// console.log("当前场景下");
|
|
|
|
|
|
|
|
//该防区为当前场景下
|
|
|
|
//压入树
|
|
|
|
models.children.push(node);
|
|
|
|
store.nodeConfigByRef.set(node.ref, node);
|
|
|
|
store.areaByNodeId.set(node.ref, data.sceneId);
|
|
|
|
// return
|
|
|
|
} else {
|
|
|
|
const childs = models.children;
|
|
|
|
for (const child of childs) {
|
|
|
|
if (child.ref == data.sceneId) {
|
|
|
|
//该防区为子场景下
|
|
|
|
// console.log("子场景下");
|
|
|
|
child.children.push(node);
|
|
|
|
store.nodeConfigByRef.set(node.ref, node);
|
|
|
|
store.areaByNodeId.set(node.ref, data.sceneId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//放进世界场景树
|
|
|
|
window.$earth.sceneTree.root.children.push({ czmObject: lineOptions, ref: data.id });
|
|
|
|
});
|
|
|
|
//加载二级区域模型
|
|
|
|
childArea.forEach((data) => {});
|
|
|
|
nextTick(() => {
|
|
|
|
const divs = $('#earthContainer>div>div>div:nth-child(5)')
|
|
|
|
.children('div')
|
|
|
|
.eq(1)
|
|
|
|
.children()
|
|
|
|
.eq(0)
|
|
|
|
.children()
|
|
|
|
.eq(0)
|
|
|
|
.children()
|
|
|
|
.each((index, element) => {
|
|
|
|
// const paddingLeft = $(element).children().eq(0).css('padding-left')
|
|
|
|
$(element).css('display', 'none');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
// console.log("models",models);
|
|
|
|
resolve(models);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|