<template>
|
<div class="lalala tree-container">
|
<el-form ref="form">
|
<el-form-item>
|
<el-select v-model="$store.state.pigCode"
|
clearable
|
filterable
|
style="width :100%"
|
@change="setproChange"
|
placeholder="请选择项目">
|
<el-option v-for="item in optionts"
|
:key="item.code"
|
:label="item.name"
|
:value="item.code">
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item>
|
<el-input placeholder="输入关键字进行过滤"
|
v-model="filterText"
|
class="search">
|
</el-input>
|
</el-form-item>
|
</el-form>
|
<el-tree ref="tree"
|
:data="treeData"
|
node-key="id"
|
show-checkbox
|
:props="defaultProps"
|
@node-click="handleLeftclick"
|
@node-contextmenu="rightClick"
|
@check="handleCheckChange"
|
:default-checked-keys="handleTreeCheck"
|
:expand-on-click-node="false"
|
:filter-node-method="filterNode"
|
draggable>
|
<span class="slot-t-node"
|
slot-scope="{ node, data }">
|
<span v-show="!data.isEdit">
|
<span :class="[data.id >= 99 ? 'slot-t-node--label' : '']">{{
|
node.label
|
}}</span>
|
</span>
|
<span v-show="data.isEdit">
|
<el-input class="slot-t-input"
|
size="mini"
|
autofocus
|
v-model="data.label"
|
:ref="'slotTreeInput' + data.id"
|
@blur.stop="nodeBlur(node, data)"
|
@keydown.native.enter="nodeBlur(node, data)"></el-input>
|
</span>
|
</span>
|
</el-tree>
|
<el-card class="box-card"
|
ref="card"
|
:style="{ ...rightClickMenuStyle }"
|
v-show="menuVisible">
|
<div class="edit"
|
@click="showLayerAttribute()"
|
v-if="showProp && !shwoHistogram">
|
<i class="el-icon-tickets"></i> 属性
|
</div>
|
<div class="edit"
|
@click="positioning()"
|
v-if="showLocal">
|
<i class="el-icon-tickets"></i> 定位
|
</div>
|
<div class="edit"
|
@click="pellucidity()"
|
v-if="showOpacity">
|
<i class="el-icon-tickets"></i> 透明度
|
</div>
|
<div class="edit"
|
@click="histogram()"
|
v-show="shwoHistogram">
|
<i class="el-icon-tickets"></i> 钻孔柱状图
|
</div>
|
</el-card>
|
</div>
|
</template>
|
|
<script>
|
import ImageWMS from "ol/source/ImageWMS";
|
import Image from "ol/layer/Image";
|
import GeoJSON from "ol/format/GeoJSON.js";
|
import queryinfo from "./queryinfo.vue";
|
import { Vector as VectorSource } from "ol/source";
|
import { Vector as VectorLayer } from "ol/layer";
|
import { perms_selectLayers, comprehensive_selectPubById, project_selectDirAll, project_selectByDirid, } from "../../api/api.js";
|
|
export default {
|
name: "tree",
|
components: { queryinfo },
|
data () {
|
return {
|
isBusy: false, // 正忙
|
showProp: false, // 属性
|
shwoHistogram: false, // 钻孔柱状图
|
showLocal: false, // 定位
|
showOpacity: false, // 不透明度
|
menuVisible: false, // 菜单
|
levelArray: [ // 调试数组
|
0, 40000000, 20000000, 10000000, 5000000, 2000000, 1000000, 500000,
|
250000, 200000, 100000, 50000, 17000, 9000, 5000, 2000, 1000, 500, 200,
|
100, 50, 25, 10, 0,
|
],
|
eleId: "",
|
isShow: false,
|
currentData: "",
|
currentNode: "",
|
firstLevel: false,
|
filterText: "",
|
appendNodetitle: "",
|
maxexpandId: 4,
|
rightClickMenuStyle: {},
|
handleTreeCheck: [],
|
dialogVisible: false,
|
showModelAttach: false,
|
addFormServer: {
|
opacity: 100,
|
serveType: "WMS",
|
type: 2,
|
},
|
layerId: [
|
"m_pipeline",
|
"th_strategic_channel",
|
"bs_project",
|
"m_sitepoint",
|
],
|
treeData: [],
|
defaultProps: {
|
children: "children",
|
label: "cnName",
|
},
|
options: [{
|
value: "WMS",
|
label: "WMS",
|
}, {
|
value: "WFS",
|
label: "WFS",
|
},
|
],
|
childOption: [],
|
mptLayer: [],
|
optionts: [],
|
proValue: null,
|
};
|
},
|
watch: {
|
filterText (val) {
|
this.$refs.tree.filter(val);
|
},
|
},
|
mounted () {
|
this.getMenus()
|
this.$bus.$on("treeDataCopy", (res) => {
|
this.$store.state.treeData = this.treeData;
|
this.$store.state.checkedKeys = this.$refs.tree.getCheckedKeys();
|
});
|
if (this.$store.state.showAllLayers) {
|
this.layersStart();
|
this.$store.state.showAllLayers = false;
|
} else {
|
this.treeData = this.$store.state.treeData;
|
this.$refs.tree.setCheckedKeys(this.$store.state.checkedKeys);
|
}
|
},
|
methods: {
|
// 获取菜单
|
async getMenus () {
|
let data = await project_selectDirAll();
|
if (data && data.code == 200) this.optionts = data.result;
|
},
|
// 初始化图层
|
async layersStart () {
|
let data = await perms_selectLayers();
|
if (data.code != 200) {
|
return this.$message.error("图层列表查询失败");
|
}
|
|
let checkKey = [], checkedLayers = [];
|
var layers = data.result.filter((lyr) => {
|
if (lyr.url && lyr.type == 2 && lyr.isShow == 1) {
|
checkKey.push(lyr.id);
|
if (lyr.serveType == "WMS") checkedLayers.push(lyr);
|
}
|
return lyr;
|
});
|
// 存储选中图层
|
this.treeData = this.setTreeData(layers);
|
this.$refs.tree.setCheckedKeys(checkKey);
|
sessionStorage.setItem("checkedLayers", JSON.stringify(checkedLayers));
|
},
|
// 设置树数据
|
setTreeData (source) {
|
let cloneData = JSON.parse(JSON.stringify(source)); // 对源数据深度克隆
|
return cloneData.filter((father) => {
|
// 循环所有项
|
let branchArr = cloneData.filter((child) => father.id == child.pid); // 对比ID,分别上下级菜单,并返回数据
|
branchArr.length > 0 ? (father.children = branchArr) : ""; // 给父级添加一个children属性,并赋值
|
// 属于同一对象问题,例如:令 a=b、c=1 ,然后再令 b.c=c ,那么 a.c=b.c=c=1 ;同理,后续令 c.d=2 ,那么 a.c.d 也是=2;
|
return father.pid == 0; // 返回一级菜单
|
});
|
},
|
// 节点获得焦点事件
|
nodeBlur (node, data) {
|
if (!data.label.length) return this.$message.error("菜单名不可为空!");
|
if (data.isEdit) this.$set(data, "isEdit", false);
|
this.$nextTick(() => {
|
this.$refs["slotTreeInput" + data.id].$refs.input.focus();
|
});
|
},
|
// 鼠标左击事件
|
handleLeftclick (data, node) {
|
this.rmListener();
|
},
|
// 取消鼠标监听事件
|
rmListener () {
|
this.menuVisible = false;
|
// 要及时关掉监听,不关掉的是一个坑,不信你试试,虽然前台显示的时候没有啥毛病,加一个alert你就知道了
|
document.removeEventListener("click", this.rmListener);
|
},
|
// 过滤节点
|
filterNode (value, data) {
|
if (!value) return true;
|
return data.cnName.indexOf(value) !== -1;
|
},
|
// 鼠标右击事件
|
rightClick (event, object, node, element) {
|
if (object.type == 1 || node.data.children != null) return;
|
|
this.currentNode = node;
|
this.currentData = object;
|
this.$store.state.propertiesName = object;
|
|
this.showProp = object.serveType == "WMS"; // 属性
|
this.shwoHistogram = this.showProp && object.enName == "s_explorationpoint"; // 钻孔柱状图
|
this.showLocal = ["Tileset", "3DML", "Mpt", "TMS", "DOM", "DEM"].indexOf(object.serveType) > -1; // 定位
|
this.showOpacity = ["Tileset", "3DML"].indexOf(object.serveType) > -1; // 不透明度
|
this.menuVisible = this.showProp || this.shwoHistogram || this.showLocal || this.showOpacity; // 菜单
|
|
this.$refs.card.$el.style.left = event.pageX + 20 + "px";
|
this.$refs.card.$el.style.top = event.pageY + "px";
|
},
|
// 属性显示
|
showLayerAttribute (data) {
|
this.rmListener();
|
this.currentData = data ? data : this.currentData;
|
var layer = this.currentData.enName.replaceAll("_", "");
|
this.$store.state.mapSpaceQueryLayer = layer;
|
this.$store.state.showPopBoxFlag = true;
|
this.$store.state.mapPopBoxFlag = "2";
|
},
|
// 定位
|
async positioning () {
|
this.rmListener();
|
if (["Tileset", "3DML"].indexOf(this.currentData.serveType) > -1) {
|
for (var i in Viewer.scene.primitives._primitives) {
|
if (Viewer.scene.primitives._primitives[i].id == this.currentData.cnName) {
|
Viewer.flyTo(Viewer.scene.primitives._primitives[i]);
|
break;
|
}
|
}
|
return;
|
}
|
|
if (["TMS", "DOM", "DEM"].indexOf(this.currentData.serveType) > -1 && this.currentData.pubid) {
|
var data = await comprehensive_selectPubById({ id: this.currentData.pubid });
|
if (data.result && data.result.geom) {
|
var wkt = this.$wkt.parse(data.result.geom);
|
var height = this.getHeight(wkt.coordinates[2]);
|
Viewer.camera.flyTo({
|
destination: Cesium.Cartesian3.fromDegrees(wkt.coordinates[1], wkt.coordinates[0], height), // 2000
|
});
|
}
|
return;
|
}
|
|
if ("Mpt" == this.currentData.serveType) {
|
viewer.camera.flyTo({ destination: Cesium.Cartesian3.fromDegrees(101.8, 37.9, 10000000.0) }); // 中国
|
}
|
},
|
// 钻孔柱状图
|
async histogram () {
|
this.rmListener();
|
var layer = this.currentData.enName.replaceAll("_", "");
|
this.$store.state.mapSpaceQueryLayer = layer;
|
this.$store.state.mapPopBoxFlag = "2";
|
this.$store.state.showPopBoxFlag = true;
|
},
|
// 透明度
|
pellucidity () {
|
this.rmListener();
|
for (var j in Viewer.scene.primitives._primitives) {
|
if (Viewer.scene.primitives._primitives[j].id == this.currentData.cnName) {
|
this.$store.state.setAlphaDity = this.currentData;
|
this.$bus.$emit("showPellucidity", true);
|
break;
|
}
|
}
|
},
|
// 获取高度
|
getHeight (level) {
|
if (level > -1 && level < 23) return this.levelArray[level];
|
|
return this.levelArray[this.levelArray.length - 1];
|
},
|
// 图层选中事件
|
handleCheckChange (data, checked) {
|
if (this.isBusy) return;
|
|
let nodes = [];
|
this.getNodes(data, nodes);
|
let obj = { WMS: [], Tileset: [], TMS: [], Mpt: [], DEM: [] };
|
|
for (let i = 0, c = nodes.length; i < c; i++) {
|
let node = nodes[i];
|
switch (node.serveType) {
|
case "WMS":
|
obj.WMS.push(node);
|
break;
|
case "3DML":
|
case "Tileset":
|
obj.Tileset.push(node);
|
break;
|
case "TMS":
|
obj.TMS.push(node);
|
break;
|
case "Mpt":
|
obj.Mpt.push(node);
|
break;
|
case "DEM":
|
obj.DEM.push(node);
|
break;
|
}
|
}
|
|
if (obj.WMS.length) this.setChangeWMS(obj.WMS, checked);
|
if (obj.Tileset.length) this.setChangeTileset(obj.Tileset, checked);
|
if (obj.TMS.length) this.setChangeTMS(obj.TMS, checked);
|
if (obj.Mpt.length) this.setChangeMpt(obj.Mpt, checked);
|
if (obj.DEM.length) this.setChangeDEM(obj.DEM, checked);
|
},
|
// 获取子节点
|
getNodes (data, arr) {
|
if (data.children) {
|
for (let i = 0, c = data.children.length; i < c; i++) {
|
var node = data.children[i];
|
if (node.children) {
|
this.getNodes(node, arr)
|
} else {
|
arr.push(node);
|
}
|
}
|
} else {
|
arr.push(data);
|
}
|
},
|
// 获取节点ID
|
getCheckNodesIds () {
|
var nodes = this.$refs.tree.getCheckedNodes();
|
|
var ids = [];
|
for (var i in nodes) {
|
ids.push(nodes[i].id);
|
}
|
|
return ids;
|
},
|
// 切换WMS服务
|
setChangeWMS (layers, checked) {
|
var value = this.$refs.tree.getCheckedNodes();
|
this.$bus.$emit("showMenuLayer", value);
|
},
|
// 切换Tileset
|
setChangeTileset (layers, checked) {
|
let ids = this.getCheckNodesIds(), arr = [];
|
for (var i in layers) {
|
var layer = layers[i];
|
if (ids.indexOf(layer.id) > -1) {
|
arr.push(layer);
|
continue;
|
}
|
|
for (var j in Viewer.scene.primitives._primitives) {
|
if (Viewer.scene.primitives._primitives[j].id == layer.cnName) {
|
Viewer.scene.primitives.remove(Viewer.scene.primitives._primitives[j]);
|
break;
|
}
|
}
|
|
var list = this.$store.state.setAlphaList;
|
for (var i = 0; i < list.length; i++) {
|
if (list[i].name == layer.cnName) {
|
list.splice(i, 1);
|
}
|
}
|
}
|
|
if (arr.length) this.addTilesetLayers(arr);
|
},
|
// 添加Tileset图层
|
addTilesetLayers (layers) {
|
//
|
},
|
// 切换TMS
|
setChangeTMS (layers, checked) {
|
let ids = this.getCheckNodesIds(), arr = [];
|
for (var i in layers) {
|
var layer = layers[i];
|
if (ids.indexOf(layer.id) > -1) {
|
arr.push(layer);
|
continue;
|
}
|
|
for (var i = 0; i < window.Viewer.imageryLayers._layers.length; i++) {
|
if (window.Viewer.imageryLayers._layers[i].name == layer.cnName) {
|
window.Viewer.imageryLayers.remove(window.Viewer.imageryLayers._layers[i]);
|
break;
|
}
|
}
|
}
|
|
if (arr.length) this.addTMSLayers(arr);
|
},
|
// 添加Tile图层
|
addTMSLayers (layers) {
|
//
|
},
|
// 切换Mpt
|
setChangeMpt (layers, checked) {
|
let ids = this.getCheckNodesIds(), arr = [];
|
for (var i in layers) {
|
var layer = layers[i];
|
if (ids.indexOf(layer.id) != -1) {
|
arr.push(layer);
|
continue;
|
}
|
|
for (var i in this.mptLayer) {
|
if (this.mptLayer[i].treeobj.name == layer.cnName) {
|
this.mptLayer[i].deleteObject();
|
this.mptLayer.splice(i, 1);
|
}
|
}
|
}
|
|
if (arr.length) this.addMptLayers(arr);
|
},
|
// 添加Mpt图层
|
addMptLayers (layers) {
|
//
|
},
|
// 切换DEM
|
setChangeDEM (layers, checked) {
|
let ids = this.getCheckNodesIds(), arr = [], isDel = false;
|
for (var i in layers) {
|
var layer = layers[i];
|
if (ids.indexOf(layer.id) != -1) {
|
arr.push(layer.url);
|
continue;
|
}
|
|
// 删除DEM
|
if (window.Viewer.terrainProvider._layers[0].resource._url == layer.url) {
|
isDel = true;
|
}
|
}
|
|
if (!arr.length && isDel) arr.push(demLayer);
|
if (arr.length) this.addDEMLayers(arr[0]);
|
},
|
// 添加DEM图层
|
addDEMLayer (url) {
|
Viewer.terrainLayer = new Cesium.CesiumTerrainProvider({
|
url: url,
|
requestVertexNormals: true
|
});
|
},
|
async setAddLayers (res) {
|
if (res.serveType == "WMS") {
|
var resource = geoServerURl;
|
if (res.resource != null && res.resource != undefined) {
|
resource = res.resource;
|
}
|
var imageryLayers = window.Viewer.scene.imageryLayers;
|
let layerWMS = new Cesium.WebMapServiceImageryProvider({
|
url: resource,
|
layers: res.url,
|
parameters: {
|
transparent: true,
|
format: "image/png",
|
srs: "EPSG:4490",
|
styles: "",
|
},
|
tileWidth: 512,
|
tileHeight: 512,
|
});
|
layerWMS.name = res.cnName;
|
//透明度
|
var tdtAnnoLayer = imageryLayers.addImageryProvider(layerWMS);
|
if (res.opacity) {
|
tdtAnnoLayer.alpha = parseInt(res.opacity) / 100;
|
}
|
var layer2 = new Image({
|
name: res.cnName,
|
source: new ImageWMS({
|
crossOrigin: "anonymous",
|
url: resource,
|
params: {
|
FORMAT: "image/png",
|
VERSION: "1.1.1",
|
LAYERS: res.url,
|
},
|
}),
|
});
|
if (res.opacity) {
|
layer2.setOpacity(parseInt(res.opacity) / 100);
|
}
|
window.map.addLayer(layer2);
|
} else if (res.serveType == "WFS") {
|
var url =
|
res.resource +
|
"?service=WFS&version=1.0.0&request=GetFeature&typeName=" +
|
res.url +
|
"&outputFormat=application%2Fjson";
|
$.ajax({
|
url: url,
|
cache: false,
|
async: true,
|
success: function (data) {
|
var datasource = Cesium.GeoJsonDataSource.load(data, {
|
stroke: Cesium.Color.YELLOW,
|
fill: Cesium.Color.YELLOW.withAlpha(0.1),
|
alpha: 0.1,
|
strokeWidth: 8,
|
clampToGround: true, //是否贴地
|
});
|
datasource.then((data) => {
|
data.name = res.cnName;
|
window.Viewer.dataSources.add(data);
|
});
|
},
|
error: function (data) {
|
console.log("error");
|
},
|
});
|
var vectorLayer = new VectorLayer({
|
name: res.cnName,
|
source: new VectorSource({
|
url: url,
|
format: new GeoJSON(),
|
}),
|
});
|
window.map.addLayer(vectorLayer);
|
} else if (res.serveType == "Tileset" || res.serveType == "3DML") {
|
var url;
|
if (res.url.indexOf("{host}") != -1) {
|
url = res.url.replace("{host}", iisHost);
|
} else {
|
url = modelUrl + "/" + res.url
|
}
|
var tileset = Viewer.scene.primitives.add(
|
new Cesium.Cesium3DTileset({
|
name: res.cnName,
|
url: url, //192.168.20.106,to4
|
maximumScreenSpaceError: 64, // 最大屏幕空间错误:16
|
maximumMemoryUsage: 768, // 最大内存:512
|
dynamicScreenSpaceError: true, // 减少离相机较远的屏幕空间错误:false
|
skipLevelOfDetail: true, // 在遍历时候跳过详情:false
|
})
|
);
|
|
tileset.readyPromise.then((tileset) => {
|
tileset.id = res.cnName;
|
tileset.layerId = res.id;
|
tileset.pubid = res.pubid;
|
if (res.serveType != '3DML') {
|
|
// Cesium.Matrix4.equals(a,b)判断两个四维矩阵是否相等
|
// 整个根节点模型矩阵,该tileSet=>世界坐标系
|
// 单位矩阵,对角线值为1.0的4*4矩阵
|
if (!Cesium.Matrix4.equals(tileset.root.transform, Cesium.Matrix4.IDENTITY)) {
|
// 获取模型的世界坐标(笛卡尔)
|
// Cesium.Matrix4.getTranslation 通过仿射变换矩阵获取该tileSet的世界坐标
|
const transformCenter = Cesium.Matrix4.getTranslation(
|
tileset.root.transform,
|
new Cesium.Cartesian3()
|
);
|
// 将笛卡尔坐标转换为WGS84经纬度坐标(模型的)
|
const transformCartographic = Cesium.Cartographic.fromCartesian(
|
transformCenter
|
);
|
// 将笛卡尔坐标转换为WGS84经纬度坐标(截面的)
|
const boundingSphereCartographic = Cesium.Cartographic.fromCartesian(
|
tileset.boundingSphere.center
|
);
|
const height = boundingSphereCartographic.height - transformCartographic.height;
|
// 从一个Cartesian3对象生成Matrix4变换矩阵(裁切面的)
|
window.modelHeight = height;
|
} else window.modelHeight = 0;
|
this.getTilesetArgs(tileset, res);
|
}
|
});
|
this.$store.state.setAlphaList.push({
|
name: res.cnName,
|
alpha: 1
|
})
|
window.model = tileset
|
} else if (res.serveType == "TMS") {
|
var url = res.url;
|
if (res.url.indexOf("{host}") != -1) {
|
url = res.url.replace("{host}", iisHost);
|
}
|
|
if (res.pubid) {
|
this.setQueryPubid(res);
|
} else {
|
|
var layer = Viewer.imageryLayers.addImageryProvider(
|
new Cesium.UrlTemplateImageryProvider({
|
url: url,
|
maximumLevel: 22,
|
})
|
);
|
layer.name = res.cnName;
|
this.setChangeWMS();
|
}
|
|
} else if (res.serveType == "Mpt") {
|
|
if (res.url.indexOf("{host}") != -1) {
|
res.url = res.url.replace("{host}", iisHost);
|
}
|
var url = res.url.split(';')
|
|
var layer = sgworld.Creator.createImageryProvider(res.cnName, "wms", {
|
url: url[0],
|
layers: url[1]
|
}, "0", undefined, true, "");
|
this.mptLayer.push(layer)
|
setTimeout(() => {
|
this.setChangeWMS();
|
}, 500);
|
}
|
},
|
async getTilesetArgs (tileset, res) {
|
if (res.pubid > 0) {
|
const data = await comprehensive_selectPubById({ id: res.pubid })
|
if (data.code != 200) {
|
//
|
} else {
|
if (res.serveType != '3DML') {
|
this.reload(tileset, data.result.json)
|
} else {
|
this.tileSet(tileset, parseFloat(res.elev))
|
}
|
}
|
} else {
|
this.tileSet(tileset, parseFloat(res.elev))
|
}
|
},
|
async setQueryPubid (res) {
|
const data = await comprehensive_selectPubById({ id: res.pubid })
|
if (data.code != 200) {
|
//
|
} else {
|
var url = data.result.url;
|
if (res.url.indexOf("{host}") != -1) {
|
url = res.url.replace("{host}", iisHost);
|
}
|
var min = data.result.min;
|
var max = data.result.max;
|
var layer;
|
if (max > 0) {
|
layer = Viewer.imageryLayers.addImageryProvider(
|
new Cesium.UrlTemplateImageryProvider({
|
url: url,
|
minimumLevel: min,
|
maximumLevel: max,
|
})
|
);
|
} else {
|
layer = Viewer.imageryLayers.addImageryProvider(
|
new Cesium.UrlTemplateImageryProvider({
|
url: url,
|
minimumLevel: min,
|
})
|
);
|
}
|
|
layer.name = res.cnName;
|
if (data.result.geom) {
|
// var wkt = this.$wkt.parse(data.result.geom);
|
// Viewer.camera.flyTo({
|
// destination: Cesium.Cartesian3.fromDegrees(wkt.coordinates[1], wkt.coordinates[0], 2000),
|
// });
|
}
|
this.setChangeWMS();
|
}
|
},
|
reload (tileset, res) {
|
var vm = JSON.parse(res)
|
var pos = Cesium.Cartesian3.fromDegrees(vm.lon, vm.lat, vm.height);
|
var converter = Cesium.Transforms.eastNorthUpToFixedFrame;
|
var hpr = new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(vm.yaw), 0, 0);
|
var matrix = Cesium.Transforms.headingPitchRollToFixedFrame(pos, hpr, Cesium.Ellipsoid.WGS84, converter);
|
tileset._root.transform = matrix;
|
// Viewer.flyTo(tileset);
|
},
|
tileSet (tileset, height) {
|
//3dtile模型的边界球体
|
var boundingSphere = tileset.boundingSphere;
|
//迪卡尔空间直角坐标=>地理坐标(弧度制)
|
var cartographic_original = Cesium.Cartographic.fromCartesian(boundingSphere.center);
|
//地理坐标(弧度制)=>迪卡尔空间直角坐标
|
var Cartesian3_original = Cesium.Cartesian3.fromRadians(cartographic_original.longitude, cartographic_original.latitude, cartographic_original.height);
|
var Cartesian3_offset = Cesium.Cartesian3.fromRadians(cartographic_original.longitude, cartographic_original.latitude, height);
|
//获得地面和offset的转换
|
var translation = Cesium.Cartesian3.subtract(Cartesian3_offset, Cartesian3_original, new Cesium.Cartesian3());
|
//修改模型矩阵
|
tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
|
// Viewer.flyTo(tileset);
|
},
|
async setproChange (res) {
|
if (res) {
|
this.setCheeckedLayer = this.$refs.tree.getCheckedKeys();
|
this.$store.state.pigCode = res;
|
var st_code = this.optionts.filter(rs => {
|
if (rs.code == res) {
|
return rs
|
}
|
})
|
|
var val = this.$store.state.oldTree.filter(rs => {
|
if (rs.enName == st_code[0].code) {
|
return rs
|
}
|
})
|
this.removeAllLayer();
|
var obj = {
|
dirid: res,
|
pageIndex: 1,
|
pageSize: 10,
|
}
|
|
const data = await project_selectByDirid(obj);
|
if (data.code != 200) {
|
this.$message.error("列表获取失败");
|
return;
|
}
|
|
if (data.result[0]) {
|
var geom = data.result[0].geom
|
if (geom) {
|
var wkt = this.$wkt.parse(geom)
|
Viewer.camera.flyTo({
|
destination: Cesium.Cartesian3.fromDegrees(wkt.coordinates[0].toFixed(6), wkt.coordinates[1].toFixed(6), 5000),
|
});
|
}
|
}
|
this.cannelTerrainLayer();
|
this.setTerrainMptLayer();
|
//清空图层树选中状态
|
this.$refs.tree.setCheckedKeys([]);
|
if (val.length > 0) {
|
if (val[0].type == 1 && val[0].isProject == 1) {//项目分类
|
var std_check = [];
|
for (var i in val) {
|
var std_val = this.getNewTree([this.$refs.tree.getNode(val[i].id).data], [])
|
for (var j in std_val) {
|
std_check.push(std_val[j])
|
}
|
}
|
var value = this.$store.state.isProjectLayer;
|
for (var i in value) {
|
|
std_check.push(value[i])
|
}
|
this.setProjectLayer(std_check);
|
} else {
|
this.setChangeProLayer();
|
}
|
} else {
|
this.setChangeProLayer();
|
}
|
} else {
|
this.removeAllLayer();
|
this.$store.state.pigCode = null;
|
this.$refs.tree.setCheckedKeys(this.setCheeckedLayer);
|
var std = [];
|
for (var i in this.setCheeckedLayer) {
|
std.push(this.$refs.tree.getNode(this.setCheeckedLayer[i]).data)
|
}
|
this.setProjectLayer(std);
|
}
|
},
|
removeAllLayer () {
|
for (var j in Viewer.scene.primitives._primitives) {
|
Viewer.scene.primitives.remove(Viewer.scene.primitives._primitives[j])
|
}
|
for (var i in window.Viewer.dataSources._dataSources) {
|
window.Viewer.dataSources.remove(
|
window.Viewer.dataSources._dataSources[i]
|
);
|
}
|
for (var i = 0; i < window.Viewer.imageryLayers._layers.length; i++) {
|
var val_id = window.Viewer.imageryLayers._layers[i].id;
|
if (val_id == 'TMS') {
|
window.Viewer.imageryLayers.remove(
|
window.Viewer.imageryLayers._layers[i]
|
);
|
}
|
}
|
for (var i in this.mptLayer) {
|
this.mptLayer[i].deleteObject();
|
this.mptLayer.splice(i, 1)
|
}
|
this.mptLayer = [];
|
},
|
setProjectLayer (res) {
|
var layerid = [];
|
for (var i in res) {
|
layerid.push(res[i].id)
|
}
|
this.$refs.tree.setCheckedKeys(layerid);
|
// var value = this.$refs.tree.getCheckedNodes();
|
// this.$bus.$emit("showMenuLayer", value);
|
var listWMS = [];
|
var listWFS = [];
|
var listTileset = [];
|
var listTMS = [];
|
var listMpt = [];
|
for (var i in res) {
|
if (res[i].type == 2) {
|
switch (res[i].serveType) {
|
case 'WMS':
|
listWMS.push(res[i])
|
break;
|
case 'WFS':
|
listWFS.push(res[i])
|
break;
|
case '3DML':
|
case 'Tileset':
|
listTileset.push(res[i])
|
break;
|
case 'Mpt':
|
listMpt.push(res[i])
|
break;
|
case 'TMS':
|
listTMS.push(res[i])
|
break;
|
}
|
}
|
}
|
// this.setChangeProLayer();
|
this.setChangeWMS(listWMS, true);
|
this.setChangeWFS(listWFS, true);
|
this.setChangeTileset(listTileset, true);
|
this.setChangeTMS(listTMS, true);
|
this.setChangeMpt(listMpt, true);
|
},
|
getNewTree (obj, result) {
|
for (const i in obj) {
|
console.log(obj[i].cnName)
|
result.push(obj[i])
|
if (obj[i].children && obj[i].children.length > 0) {
|
this.getNewTree(obj[i].children, result)
|
}
|
}
|
return result
|
},
|
cannelTerrainLayer () {
|
//清空地形
|
if (window.terrainMptLayer) {
|
window.terrainMptLayer.deleteObject();
|
window.terrainMptLayer = null;
|
}
|
if (window.terrainDemLayer) {
|
Viewer.terrainProvider = new Cesium.EllipsoidTerrainProvider();
|
window.terrainDemLayer = null;
|
}
|
},
|
setTerrainMptLayer () {
|
// //默认地形MPT
|
// var option = {
|
// url: window.sceneConfig.SGUrl,
|
// layerName: window.sceneConfig.mptName,
|
// requestVertexNormals: true,
|
// };
|
// window.terrainMptLayer = sgworld.Creator.sfsterrainprovider("", option, "", true, "");
|
window.terrainDemLayer = new Cesium.CesiumTerrainProvider({
|
// url: LFData + '/3d/terrain/dem20230321'
|
url: demLayer
|
});
|
Viewer.terrainProvider = window.terrainDemLayer
|
},
|
setChangeProLayer () {
|
var value = this.$store.state.isProjectLayer;
|
if (value.length != 0) {
|
|
var std = [];
|
for (var i in value) {
|
std.push(value[i].id)
|
}
|
this.$refs.tree.setCheckedKeys(std);
|
this.$bus.$emit("showMenuLayer", value);
|
}
|
},
|
},
|
};
|
</script>
|
<style scoped lang="less">
|
/* 点击节点时的选中颜色 */
|
.tree-container /deep/.el-tree-node.is-current > .el-tree-node__content {
|
color: #409eff !important;
|
}
|
|
.tree-container /deep/ .el-tree-node__expand-icon.expanded {
|
-webkit-transform: rotate(90deg);
|
transform: rotate(90deg);
|
}
|
|
.tree-container /deep/ .el-icon-caret-right:before {
|
content: "\e791";
|
font-size: 18px;
|
}
|
|
.tree-container /deep/ .el-tree-node__expand-icon {
|
margin-left: 1px;
|
padding: 0px;
|
}
|
|
.tree-container /deep/ .el-tree-node__expand-icon.is-leaf {
|
margin-left: 0px;
|
}
|
|
.tree-container /deep/ .el-tree-node {
|
position: relative;
|
padding-left: 10px;
|
}
|
|
.tree-container /deep/ .el-tree-node__children {
|
padding-left: 16px;
|
}
|
|
.tree-container /deep/ .el-tree > .el-tree-node:before {
|
border-left: none;
|
}
|
|
.tree-container /deep/ .el-tree > .el-tree-node:after {
|
border-top: none;
|
}
|
.tree-container /deep/ .el-tree > .el-tree-node:before {
|
border-left: none;
|
}
|
|
.tree-container /deep/ .el-tree > .el-tree-node:after {
|
border-top: none;
|
}
|
|
.tree-container /deep/ .el-tree-node:before {
|
content: "";
|
left: 10px;
|
position: absolute;
|
right: auto;
|
border-width: 1px;
|
}
|
|
.tree-container /deep/ .el-tree-node:after {
|
content: "";
|
left: 10px;
|
position: absolute;
|
right: auto;
|
border-width: 1px;
|
}
|
|
.tree-container /deep/ .el-tree-node:before {
|
border-left: 1px dashed #ccc;
|
bottom: 0px;
|
height: 100%;
|
top: -19px;
|
width: 1px;
|
}
|
|
.tree-container /deep/ .el-tree-node:after {
|
border-top: 1px dashed #ccc;
|
height: 25px;
|
top: 20px;
|
width: 20px;
|
}
|
|
.el-tree-node :last-child:before {
|
height: 40px;
|
}
|
|
.tree-container {
|
margin: 10px;
|
}
|
.tree-container /deep/ .el-tree .el-tree-node {
|
position: relative;
|
}
|
.tree-container /deep/ .el-tree-node .el-tree-node__content {
|
height: 34px;
|
padding-left: 0px !important;
|
border: none;
|
}
|
.tree-container /deep/ .el-tree-node .el-tree-node__content::before {
|
border-left: 1px dashed #ccc;
|
height: 100%;
|
top: 0;
|
width: 1px;
|
margin-left: 1px;
|
margin-top: 0px;
|
z-index: 8;
|
}
|
.tree-container
|
/deep/
|
.el-tree-node
|
.el-tree-node__children
|
.el-tree-node__content::before {
|
border-left: 0px dashed #ccc;
|
height: 100%;
|
top: 0;
|
width: 1px;
|
margin-left: 1px;
|
margin-top: 0px;
|
z-index: 8;
|
}
|
|
.tree-container /deep/ .el-tree-node .el-tree-node__content::after {
|
border-top: 1px dashed #ccc;
|
height: 1px;
|
top: 18px;
|
width: 13px;
|
margin-left: 1px;
|
z-index: 8;
|
}
|
|
.tree-container /deep/ .el-tree-node {
|
.is-leaf + .el-checkbox .el-checkbox__inner {
|
display: inline-block;
|
}
|
|
.el-checkbox .el-checkbox__inner {
|
//display: none;
|
}
|
}
|
|
.tree-container
|
/deep/
|
.el-tree-node
|
.el-tree-node__children
|
.el-tree-node__content::after {
|
border-top: 0px dashed #ccc;
|
}
|
|
.tree-container .el-tree-node .el-tree-node__content::before,
|
.tree-container .el-tree-node .el-tree-node__content::after {
|
content: "";
|
position: absolute;
|
right: auto;
|
}
|
|
/deep/.el-table__placeholder {
|
padding-left: 8px;
|
}
|
|
/deep/.el-card__body {
|
padding: 10px !important;
|
> div {
|
padding-bottom: 10px;
|
border-bottom: 1px solid #ccc;
|
&:hover {
|
color: #409eff;
|
}
|
}
|
}
|
|
/deep/ .el-form .el-form-item {
|
padding-right: 0px !important;
|
}
|
|
/deep/ .el-form-item {
|
margin-bottom: 10px !important;
|
}
|
|
.text {
|
font-size: 14px;
|
}
|
.el-tree {
|
width: 100%;
|
margin-top: 10px;
|
}
|
.search {
|
width: 100%;
|
}
|
|
.item {
|
padding: 18px 0;
|
}
|
|
.add {
|
cursor: pointer;
|
margin-top: 10px;
|
}
|
|
.delete {
|
margin: 10px 0;
|
cursor: pointer;
|
}
|
|
.edit {
|
margin-bottom: 10px;
|
cursor: pointer;
|
}
|
|
.search {
|
cursor: pointer;
|
}
|
|
.box-card {
|
position: fixed;
|
display: block;
|
z-index: 10000;
|
padding: 0px 0px;
|
border: 1px solid #ebeef5;
|
border-radius: 4px;
|
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
}
|
</style>
|