Files
4.0/src/renderer/components/LeftMenu/secondMenuFun111.js
2025-08-22 10:33:34 +08:00

1872 lines
56 KiB
JavaScript

import {
getSelectedNode,
getNodeData,
cusAddNodes,
cusRenderNode,
getKeyOfSelectedNode,
nodeType,
findParentId,
} from "@/components/Tree/treeNode";
import {
addSource,
addPanorama,
queryRoute,
addPicture,
addSituation,
} from "@/api/gisAPI";
import { getNamefromPath, getIP } from "../../utils";
import {
processBase64Images,
combineBase64Images,
} from "../../utils/HighDefinitionScreenshot";
import {
$changeComponentShow,
$recvElectronChanel,
$sendElectronChanel,
} from "../../utils/communication";
import fs from "fs";
import dayjs from "dayjs";
import {
renderWater,
renderDiffuseScan,
renderRadarScan,
renderWallStereoscopic,
renderRoad,
renderSmoke,
renderExplosion,
renderPolyhedronObject,
renderScanStereoscopic,
renderPressModel,
renderPicture,
renderFountain,
renderShp,
renderSpout,
renderEllipse,
renderSector,
renderFlyLine,
} from "../Tree/renderNode";
import { shpTotalDict } from "../../api/shpTotalDict";
import e from "express";
let newp_id = "特效图层"
let model_p_id = "模型图层"
const secondMenuFun = {
data() {
return {
pickStatus: false,
rainStatus: false,
snowStatus: false,
fogStatus: false,
lightStatus: false,
graffitiStatus: false,
treeObj: null,
viewed: null,
perspectiveStatus: false,
graffitiObj: null,
// visualFieldAnalysis_data: null,//可视域
// slopeDirection_data: null,//坡度坡向
// cutFill_data: null,//土方分析
// profileAnalysis_data: null,//剖面分析
// inundationAnalysis_data: null,//淹没分析
};
},
mounted() {
this.$recvChanel("getTreeObj", (treeObj) => {
this.treeObj = treeObj;
this.$removeChanel("getTreeObj");
});
},
methods: {
// 海东1021
// 物资搜索
goodsSearchPolgon() {
if (window.checkAuthIsValid) {
let draw = new YJ.Draw.DrawPolygon(window.Earth1);
draw.start((err, params) => {
console.log("sssssss", err, params);
if (!err && params.length > 2) {
$root_home_index.goodSearchDialog = true;
let nodes = this.booleanOverlaps(params, "polygon");
this.renderCanvas(nodes);
}
});
} else {
this.$message({
message: "您没有该功能的权限",
type: "warning",
});
}
},
renderCanvas(nodes) {
console.log("nodes", nodes);
let x = [];
let y = [];
nodes.forEach((item) => {
// shp物资统计
if (item.source_type == "Feature") {
let obj = JSON.parse(JSON.stringify(item.detail.properties));
for (const key in obj) {
let name = key;
if (shpTotalDict[key]) {
name = shpTotalDict[key];
// 把相同名称的物资数量相加,名称相同时,累加数据
let index = x.findIndex((item) => item === name);
if (index !== -1) {
y[index] = y[index] + Number(obj[key]);
} else {
x.push(name);
y.push(Number(obj[key]));
}
}
}
}
if (item.detail.attribute && item.detail.attribute.goods) {
let goods = item.detail.attribute.goods.content;
console.log("goods", goods);
if (goods.length) {
// $root_home_index.goodSearchDialog = false;
goods.forEach((good) => {
// 把相同名称的物资数量相加,名称相同时,累加数据
let index = x.findIndex((item) => item === good.name);
if (index !== -1) {
y[index] = y[index] + Number(good.cnt);
} else {
x.push(good.name);
y.push(Number(good.cnt));
}
});
}
}
});
console.log("x,y");
console.log(x);
console.log(y);
let notZeroX = [];
let notZeroY = [];
for (let i = 0; i < y.length; i++) {
if (y[i] != 0) {
notZeroX.push(x[i]);
notZeroY.push(y[i]);
}
}
console.log(notZeroX);
console.log(notZeroY);
x = notZeroX;
y = notZeroY;
if (!x.length) $root_home_index.goodSearchDialog = false;
if ($root_home_index.goodSearchDialog) {
this.$nextTick(() => {
let option = {
grid: {
top: "20%",
left: "5%",
right: "5%",
bottom: "8%",
containLabel: true,
},
tooltip: {
trigger: "axis",
axisPointer: {
type: "shadow",
label: {
show: true,
},
},
formatter(params) {
var data = "";
for (var i = 0; i < params.length; i++) {
if (params[i].seriesName == "随访率") {
data +=
params[i].seriesName + ": " + params[i].value + "%";
} else {
data +=
params[i].seriesName + ": " + params[i].value + "<br/>";
}
}
return data;
},
},
legend: {
data: ["总量"],
top: "5%",
left: "5%",
right: "5%",
bottom: "5%",
textStyle: {
color: "#fff",
},
},
xAxis: {
// type: "category",
axisLine: {
show: false,
},
axisTick: {
show: false,
},
axisLabel: {
show: true,
width: 40, //将内容的宽度固定
overflow: "truncate", //超出的部分截断
truncate: "...", //截断的部分用...代替
rotate: 30,
interval: 0,
textStyle: {
color: "#fff", //X轴文字颜色
},
},
},
yAxis: [
{
type: "value",
name: "(数量)",
nameTextStyle: {
color: "#fff",
},
splitLine: {
show: true,
lineStyle: {
color: "#eeeeee",
},
},
axisTick: {
show: false,
},
axisLine: {
show: false,
},
axisLabel: {
show: true,
textStyle: {
color: "#fff",
},
},
},
{
type: "value",
gridIndex: 0,
min: 50,
max: 100,
splitNumber: 8,
splitLine: {
show: false,
},
axisLine: {
show: false,
},
axisTick: {
show: false,
},
axisLabel: {
show: false,
},
splitArea: {
show: false,
areaStyle: {
color: ["rgba(250,250,250,0.0)", "rgba(250,250,250,0.05)"],
},
},
},
],
series: [
{
name: "数量",
type: "bar",
label: {
show: true,
position: "top",
},
barWidth: 15,
itemStyle: {
normal: {
color: "#fdcb6c",
},
},
},
],
};
var dom = document.getElementById("goodSearchEchart");
var myChart = echarts.init(dom);
option.xAxis.data = x;
option.series[0].data = y;
myChart.setOption(option);
});
} else {
this.$message.warning("该区域没有物资");
}
},
// 物资搜索
goodsSearchCircle() {
if (window.checkAuthIsValid) {
let draw = new YJ.Draw.DrawCircle(window.Earth1);
draw.start((err, positions) => {
console.log("err, positions", err, positions);
if (!err && positions.center.lng) {
$root_home_index.goodSearchDialog = true;
let nodes = this.booleanOverlaps(positions);
console.log("goodsSearchCircle", nodes);
this.renderCanvas(nodes);
}
});
} else {
this.$message({
message: "您没有该功能的权限",
type: "warning",
});
}
},
// 海东1021
booleanOverlaps(positions1, flag = "circle") {
let cross = undefined;
function set3Array(positions) {
let arr = [];
positions.forEach((item) => {
arr.push([item.lng, item.lat]);
});
arr.push(arr[0]);
return arr;
}
let getNode = (types) => {
let treeObj = $.fn.zTree.getZTreeObj("treeDemo");
let res = [];
types.forEach((type) => {
let nodes = treeObj.getNodesByParam("source_type", type, null);
// console.log("nodes",nodes)
res = res.concat(nodes);
});
return res;
};
//绘制的区域
// console.log("[set3Array(positions1)]", [set3Array(positions1)])
// 获取物资处(特定的标注类型)
let allNodes = getNode(["point", "vr", "picture", "Feature"]);
console.log("allNodes", allNodes);
let itemInArea = []; //区域内的类型符合的标注
for (let i = 0; i < allNodes.length; i++) {
let item = allNodes[i];
let getAllItemInArea = (lng, lat) => {
if (flag == "circle") {
let { center, radius } = positions1;
let centerDegress = Cesium.Cartesian3.fromDegrees(
center.lng,
center.lat
);
let point = Cesium.Cartesian3.fromDegrees(lng, lat);
let distance = Cesium.Cartesian3.distance(point, centerDegress);
distance < radius && itemInArea.push(item);
} else {
let polygon1 = turf.polygon([set3Array(positions1)]);
let pt = turf.point([lng, lat]);
turf.booleanPointInPolygon(pt, polygon1) && itemInArea.push(item);
}
};
switch (item.source_type) {
case "point":
case "vr":
case "picture":
let lng = item.detail.positions.lng;
let lat = item.detail.positions.lat;
getAllItemInArea(lng, lat);
break;
case "Feature":
if (item.detail.geometry.type == "Point") {
lng = item.detail.geometry.coordinates[0];
lat = item.detail.geometry.coordinates[1];
getAllItemInArea(lng, lat);
}
break;
}
}
return itemInArea;
},
//道路
roadDraw() {
let option = {
imageType: "asphaltRoad",
name: "道路",
};
this.road(option);
},
road(option) {
let selectedNode = getSelectedNode(this.treeObj);
let draw = new YJ.Draw.DrawPolyline();
draw.start((err, params) => {
if (params.length > 1) {
option.positions = params;
let source_id = this.$md5(new Date().getTime() + option.name);
let DbOption = {
source_id,
source_name: option.name,
source_type: "road",
p_id: newp_id,
};
let detailOption = JSON.parse(JSON.stringify(option));
let node = getNodeData(DbOption, detailOption);
// renderRoad(node);
addSource(node).then((res) => {
if ([0, 200].includes(res.code)) {
cusRenderNode(DbOption);
cusAddNodes(this.treeObj, DbOption.p_id, [node]);
}
});
// new YJ.Efflect.Road(option);
}
});
},
//路线
lineDraw() {
let option = {
imageType: "arrowRoad",
name: "路线",
};
this.road(option);
},
//爆炸
explosion() {
let selectedNode = getSelectedNode(this.treeObj);
let draw = new YJ.Draw.DrawPoint(window.Earth1);
draw.start((err, params) => {
if (params != undefined) {
let option = {
position: params,
scaleByDistance: true,
};
let source_id = this.$md5(new Date().getTime() + "爆炸");
let DbOption = {
source_id,
source_name: "爆炸",
source_type: "explosion",
p_id: newp_id,
};
let detailOption = JSON.parse(JSON.stringify(option));
let node = getNodeData(DbOption, detailOption);
// renderExplosion(node);
addSource(node).then((res) => {
if ([0, 200].includes(res.code)) {
cusRenderNode(DbOption);
cusAddNodes(this.treeObj, DbOption.p_id, [node]);
}
});
}
});
},
//喷泉
fountain() {
let draw = new YJ.Draw.DrawPoint(window.Earth1);
draw.start((err, params) => {
if (params != undefined) {
let option = {
position: params,
};
let source_id = this.$md5(new Date().getTime() + "喷泉");
let DbOption = {
source_id,
source_name: "喷泉",
source_type: "fountain",
p_id: newp_id,
};
let detailOption = JSON.parse(JSON.stringify(option));
let node = getNodeData(DbOption, detailOption);
console.log("getNodeData", node);
// renderFountain(node);
addSource(node).then((res) => {
if ([0, 200].includes(res.code)) {
cusRenderNode(DbOption);
cusAddNodes(this.treeObj, DbOption.p_id, [node]);
}
});
}
});
},
// 烟
smoke() {
let selectedNode = getSelectedNode(this.treeObj);
let draw = new YJ.Draw.DrawPoint(window.Earth1);
draw.start((err, params) => {
if (params != undefined) {
let option = {
position: params,
};
let source_id = this.$md5(new Date().getTime() + "烟");
let DbOption = {
source_id,
source_name: "烟",
source_type: "smoke",
p_id: newp_id,
};
let detailOption = JSON.parse(JSON.stringify(option));
let node = getNodeData(DbOption, detailOption);
// renderSmoke(node);
addSource(node).then((res) => {
if ([0, 200].includes(res.code)) {
cusRenderNode(DbOption);
cusAddNodes(this.treeObj, DbOption.p_id, [node]);
}
});
}
});
},
// 聚合
annotationAggregation(item) {
item.status = !item.status;
YJ.Global.switchCluster(window.Earth1, item.status);
},
// 多面体
multilateralBody() {
let selectedNode = getSelectedNode(this.treeObj);
let draw = new YJ.Draw.DrawPolygon(window.Earth1);
draw.start((err, params) => {
if (params.length > 2) {
let source_id = this.$md5(new Date().getTime() + "多边体");
let DbOption = {
source_id,
source_name: "多边体",
source_type: "PolyhedronObject",
p_id: newp_id,
};
let option = {
polyhedron: {
positions: params,
color: "#00d9ff",
},
height: 10,
};
let detailOption = JSON.parse(JSON.stringify(option));
let node = getNodeData(DbOption, detailOption);
// renderPolyhedronObject(node);
addSource(node).then((res) => {
if ([0, 200].includes(res.code)) {
cusRenderNode(DbOption);
cusAddNodes(this.treeObj, DbOption.p_id, [node]);
}
});
}
});
},
//电子围墙
electronicFence() {
let selectedNode = getSelectedNode(this.treeObj);
let draw = new YJ.Draw.DrawPolyline(window.Earth1);
draw.start((err, params) => {
if (params.length > 1) {
let alt = params[0].alt;
params.forEach((item) => {
if (item.alt < alt) alt = item.alt;
});
let source_id = this.$md5(new Date().getTime() + "围墙");
let DbOption = {
source_id,
source_name: "电子围墙",
source_type: "wallStereoscopic",
p_id: newp_id,
};
let option = {
id: source_id,
positions: params,
color: "#fff",
cornerType: undefined,
extrudedHeight: 2.4,
width: 0.24,
};
let detailOption = JSON.parse(JSON.stringify(option));
let node = getNodeData(DbOption, detailOption);
renderWallStereoscopic(node);
addSource(node).then((res) => {
if ([0, 200].includes(res.code)) {
// cusRenderNode(DbOption);
cusAddNodes(this.treeObj, DbOption.p_id, [node]);
}
});
}
});
},
// 实体墙
entityWall() {
let selectedNode = getSelectedNode(this.treeObj);
let draw = new YJ.Draw.DrawPolyline(window.Earth1);
draw.start((err, params) => {
if (params.length >= 2) {
let source_id = this.$md5(new Date().getTime() + "实体墙");
let DbOption = {
source_id,
source_name: "实体墙",
source_type: "entityWall",
p_id: newp_id,
};
let option = {
positions: params,
color: "#fff",
cornerType: undefined,
extrudedHeight: 2.4,
width: 0.24,
};
let detailOption = JSON.parse(JSON.stringify(option));
let node = getNodeData(DbOption, detailOption);
// renderWall(node);
addSource(node).then((res) => {
if ([0, 200].includes(res.code)) {
cusRenderNode(DbOption);
cusAddNodes(this.treeObj, DbOption.p_id, [node]);
}
});
}
});
},
//雷达光波
diffusedLightWave() {
let draw = new YJ.Draw.DrawCircle(window.Earth1);
draw.start((err, params) => {
if (params) {
let source_id = this.$md5(new Date().getTime() + "雷达光波");
let DbOption = {
source_id,
source_name: "雷达光波",
source_type: "radarScan",
p_id: newp_id,
};
let option = {
center: params.center,
show: true,
id: source_id,
radius: params.radius,
duration: 3000,
color: "#ff0000",
};
let detailOption = JSON.parse(JSON.stringify(option));
let node = getNodeData(DbOption, detailOption);
// renderRadarScan(node, params);
addSource(node).then((res) => {
if ([0, 200].includes(res.code)) {
cusRenderNode(DbOption);
cusAddNodes(this.treeObj, DbOption.p_id, [node]);
}
});
}
});
},
//立体雷达扫描
scanStereoscopic() {
let draw = new YJ.Draw.DrawCircle(window.Earth1);
draw.start((err, params) => {
if (params) {
let source_id = this.$md5(new Date().getTime() + "立体雷达扫描");
let DbOption = {
source_id,
source_name: "立体雷达扫描",
source_type: "scanStereoscopic",
p_id: newp_id,
};
let option = {
center: params.center,
show: true,
id: source_id,
radius: params.radius,
duration: 2000,
};
let detailOption = JSON.parse(JSON.stringify(option));
let node = getNodeData(DbOption, detailOption);
// renderScanStereoscopic(node, params);
addSource(node).then((res) => {
if ([0, 200].includes(res.code)) {
cusRenderNode(DbOption);
cusAddNodes(this.treeObj, DbOption.p_id, [node]);
}
});
}
});
},
//扩散光波
radarLightWave() {
let draw = new YJ.Draw.DrawCircle(window.Earth1);
draw.start((err, params) => {
console.log(params);
if (params) {
let source_id = this.$md5(new Date().getTime() + "扩散光波");
let DbOption = {
source_id,
source_name: "扩散光波",
source_type: "diffuseScan",
p_id: newp_id,
};
let option = {
id: source_id,
center: params.center,
radius: params.radius,
duration: 3000,
color: "#ff0000",
};
let detailOption = JSON.parse(JSON.stringify(option));
let node = getNodeData(DbOption, detailOption);
renderDiffuseScan(node);
addSource(node).then((res) => {
if ([0, 200].includes(res.code)) {
// cusRenderNode(DbOption)
cusAddNodes(this.treeObj, DbOption.p_id, [node]);
}
});
}
});
},
//水面特效
waterSurface() {
let selectedNode = getSelectedNode(this.treeObj);
let draw = new YJ.Draw.DrawPolygon(window.Earth1);
draw.start((err, params) => {
if (params.length > 2) {
let source_id = this.$md5(new Date().getTime() + "水面");
let DbOption = {
source_id,
source_name: "水面",
source_type: "water",
p_id: newp_id,
};
let option = {
id: source_id,
amplitude: 10,
animationSpeed: 1,
color: "rgba(32,67,135,0.5)",
frequency: 10,
ground: true,
positions: params,
};
let detailOption = JSON.parse(JSON.stringify(option));
let node = getNodeData(DbOption, detailOption);
// renderWater(node);
addSource(node).then((res) => {
if ([0, 200].includes(res.code)) {
cusRenderNode(DbOption);
cusAddNodes(this.treeObj, DbOption.p_id, [node]);
}
});
}
});
},
//夹角测量
MeasureAngle() {
new YJ.Measure.MeasureAngle(window.Earth1).start();
},
MeasureAzimuth() {
new YJ.Measure.MeasureAzimuth(window.Earth1).start();
},
clear() {
YJ.Analysis.Clear();
},
rangeQuery() {
this.$changeComponentShow(".echartsTotalBox", true);
$root_home_index.$refs.echartsTotal.init();
},
//热力图
heatMap() {
let draw = new YJ.Draw.DrawPolygon({ earth: window.Earth1.earth });
draw.start((err, positions) => {
if (err) throw err;
else {
let heatMap = new YJ.Obj.HeatMap(window.Earth1.earth, {
positions,
dataLen: 1000,
id: this.$md5(new Date().getTime() + "热力图"),
});
window.analysisArr.push(heatMap);
}
});
},
//坡度坡向
slopeDirection() {
this.viewDestroy("slopeDirection_data");
this.slopeDirection_data = new YJ.Analysis.SlopeAspect(window.Earth1);
// console.log('slopeAspect',slopeAspect);
// this.slopeDirection_data.createNew4Num(20);
// slopeAspect.openTip();
window.analysisArr.push(this.slopeDirection_data);
},
//通视
Intervisibility() {
let Intervisibility = new YJ.Analysis.Visibility(window.Earth1);
Intervisibility.start();
window.analysisArr.push(Intervisibility);
},
//等高线
contour() {
let draw = new YJ.Draw.DrawRect(window.Earth1);
draw.start((a, positions) => {
let contour = new YJ.Analysis.Contour(window.Earth1, {
positions: positions,
});
});
},
//透视
perspective(item) {
item.status = !item.status;
YJ.Global.enablePerspective(window.Earth1.earth, {
status: item.status,
alpha: 0.5,
});
},
//坐标定位
coorLocation() {
this.$changeComponentShow(".flyToLocationBox", true);
let is84 =
window.$root_home_index.$store.state.systemSetting.system.coordinate;
window.$root_home_index.$refs.flyToLocation.init(is84);
},
//可视域
visualFieldAnalysis() {
this.viewDestroy("visualFieldAnalysis_data");
this.visualFieldAnalysis_data = new YJ.Analysis.ViewShed(window.Earth1);
// this.viewed.start();
},
// 视域分析(地形)
visualFieldAnalysis2() {
this.visualFieldAnalysis_data = new YJ.Analysis.CircleViewShed(
window.Earth1
);
},
//单个重新绘制清除上一个
viewDestroy(name) {
if (this[name]) {
this[name].destroy();
this[name] = null;
}
},
//土方分析
cutFill() {
this.viewDestroy("cutFill_data");
// $changeComponentShow(".cutFill", true);
console.log("计算量不要画太大了");
this.cutFill_data = new YJ.Analysis.CutFillAnalysis(window.Earth1);
},
//剖面分析
profileAnalysis() {
this.viewDestroy("profileAnalysis_data");
this.profileAnalysis_data = new YJ.Analysis.Profile(window.Earth1);
//显示分析框
// $changeComponentShow(".profileAnalysis", true);
// this.$sendChanel("profileAnalysis", this.profileAnalysis_data);
},
//淹没分析
inundationAnalysis() {
this.viewDestroy("inundationAnalysis_data");
// $changeComponentShow(".inundationAnalysis", true);
this.inundationAnalysis_data = new YJ.Analysis.Submerge(window.Earth1);
},
clearGraffiti() {
this.graffitiObj.remove();
},
stopGraffiti(item) {
this.graffiti(item);
},
graffiti(item) {
if (this.graffitiObj) {
this.graffitiObj.end();
}
// item.status = !item.status;
// this.$sendChanel("lock");
// if (item.status) {
this.graffitiObj = new YJ.Obj.Graffiti(window.Earth1);
// } else {
// item.name = "graffiti";
// }
},
videoRecord() {
YJ.Global.ScreenRecord.start();
},
editTs(item) {
this.$sendChanel("initTasks", item);
},
tsOnclick(item) {},
newTs(item) {
this.$prompt("请输入态势方案名称", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
inputPattern: /^.+$/,
inputErrorMessage: "名称不能为空",
})
.then(({ value }) => {
let dataObj = {
tasks: [],
};
addSituation(
{ ts_name: value, Ts_data: JSON.stringify(dataObj) },
(res) => {
console.log(res);
}
);
})
.catch(() => {
/*this.$message({
type: 'info',
message: '取消输入'
});*/
});
},
addGlb(item) {
let selectedNode = getSelectedNode(this.treeObj);
if (selectedNode) {
//取点
new YJ.Draw.DrawPoint().start((err, position) => {
if (err == null || err != false) {
let source_id = this.$md5(new Date().getTime() + item.model_name);
let DbOption = {
source_id,
source_name: item.model_name,
source_type: "model",
p_id: DbOption.source_id,
};
let option = {
id: source_id,
position,
url: item.model_url,
};
let Model = new YJ.Obj.Model(option);
window._entityMap.set(option.id, Model);
let detailOption = JSON.parse(JSON.stringify(Model.options));
detailOption.url = item.model_id + ".glb";
let node = getNodeData(DbOption, detailOption);
addSource(node).then((res) => {
if ([0, 200].includes(res.code)) {
// cusRenderNode(DbOption)
cusAddNodes(this.treeObj, model_p_id, [node]);
}
});
}
});
} else {
this.$message.warning("请在图层指挥舱中选中对应图层添加");
}
},
//火焰
fire() {
let selectedNode = getSelectedNode(this.treeObj);
if (selectedNode) {
let source_id = this.$md5(new Date().getTime() + "火焰");
let DbOption = {
source_id,
source_name: "火焰",
source_type: "fire",
p_id: newp_id,
};
let draw = new YJ.Draw.DrawPoint(window.Earth1);
draw.start((err, params) => {
if (params != undefined) {
if (err) throw err;
let detailOption = { position: params };
//获取节点树对象
let node = getNodeData(DbOption, detailOption);
addSource(node).then((res) => {
if ([0, 200].includes(res.code)) {
cusRenderNode(DbOption);
cusAddNodes(this.treeObj, DbOption.p_id, [node]);
}
});
}
});
} else {
this.$message.warning("请在图层指挥舱中选中对应图层添加");
}
},
//清除轨迹运动
clearTrajectoryMotion() {
new YJ.ClearAllRoutePlanning();
},
//轨迹运动
trajectoryMotion() {
// let selectedNode = getSelectedNode(this.treeObj);
// // console.log(selectedNode);
// if (!selectedNode) {
// this.$message.warning("请在图层指挥舱中选中对应图层添加");
// return;
// }
$changeComponentShow(".modelBox", true);
$root_home_index.$refs.model.open("rightMenu");
this.$recvChanel("selectModel", (data) => {
this.$changeComponentShow(".modelSelectBox", false);
let url = data.model_id + ".glb";
console.log("urlurlurlurlurlurl", url);
let draw = new YJ.Draw.DrawPolyline(window.Earth1);
draw.start((err, positions) => {
if (positions.length < 2) {
this.$message.warning("至少两个点");
return;
} else {
let height = 0;
let avgheight = 0;
positions.forEach((item) => {
let val = item.alt || 0;
height += val;
});
avgheight = height / positions.length;
//
let source_id = this.$md5(new Date().getTime() + "轨迹运动");
let DbOption = {
source_id,
source_name: "轨迹运动-" + data.model_name,
source_type: "path",
p_id: newp_id,
};
let trajectoryOption = {
model: {
id: source_id + "model",
url,
show: true,
maximumScale: 500,
},
line: {
show: true,
positions,
noseToTail: false,
smooth: false,
keyPoint: false,
},
id: source_id + "path",
positions,
show: true, //路径显示
currentSpeed: 10, //速度
loop: false, //是否环线
showDirection: false, //显示方向
playing: true, //是否播放
loopPlay: false, //是否循环播放
alwaysAlongThePath: true, //始终沿着路径方向
cameraAttached: true, //相机绑定
cameraAttached1: false, //相机绑定1
height: avgheight,
};
let node = getNodeData(DbOption, trajectoryOption);
cusRenderNode(node);
addSource(node).then((res) => {
if ([0, 200].includes(res.code)) {
cusAddNodes(this.$parent.treeObj, DbOption.p_id, [node]);
}
});
}
});
});
},
//模型压平
pressModel() {
if (window.checkAuthIsValid) {
let selectedNode = getSelectedNode(this.treeObj);
if (selectedNode) {
let isTileset = ["bim", "tileset"].includes(selectedNode.source_type);
if (!isTileset) {
this.$message.warning("请在图层指挥舱选中对应模型进行操作!");
return;
}
let source_id = this.$md5(new Date().getTime() + "压平面");
let DbOption = {
source_id,
source_name: "压平面",
source_type: "pressModel",
p_id: selectedNode.source_id,
};
let draw = new YJ.Draw.DrawPolygon(window.Earth1);
draw.start((err, params) => {
if (params.length > 2) {
if (err) throw err;
let alt = params[0].alt;
params.forEach((item) => {
if (item.alt < alt) alt = item.alt;
});
let detailOption = {
model_id: selectedNode.source_id,
positions: params,
};
//获取节点树对象
let node = getNodeData(DbOption, detailOption);
// renderPressModel(node);
addSource(node).then((res) => {
if ([0, 200].includes(res.code)) {
cusRenderNode(node);
cusAddNodes(this.treeObj, DbOption.p_id, [node]);
}
});
} else {
this.$message.warning("至少三个点");
}
});
} else {
this.$message.warning("请在图层指挥舱选中对应模型进行操作!");
}
} else {
this.$message({
message: "您没有该功能的权限",
type: "warning",
});
}
},
//模型剖切
tilesetClipping() {
if (window.checkAuthIsValid) {
let selectedNode = getSelectedNode(this.treeObj);
if (!selectedNode) {
this.$message.warning("请在图层指挥舱选中对应模型进行操作");
return;
}
if (
!(
selectedNode.source_type === "tileset" ||
selectedNode.source_type === "bim"
)
) {
this.$message.warning("选中的节点不能进行剖切");
return;
}
let tileset = _entityMap.get(selectedNode.source_id);
let draw = new YJ.Draw.DrawPolygon(window.Earth1);
draw.start((err, pos) => {
let section = new YJ.Analysis.Section(window.Earth1, tileset.entity, {
positions: pos,
});
_entityMap.set(selectedNode.source_id + "pouqie", section);
});
} else {
this.$message({
message: "您没有该功能的权限",
type: "warning",
});
}
},
//地形开挖
terrainDig() {
if (window.checkAuthIsValid) {
new YJ.Analysis.TerrainExcavation(window.Earth1);
} else {
this.$message({
message: "您没有该功能的权限",
type: "warning",
});
}
},
//清除剖切
clearTilesetClipping() {
// if (window.checkAuthIsValid) {
// let selectedNode = getSelectedNode(this.treeObj);
// if (
// !selectedNode ||
// !(
// selectedNode.source_type === "tileset" ||
// selectedNode.source_type === "bim"
// )
// ) {
// return;
// }
// let tileset = _entityMap.get(selectedNode.source_id + "pouqie");
// tileset.destroy();
// _entityMap.delete(selectedNode.source_id + "pouqie");
// } else {
// this.$message({
// message: "您没有该功能的权限",
// type: "warning",
// });
// }
YJ.Analysis.ClearSection();
},
//飞行漫游
path() {
// let selectedNode = getSelectedNode(this.treeObj);
// if (selectedNode) {
YJ.Global.FlyRoam.open(
window.Earth1,
{},
{
clickSavePath: (data) => {
let source_id = this.$md5(new Date().getTime() + "漫游路径");
let DbOption = {
source_id,
source_name: "漫游路径",
source_type: "roam",
p_id: findParentId(this.treeObj),
detail: {
...data,
},
};
cusRenderNode(DbOption);
addSource(DbOption).then((res) => {
YJ.Global.FlyRoam.close();
if ([0, 200].includes(res.code)) {
cusAddNodes(this.treeObj, DbOption.p_id, [DbOption]);
}
});
},
changeRepeatStateCallBack: (data) => {
console.log(data);
},
}
);
// } else {
// this.$message.warning("请在图层指挥舱中选中对应图层添加");
// }
},
floodSimulation() {
let draw = new YJ.Draw.DrawPolygon();
draw.start((err, params) => {
if (
!(
(Object.prototype.toString.call(params) === "[object Array]" &&
params.length == 0) ||
params == undefined
)
) {
let minHeight = params[0].alt;
let options = {
positions: params,
maxHeight: minHeight + 100,
};
new YJ.Efflect.Yanmo(window.Earth1.earth, options);
}
});
},
//BIM编辑
// BIMEdit(item) {
// item.status = !item.status;
// // new YJ.Tools().setPickStatus(item.status);
// // console.log("ce", new YJ.Tools())
// let draw = new YJ.Draw.DrawPoint(window.Earth1)
// draw.start((err, params) => {
// console.log("bim编辑", err, params)
// })
// // console.log("bim编辑", draw)
// let tileset = new YJ.Obj.BIM(window.Earth1, {
// show: true,
// url: "http://localhost:55110/data/bim/izncSnyeCmX2GkTRrphiQdMEYXtDXMrr/scenetree.json",
// position: { lng: 100, lat: 40, alt: 10 }
// })
// console.log("xxxx", tileset)
// YJ.Global.flyTo(window.Earth1, {
// position: { lng: 100, lat: 40, alt: 10 },
// duration: 2,
// });
// },
//雨特效
rain(item) {
item.status = !item.status;
YJ.Global.efflect.rain(window.Earth1, item.status);
},
//雪
snow(item) {
item.status = !item.status;
YJ.Global.efflect.snow(window.Earth1, item.status);
},
//雾
fog(item) {
item.status = !item.status;
YJ.Global.efflect.fog(window.Earth1, item.status);
},
light(item) {
item.status = !item.status;
YJ.Global.Light({ earth: window.Earth1.earth, status: item.status });
},
// 夜视
nightVision(item) {
item.status = !item.status;
YJ.Global.efflect.nightVision(window.Earth1, item.status);
},
// 星空
skystarry(item) {
item.status = !item.status;
YJ.Global.efflect.skyStarry(window.Earth1, item.status);
},
// 光照
illumination(item) {
// item.status = !item.status;
// YJ.Global.efflect.illumination(window.Earth1, item.status);
let layer2 = new YJ.Global.efflect.Sunshine(window.Earth1, { id: 123 });
},
//投影面积
projectionArea() {
let measure = new YJ.Measure.MeasureTyArea(window.Earth1);
measure.start();
},
areaMeasure() {
let measure = new YJ.Measure.MeasureTdArea(window.Earth1);
measure.start();
},
// 坡度测量
lopeDistanceMeasures() {
let measure = new YJ.Measure.MeasureSlopeDistance(window.Earth1);
measure.start();
},
//投影距离测量
projectionDistanceMeasure() {
let measure = new YJ.Measure.MeasureProjectionDistance(window.Earth1);
measure.start();
},
//距离测量
distanceMeasure() {
let measure = new YJ.Measure.MeasureDistance(window.Earth1);
measure.start();
},
//高度测量
heightMeasure() {
let measure = new YJ.Measure.MeasureHeight(window.Earth1);
measure.start();
},
//三角测量
triangleMeasure() {
let measure = new YJ.Measure.MeasureTriangle(window.Earth1);
measure.start();
},
//坐标测量
coorMeasure() {
let measure = new YJ.Measure.MeasureLocation(window.Earth1);
measure.start();
},
//清除测量
clearMeasure() {
YJ.Measure.Clear();
},
// 高清截图
async HDScreen() {
// let res = window.Earth1.viewer.scene.canvas.toDataURL()
// let res = YJ.Global.ScreenShot(window.Earth1)
// 判断
if (window.splitScreen || window.multiViewportMode) {
let res = "";
let res2 = "";
let sdk;
if (window.splitScreen) {
sdk = YJ.Global.splitScreen.getSdk();
} else {
sdk = YJ.Global.multiViewportMode.getSdk();
}
await new YJ.Global.ScreenShot(sdk.sdkD, (data) => {
res = data;
});
await new YJ.Global.ScreenShot(sdk.sdkP, (data) => {
res2 = data;
});
if (window.multiViewportMode) {
processBase64Images(res, res2, (mergedBase64) => {
this.downloadScreen(mergedBase64);
// window.multiViewportMode = false;
});
} else {
let doms = document.querySelectorAll(".cesium-widget");
let leftWidth = doms[0].offsetWidth;
let rightWidth = doms[1].offsetWidth;
combineBase64Images(res2, leftWidth, res, rightWidth)
.then((result) => {
this.downloadScreen(result)
// window.splitScreen = false;
})
.catch((err) => console.error("拼接失败:", err));
}
} else {
let res = "";
await new YJ.Global.ScreenShot(window.Earth1, (data) => {
res = data;
});
this.downloadScreen(res);
}
},
// 截图下载
downloadScreen(res) {
let base64 = res.replace(/^data:image\/\w+;base64,/, "");
console.log("base64", base64);
let dataBuffer = new Buffer(base64, "base64");
this.$sendElectronChanel("saveFile", {
title: "保存图片",
filename: dayjs().format("YYYYMMDDHHmmss") + "截图",
filters: [{ name: "保存图片", extensions: ["jpg"] }],
});
this.$recvElectronChanel("selectedFileItem", (e, path) => {
fs.writeFile(path, dataBuffer, (res) => {
console.log(res);
});
});
},
HDScreenHD(item, list) {
let splitScreen = list[5].list.find((item) => item.name == "splitScreen");
splitScreen.status = false;
YJ.Global.ScreenShotHD(window.Earth1);
},
//路径规划
routePlan() {
window.clicknum = 0;
let host = new URL(getIP()).host;
let routePlanning = new YJ.Obj.RoutePlanning(window.Earth1, {
gps: true,
host,
});
routePlanning.Dialog.queryCallBack = async (v) => {
const params = {
start: {
lng: v.start[0],
lat: v.start[1],
alt: 0,
},
end: {
lng: v.end[0],
lat: v.end[1],
alt: 0,
},
};
await queryRoute(params, (response) => {
if (response) {
routePlanning.createRoute(response.list[0].positions);
}
});
};
},
//范围截图(暂无)
areaScreen() {
let draw = new YJ.Draw.DrawRect(window.Earth1);
draw.start((err, params) => {
let detailOption = { position: params, name: "55" };
let DbOption = {
source_id: "55",
source_name: "55",
source_type: "panel",
p_id: "-1",
};
let node = getNodeData(DbOption, detailOption);
cusRenderNode(DbOption);
_entityMap.get("55").flyTo();
if (_entityMap.get("55")) {
_entityMap.get("55").remove();
_entityMap.delete("55");
}
setTimeout(() => {
this.HDScreen();
}, 3000);
});
},
transform() {
$root_home_index.transformDrawer = true;
$root_home_index.transformTypeActiveName = "";
$root_home_index.input = "";
$root_home_index.output = "";
},
//视频录制
videoRecording(item) {
item.status = !item.status;
let time = 3;
this.$changeComponentShow("#secondMenu", false);
// const onKeyDown = (e) => {
// if (e.keyCode === 27) {
// item.status = !item.status;
// $sendElectronChanel("endRecoder");
// document.removeEventListener("keydown", onKeyDown);
// }
// };
if (item.status) {
// document.addEventListener("keydown", onKeyDown);
let loading = $root_home.openLoading(time, {
background: "rgba(0,0,0,0)",
fullscreen: false,
customClass: "timer",
});
let timer = "";
const p = document.createElement("p");
p.style.color = "#fff";
p.innerHTML = "再次点击录制结束";
document.getElementsByClassName("el-loading-spinner")[0].appendChild(p);
let func = () => {
loading.setText(time--);
if (time == -1) {
clearInterval(timer);
loading.close();
console.log("开始了");
p.remove();
$sendElectronChanel("startRecoder");
}
};
func();
timer = setInterval(func, 1000);
} else {
$sendElectronChanel("endRecoder");
// document.removeEventListener("keydown", onKeyDown);
}
},
//图片定位
pictureLocation() {
let selectedNode = getSelectedNode(this.treeObj);
if (selectedNode) {
let source_id = this.$md5(new Date().getTime() + "图片定位");
let DbOption = {
source_id,
source_name: "图片定位",
source_type: "picture",
p_id: findParentId(this.treeObj),
};
let option = {
properties: ["openFile", "multiSelections"],
filters: [
{
name: "无人机航拍",
extensions: ["JPG"],
},
],
};
this.openDirectoryDialog(option, (paths) => {
if (!paths.length) {
return;
}
const billboard = {
image: YJ.Global.getBillboardDefaultUrl("1"),
defaultImage: "1",
show: true,
scale: 1,
};
console.log("图片定位", billboard.image);
addPicture(
{ list: paths, p_id: DbOption.p_id, billboard: billboard },
(res) => {
console.log("res.list", res);
if (res.whout_list.length > 0) {
let msg = "";
let arr = [];
if (res.whout_list.length > 5) {
arr = res.whout_list.slice(0, 5);
} else {
arr = res.whout_list;
}
arr.forEach((item) => {
msg = msg + item + " ";
});
this.$message.warning(msg + "导入失败!");
} else {
this.$message.success("导入成功!");
}
console.log("res.list", res.list);
res.list.forEach((item) => {
let entity = renderPicture(item);
entity.flyTo();
cusAddNodes(this.treeObj, DbOption.p_id, [item]);
});
}
);
});
} else {
this.$message.warning("请在图层指挥舱中选中对应图层添加");
}
},
//全景导入
importPanorama() {
let selectedNode = getSelectedNode(this.treeObj);
if (selectedNode) {
let source_id = this.$md5(new Date().getTime() + "全景图片");
let DbOption = {
source_id,
source_name: "全景图片",
source_type: "vr",
p_id: findParentId(this.treeObj),
};
let option = {
properties: ["openFile", "multiSelections"],
filters: [
{
name: "全景图片",
extensions: ["JPG"],
},
],
};
this.openDirectoryDialog(option, (paths) => {
if (!paths.length) {
return;
}
const billboard = {
image: `http://localhost:${window.staticPort}/GEMarker/vr.png`,
defaultImage: "2",
show: true,
scale: 1,
};
addPanorama(
{ list: paths, p_id: DbOption.p_id, billboard: billboard },
(res) => {
if (res.whout_list.length > 0) {
let msg = "";
let arr = [];
if (res.whout_list.length > 5) {
arr = res.whout_list.slice(0, 5);
} else {
arr = res.whout_list;
}
arr.forEach((item) => {
msg = msg + item + " ";
});
this.$message.warning(msg + "导入失败!");
} else {
this.$message.success("导入成功!");
}
res.list.forEach((item) => {
let entity = renderPicture(item);
entity.flyTo();
cusAddNodes(this.treeObj, DbOption.p_id, [item]);
});
}
);
});
} else {
this.$message.warning("请在图层指挥舱中选中对应图层添加");
}
},
// gdb
gdbImport() {
// let selectedNode = getSelectedNode(this.treeObj);
// if (selectedNode) {
let option = {
properties: ["openDirectory"],
filters: [],
};
this.openDirectoryDialog(option, (paths) => {
if (!paths.length) {
return;
}
let path = paths[0];
let arr = path.split("/");
let name = arr[arr.length - 1];
let source_type = "gdb";
/*if (!_map.has(item)) {*/
let params = {
source_name: name,
source_type,
source_id: this.$md5(path),
source_path: path,
is_show: 1,
p_id: findParentId(this.treeObj),
detail: {
richText: {},
},
};
addSource(params).then(
(res) => {
console.log(params, res);
params.source_type = res.data.type;
if (!["gdb"].includes(params.source_type))
params.source_path = res.data.tile_set.url;
source_type = params.source_type;
cusAddNodes(this.$parent.treeObj, findParentId(this.treeObj), [
params,
]);
if (source_type == "gdb") {
console.log("gdb", params);
renderShp(params);
}
},
(err) => {
console.log(err);
if (err.code == 50) {
let source_id = err.message.split(":")[1];
let node = this.$parent.treeObj.getNodeByParam(
"source_id",
source_id,
null
);
this.$parent.treeObj.selectNode(node);
}
}
);
});
// } else {
// this.$message.warning("请在图层指挥舱中选中对应图层添加");
// }
},
//人房关联
peopleRoomLink() {
window.$dth.open();
},
//鼠标坐标
mouseLocation(item) {
item.status = !item.status;
const onKeyDown = (e) => {
if (e.keyCode === 27) {
item.status = !item.status;
YJ.Global.MouseCoordinate(window.Earth1, item.status);
document.removeEventListener("keydown", onKeyDown);
}
};
this.$changeComponentShow("#secondMenu", false);
if (item.status) {
document.addEventListener("keydown", onKeyDown);
this.$message.success("按下Esc或者点击结束按钮取消定位");
} else {
document.removeEventListener("keydown", onKeyDown);
}
YJ.Global.MouseCoordinate(window.Earth1, item.status);
},
// 根据VR图片查找其邻居并计算距离和方位角
importImg() {
this.$changeComponentShow(".vrModelBox", true);
// let option = {
// properties: ["openDirectory", ],
// filters: [
// ]
// }
// this.openDirectoryDialog(option, paths => {
// if(!paths.length){
// return
// }
// console.log(paths);
// })
},
// 度分秒转换
projConvert(item) {
item.status1 = !item.status1;
let tools = new YJ.Tools(window.Earth1);
tools.projConvert(item.status1, () => {
item.status1 = false;
});
},
// 投影转换
projectionConvert(item) {
item.status1 = !item.status1;
let tools = new YJ.Tools(window.Earth1);
tools.projectionConvert(item.status1, () => {
item.status1 = false;
});
},
openDirectoryDialog(option, cb) {
this.$sendElectronChanel("open-directory-dialog", option);
this.$recvElectronChanel("selectedItem", (e, paths) => {
cb(paths);
});
},
// 水流
waterL() {
let selectedNode = getSelectedNode(this.treeObj);
let draw = new YJ.Draw.DrawPolyline(window.Earth1, { number: 2 });
draw.start((err, params) => {
console.log("paramsparamsparamsparams", params);
if (params.length > 1) {
let source_id = this.$md5(new Date().getTime() + "水流");
let DbOption = {
source_id,
source_name: "喷射水柱",
source_type: "waterl",
p_id: newp_id,
};
let option = {
id: source_id,
start: {
...params[0],
},
end: {
...params[1],
},
};
let detailOption = JSON.parse(JSON.stringify(option));
let node = getNodeData(DbOption, detailOption);
console.log("renderSpoutrenderSpoutrenderSpout", node);
renderSpout(node);
addSource(node).then((res) => {
if ([0, 200].includes(res.code)) {
// cusRenderNode(DbOption)
cusAddNodes(this.treeObj, DbOption.p_id, [node]);
}
});
}
// else {
// this.$message.warning("请选择两个点");
// }
});
},
objModel() {
let draw = new YJ.Draw.DrawPoint(window.Earth1);
draw.start((err, params) => {
if (params != undefined) {
console.log("paramsparamsparams", params);
const LoadObjModel = new YJ.Obj.LoadObjModel(
window.Earth1,
{
// position: params,
objUrl: "/static/lib/obj/少年路.obj",
videoUrl:
"https://open.ys7.com/v3/openlive/BA3811045_1_1.m3u8?expire=1741310776&id=687592287001128960&t=6ae241534de5513d1e5da800d2c538d544669490c6ff37f3288d2eb058a756ba&ev=100",
heading: 106,
pitch: 89,
roll: 355,
},
(a) => {
console.log(a);
}
);
window.LoadObjModel = LoadObjModel;
}
});
},
// 分屏
splitScreen(item, list) {
item.status = !item.status;
window.menuList = list;
window.splitScreen = item.status;
window.multiViewportMode = false;
if (item.status) {
YJ.Global.splitScreen.on(window.Earth1);
} else {
YJ.Global.splitScreen.off(window.Earth1);
}
},
// 飞线
flyLine() {
// let layer2 = new YJ.Obj.FlowLine(window.Earth1, {id: Math.random(),})
// console.log('layer2',layer2)
let Draw = new YJ.Draw.DrawPolygon(window.Earth1);
Draw.start((err, positions) => {
let source_id = this.$md5(new Date().getTime() + "飞线");
let option = {
id: source_id,
positions,
};
let DbOption = {
source_id,
source_name: "飞线",
source_type: "flyLine",
p_id: newp_id,
};
let detailOption = JSON.parse(JSON.stringify(option));
let node = getNodeData(DbOption, detailOption);
renderFlyLine(node);
addSource(node).then((res) => {
if ([0, 200].includes(res.code)) {
cusAddNodes(this.treeObj, DbOption.p_id, [node]);
}
});
});
},
// 全局等高线
qcontour() {
YJ.Global.Contour(window.Earth1);
},
},
};
export default secondMenuFun;