From dae8fb08b9ff7327da86ed249c9c97a87c90e6f2 Mon Sep 17 00:00:00 2001 From: Surpriseplus <845948745@qq.com> Date: 星期二, 16 五月 2023 18:05:34 +0800 Subject: [PATCH] 发布管理,图层管理修改 --- src/views/Tools/LayerTree.vue | 495 ++++++++++++++++--------------------------------------- 1 files changed, 144 insertions(+), 351 deletions(-) diff --git a/src/views/Tools/LayerTree.vue b/src/views/Tools/LayerTree.vue index 085b369..5006a68 100644 --- a/src/views/Tools/LayerTree.vue +++ b/src/views/Tools/LayerTree.vue @@ -115,7 +115,7 @@ <div class="edit" @click="pellucidity()" - v-if="showopaque" + v-if="showlocal" > <i class="el-icon-tickets"></i> 閫忔槑搴� </div> @@ -125,14 +125,6 @@ v-show="shwoHistogram" > <i class="el-icon-tickets"></i> 閽诲瓟鏌辩姸鍥� - </div> - <div - class="edit" - v-show="shwoTitle" - @click="tileDownload()" - > - <i class="el-icon-download"></i> 鐡︾墖涓嬭浇 - </div> <!-- <div class="edit" @@ -228,7 +220,6 @@ perms_selectLayers, inquiry_selectDomains, comprehensive_selectPubById, project_selectDirAll, project_selectByDirid, dataQuerySelectWktById } from "../../api/api.js"; -import { conditions } from '../Archive/Archive.js'; export default { name: "tree", components: { queryinfo }, @@ -236,7 +227,6 @@ return { shwoHistogram: false, showlocal: false, - showopaque: false, eleId: "", isShow: false, currentData: "", @@ -280,47 +270,10 @@ mptLayer: [], optionts: [], proValue: null, - setCheeckedLayer: [], - shwoTitle: false, }; }, methods: { - //鐡︾墖涓嬭浇 - tileDownload() { - var that = this; - this.menuVisible = false - sgworld.Creator.createSimpleGraphic( - "rectangle", - {}, - function (entity) { - that.getTileRectangle(entity); - sgworld.Creator.SimpleGraphic.clear() - } - ); - }, - getTileRectangle(res) { - var value = res.rectangle.coordinates.getValue(); - var val = { - pubid: this.currentData.pubid, - pwd: "", - title: "", - xmax: Cesium.Math.toDegrees( - value.east - ), - xmin: Cesium.Math.toDegrees( - value.west - ), - ymax: Cesium.Math.toDegrees( - value.north - ), - ymin: Cesium.Math.toDegrees( - value.south - ) - } - this.$bus.$emit("titleDown", val) - - }, //杞瓟鏌辩姸鍥� async histogram() { this.menuVisible = false @@ -370,14 +323,10 @@ this.currentNode = Node; this.$store.state.propertiesName = this.currentData; - this.showModelAttach = false; - this.shwoTitle = false; - - - if (this.currentData.serveType == 'TMS') { - this.shwoTitle = true - } else if (this.currentData.serveType == "Tileset") { + if (this.currentData.serveType == "Tileset" || this.currentData.serveType == "3DML") { this.showModelAttach = true; + } else { + this.showModelAttach = false; } if (this.currentData.enName == "s_explorationpoint") { this.shwoHistogram = true; @@ -390,18 +339,10 @@ } else { this.firstLevel = true; } - if (Node.data.children == null && Node.data.serveType == "Tileset") { + if (Node.data.children == null && Node.data.serveType == "Tileset" || Node.data.serveType == "3DML") { this.showlocal = true; - this.showopaque = true; - } else if (Node.data.children == null && Node.data.serveType == "TMS") { - this.showlocal = true; - this.showopaque = false; - } else if (Node.data.children == null && Node.data.serveType != "Tileset") { + } else if (Node.data.children == null && Node.data.serveType != "Tileset" || Node.data.serveType == "3DML") { this.showlocal = false; - this.showopaque = false; - } else if (Node.data.children == null && Node.data.serveType != "DEM") { - this.showlocal = false; - this.showopaque = false; } this.menuVisible = true; @@ -543,27 +484,15 @@ //妯″瀷瀹氫綅 - async positioning() { + positioning() { this.menuVisible = false - - if (this.currentData.serveType == 'Tileset') { - 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]); - } - } - } else if (this.currentData.serveType == 'TMS' && this.currentData.pubid) { - const data = await comprehensive_selectPubById({ id: this.currentData.pubid }) - 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), - }); + 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]); } } - }, // 缂栬緫鑺傜偣 editNode(data) { @@ -637,7 +566,6 @@ console.log("tree drop: ", dropNode.label, dropType); }, handleCheckChange(data, checked, indeterminate) { - if (data.type == 1) { this.childOption = []; this.getchilds(data); @@ -646,7 +574,6 @@ var listTileset = []; var listTMS = []; var listMpt = []; - var listDem = []; for (var i in this.childOption) { switch (this.childOption[i].serveType) { case 'WMS': @@ -654,6 +581,9 @@ break; case 'WFS': listWFS.push(this.childOption[i]) + break; + case '3DML': + listTileset.push(this.childOption[i]) break; case 'Tileset': listTileset.push(this.childOption[i]) @@ -664,9 +594,6 @@ case 'TMS': listTMS.push(this.childOption[i]) break; - case 'DEM': - listDem.push(this.childOption[i]) - break; } } this.setChangeWMS(listWMS, checked); @@ -674,57 +601,84 @@ this.setChangeTileset(listTileset, checked); this.setChangeTMS(listTMS, checked); this.setChangeMpt(listMpt, checked); - this.setChangeDem(listDem, checked); } else if (data.type == 2) { if (data.serveType == "WMS") { this.setChangeWMS([data], checked); - } else if (data.serveType == "Tileset") { + } else if (data.serveType == "Tileset" || data.serveType == "3DML") { this.setChangeTileset([data], checked); } else if (data.serveType == "TMS") { this.setChangeTMS([data], checked); } else if (data.serveType == "Mpt") { this.setChangeMpt([data], checked); - } else if (data.serveType == "DEM") { - this.setChangeDem([data], checked); } } + // if (data.type != 2) return; + + + + + // if (data.serveType == "WFS") { + // if (window.Viewer.dataSources._dataSources.length == 0) { + // this.setAddLayers(data); + // } else { + + // } + // } else if (data.serveType == "Tileset") { + + // if (Viewer.scene.primitives._primitives.length == 0) { + // this.setAddLayers(data); + // } else { + // var std = []; + // for (var i in Viewer.scene.primitives._primitives) { + // Viewer.scene.primitives._primitives[i].show = checked; + // if (Viewer.scene.primitives._primitives[i].id == data.cnName) { + // std.push(data.id); + // Viewer.flyTo(Viewer.scene.primitives._primitives[i]); + // } + // } + // } + // if (std.length == 0 && checked == true) { + // this.setAddLayers(data); + // } else { + // window.map.getLayers().getArray().forEach(item => { + // if (item.get("name") == data.cnName) { + // item.setVisible(checked); + + // } + // }); + // } + // } else if (data.serveType == "TMS") { + + // if (data.pubid) { + + // } else { + // var res; + // if (data.url.indexOf("{host}") != -1) { + // res = data.url.replace("{host}", iisHost); + // } else { + // res = data.url + // } + // var url = res.split(';') + + // window.sgworld.Creator.createImageryProvider('mpt褰卞儚', "wms", { + // url: url[0], + // layers: url[1] + // }, "0", undefined, true, ""); + // } + + // } + + + + + // var layers_ol = window.map.getAllLayers(); + // for (var i in layers_ol) { + // var layerOl = layers_ol[i]; + // if (layerOl.values_.name == data.label) { + // layerOl.setVisible(checked); //鏄剧ず鍥惧眰 + // } + // } }, - setChangeDem(data, checked) { - if (data.length <= 0) return - this.cannelTerrainLayer(); - var val = this.$refs.tree.getCheckedKeys(); - var std = []; - for (var i = 0; i < val.length; i++) { - var res = this.$refs.tree.getNode(val[i]).data; - if (res.serveType && res.serveType != 'DEM') { - std.push(val[i]) - } - } - debugger - var result = data[0] - if (this.$refs.tree.getNode(result.id).checked) { - - std.push(result.id); - var base_ulr = result.url; - if (base_ulr.indexOf('{host}') > -1) { - base_ulr = base_ulr.replace("{host}", iisHost) - } - - this.setTerrainDemLayer(base_ulr); - } else { - this.setTerrainMptLayer(); - } - this.$refs.tree.setCheckedKeys(std) - // - // this.$nextTick(() => { - // - // }); - - // setTimeout(() => { - // - // }, 500); - }, - setChangeWMS(result, checked) { var value = this.$refs.tree.getCheckedNodes(); this.$bus.$emit("showMenuLayer", value); @@ -780,6 +734,20 @@ } } } + + + + // if (checked.checkedKeys) { + // for (var i in result) { + // + // } + // } else { + + // for (var j in result) { + // console.log(result[j]) + // // + // } + // } }, setChangeMpt(result, checked) { var value = this.$refs.tree.getCheckedNodes(); @@ -918,7 +886,7 @@ }), }); window.map.addLayer(vectorLayer); - } else if (res.serveType == "Tileset") { + } else if (res.serveType == "Tileset" || res.serveType == "3DML") { var url; if (res.url.indexOf("{host}") != -1) { url = res.url.replace("{host}", iisHost); @@ -938,37 +906,35 @@ ); tileset.readyPromise.then((tileset) => { - - tileset.id = res.cnName; tileset.layerId = res.id; tileset.pubid = res.pubid; - // Cesium.Matrix4.equals(a,b)鍒ゆ柇涓や釜鍥涚淮鐭╅樀鏄惁鐩哥瓑 - // 鏁翠釜鏍硅妭鐐规ā鍨嬬煩闃碉紝璇ileSet=>涓栫晫鍧愭爣绯� - // 鍗曚綅鐭╅樀锛屽瑙掔嚎鍊间负1.0鐨�4*4鐭╅樀 - if (!Cesium.Matrix4.equals(tileset.root.transform, Cesium.Matrix4.IDENTITY)) { - // 鑾峰彇妯″瀷鐨勪笘鐣屽潗鏍�(绗涘崱灏�) - // Cesium.Matrix4.getTranslation 閫氳繃浠垮皠鍙樻崲鐭╅樀鑾峰彇璇ileSet鐨勪笘鐣屽潗鏍� - const transformCenter = Cesium.Matrix4.getTranslation( - tileset.root.transform, - new Cesium.Cartesian3() - ); - // 灏嗙瑳鍗″皵鍧愭爣杞崲涓篧GS84缁忕含搴﹀潗鏍囷紙妯″瀷鐨勶級 - const transformCartographic = Cesium.Cartographic.fromCartesian( - transformCenter - ); - // 灏嗙瑳鍗″皵鍧愭爣杞崲涓篧GS84缁忕含搴﹀潗鏍囷紙鎴潰鐨勶級 - const boundingSphereCartographic = Cesium.Cartographic.fromCartesian( - tileset.boundingSphere.center - ); - const height = boundingSphereCartographic.height - transformCartographic.height; - // 浠庝竴涓狢artesian3瀵硅薄鐢熸垚Matrix4鍙樻崲鐭╅樀锛堣鍒囬潰鐨勶級 - window.modelHeight = height; - } else window.modelHeight = 0; - this.getTilesetArgs(tileset, res); + if (res.serveType != '3DML') { - - + // Cesium.Matrix4.equals(a,b)鍒ゆ柇涓や釜鍥涚淮鐭╅樀鏄惁鐩哥瓑 + // 鏁翠釜鏍硅妭鐐规ā鍨嬬煩闃碉紝璇ileSet=>涓栫晫鍧愭爣绯� + // 鍗曚綅鐭╅樀锛屽瑙掔嚎鍊间负1.0鐨�4*4鐭╅樀 + if (!Cesium.Matrix4.equals(tileset.root.transform, Cesium.Matrix4.IDENTITY)) { + // 鑾峰彇妯″瀷鐨勪笘鐣屽潗鏍�(绗涘崱灏�) + // Cesium.Matrix4.getTranslation 閫氳繃浠垮皠鍙樻崲鐭╅樀鑾峰彇璇ileSet鐨勪笘鐣屽潗鏍� + const transformCenter = Cesium.Matrix4.getTranslation( + tileset.root.transform, + new Cesium.Cartesian3() + ); + // 灏嗙瑳鍗″皵鍧愭爣杞崲涓篧GS84缁忕含搴﹀潗鏍囷紙妯″瀷鐨勶級 + const transformCartographic = Cesium.Cartographic.fromCartesian( + transformCenter + ); + // 灏嗙瑳鍗″皵鍧愭爣杞崲涓篧GS84缁忕含搴﹀潗鏍囷紙鎴潰鐨勶級 + const boundingSphereCartographic = Cesium.Cartographic.fromCartesian( + tileset.boundingSphere.center + ); + const height = boundingSphereCartographic.height - transformCartographic.height; + // 浠庝竴涓狢artesian3瀵硅薄鐢熸垚Matrix4鍙樻崲鐭╅樀锛堣鍒囬潰鐨勶級 + window.modelHeight = height; + } else window.modelHeight = 0; + this.getTilesetArgs(tileset, res); + } }); this.$store.state.setAlphaList.push({ name: res.cnName, @@ -992,7 +958,6 @@ }) ); layer.name = res.cnName; - layer.id = "TMS" this.setChangeWMS(); } @@ -1020,11 +985,12 @@ if (data.code != 200) { } else { - if (res.bak != '3dml') { + if (res.serveType != '3DML') { this.reload(tileset, data.result.json) } else { this.tileSet(tileset, parseFloat(res.elev)) } + } } else { this.tileSet(tileset, parseFloat(res.elev)) @@ -1068,12 +1034,12 @@ 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), - // }); - // } + 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(); } }, @@ -1104,15 +1070,7 @@ let cloneData = JSON.parse(JSON.stringify(source)); // 瀵规簮鏁版嵁娣卞害鍏嬮殕 return cloneData.filter((father) => { // 寰幆鎵�鏈夐」 - let branchArr = cloneData.filter((child) => father.id == child.pid); - if (branchArr.length > 0) { - - branchArr.sort(function (a, b) { - - return a.orderNum - b.orderNum - }) - } - + let branchArr = cloneData.filter((child) => father.id == child.pid); // 瀵规瘮ID锛屽垎鍒笂涓嬬骇鑿滃崟锛屽苟杩斿洖鏁版嵁 branchArr.length > 0 ? (father.children = branchArr) : ""; // 缁欑埗绾ф坊鍔犱竴涓猚hildren灞炴�э紝骞惰祴鍊� // 灞炰簬鍚屼竴瀵硅薄闂锛屼緥濡傦細浠� a=b銆乧=1 锛岀劧鍚庡啀浠� b.c=c 锛� 閭d箞 a.c=b.c=c=1 锛涘悓鐞嗭紝鍚庣画浠� c.d=2 ,閭d箞 a.c.d 涔熸槸=2锛� // 鐢辨寰幆澶氭鍚庯紝灏辫兘褰㈡垚鐩稿簲鐨勬爲褰㈡暟鎹粨鏋� @@ -1217,51 +1175,23 @@ } this.$refs.tree.setCheckedKeys(std); }, - getNewTree(obj, result) { - for (const i in obj) { - - result.push(obj[i]) - if (obj[i].children && obj[i].children.length > 0) { - this.getNewTree(obj[i].children, result) - } - } - return result - }, - - - // 鏌ヨ filterNode(value, data) { + if (!value) return true; return data.cnName.indexOf(value) !== -1; }, async setproChange(res) { + + this.$store.state.pigCode = 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 - } - if (rs.enName && rs.enName.indexOf(st_code[0].code) > -1) { - 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("鍒楄〃鑾峰彇澶辫触"); @@ -1269,154 +1199,21 @@ } 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), - }); - } + 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) { - var std_check = []; - for (var i in val) { - if (val[i].type == 1 && val[i].isProject == 1) {//椤圭洰鍒嗙被 - 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(); - } - - + 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); + this.$store.state.pigCode = null + this.setChangeWMS(); } }, - 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, ""); - }, - setTerrainDemLayer(res) { - - window.terrainDemLayer = new Cesium.CesiumTerrainProvider({ - url: res - }); - Viewer.terrainProvider = window.terrainDemLayer - }, - 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 = []; - var listDem = []; - 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 'Tileset': - listTileset.push(res[i]) - break; - case 'Mpt': - listMpt.push(res[i]) - break; - case 'TMS': - listTMS.push(res[i]) - break; - case 'DEM': - listDem.push(this.childOption[i]) - break; - } - } - } - // this.setChangeDem(listDem, true); - this.setChangeWMS(listWMS, true); - this.setChangeWFS(listWFS, true); - this.setChangeTileset(listTileset, true); - this.setChangeTMS(listTMS, true); - this.setChangeMpt(listMpt, true); - }, - 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 = []; - }, - - setChangeProLayer() { - var value = this.$store.state.isProjectLayer; - if (value.length != 0) { var std = []; @@ -1447,17 +1244,13 @@ this.getMenuProject() this.$bus.$on("treeDataCopy", (res) => { this.$store.state.treeData = this.treeData; - if (this.$refs.tree.getCheckedKeys().length > 0) { - this.$store.state.checkedKeys = this.$refs.tree.getCheckedKeys(); - } + this.$store.state.checkedKeys = this.$refs.tree.getCheckedKeys(); }); if (this.$store.state.showAllLayers == true) { this.layersStart(); this.$store.state.showAllLayers = false; - } else { - this.treeData = this.$store.state.treeData; this.$refs.tree.setCheckedKeys(this.$store.state.checkedKeys); } -- Gitblit v1.9.3