From 6ae4841b48665145aa469d574fbadb988a9c498c Mon Sep 17 00:00:00 2001 From: suerprisePlus <15810472099@163.com> Date: 星期四, 27 六月 2024 15:55:17 +0800 Subject: [PATCH] 演示1版本 --- src/assets/js/map/modelLayer.js | 139 +++++++++++++++++++++++++++++++++++----------- 1 files changed, 106 insertions(+), 33 deletions(-) diff --git a/src/assets/js/map/modelLayer.js b/src/assets/js/map/modelLayer.js index dfd6536..93942e1 100644 --- a/src/assets/js/map/modelLayer.js +++ b/src/assets/js/map/modelLayer.js @@ -1,7 +1,10 @@ import { getPublickey, getSecurityLogin, - getListCanview + getListCanview, + getmapConfig, + getQueryEentity, + getSettingPublickey } from "../../../api/modelBase.js"; import JSEncrypt from "jsencrypt"; import store from "../../../store/index.js"; @@ -14,35 +17,42 @@ modelBase: null, dbid: null, geom: null, - // 鑾峰彇Publickey + layers: null, + publickey: null, init() { this.modelBase = config.modelBase; - getPublickey().then((response) => { - const password = this.modelBase.password; - const userId = this.modelBase.userId; - const publickey = response.data; - const encrypt = new JSEncrypt(); - encrypt.setPublicKey(publickey); - let encrypted = encrypt.encrypt(password.substring(0, 50)) + ""; - let submit = { - userid: userId, - password: encrypted - }; - this.setLoginsubmit(submit); + this.getSettingPublicKey(); + const token = getToken(); + if (token) { + this.getModelLayerList(); + } else { + getPublickey().then((response) => { + const password = this.modelBase.password; + const userId = this.modelBase.userId; + this.publickey = response.data; + const encrypt = new JSEncrypt(); + encrypt.setPublicKey(this.publickey); + let encrypted = encrypt.encrypt(password.substring(0, 50)) + ""; + let submit = { + userid: userId, + password: encrypted + }; + this.setLoginsubmit(submit); + }); + } + }, + getSettingPublicKey() { + getSettingPublickey().then((response) => { + this.publickey = response.data; }); }, // 鑾峰彇Token setLoginsubmit(res) { - // const token = getToken(); - // if (token) { getSecurityLogin(res).then((response) => { const val = response.data.token; setToken(val); this.getModelLayerList(); }); - // } else { - // this.getModelLayerList( ); - // } }, // 鑾峰彇鍒楄〃 getModelLayerList() { @@ -56,19 +66,87 @@ }); if (obj.length > 0) { this.dbid = obj[0].dbid; + this.getmapConfig(); } }); - this.setLayerQuery(); }, + getmapConfig() { + getmapConfig({ + dbid: this.dbid, + token: getToken() + }).then((response) => { + if (response.code != 200) return; + const layers = response.data.layers; + this.layers = layers; + for (var i in layers) { + if (layers[i].name == "寤虹瓚") { + const url = layers[i].lod_url["3d"][""]; + + mapServer.addServer({ + sourceType: "Tileset", + url: url, + id: layers[i].id + }); + } + } + }); + }, + getQueryGroupBy(layer, filed, ction) { + const layerId = this.layers.filter((item) => { + if (item.name == layer) { + return item; + } + }); + if (layerId.length <= 0) { + return; + } + + const url = + config.modelBase.url + + config.modelBase.geo + + "/entitydbdata/query/entity"; + const obj = [ + { + type: "count", + field: filed, + outfield: "count_" + filed + } + ]; + axios + .post( + url, + { + layerid: layerId[0].id, + dbid: this.dbid, + token: getToken(), + statistics: JSON.stringify(obj), + containCount: true, + groupby: filed + }, + { + headers: { + Authorization: getToken(), + "Content-Type": "application/x-www-form-urlencoded" + } + } + ) + .then((response) => { + ction(response); + }) + .catch((error) => { + error; + }); + }, + setLayerQuery() { const token = getToken(); this.geom = mapConfig.setPointToCrical(120.27, 14.79, null); - const obj = { - type: "FeatureCollection", - totalFeatures: 1086, - features: [this.geom] - }; + // const obj = { + // type: "FeatureCollection", + // totalFeatures: 1086, + // features: [this.geom] + // }; // earthCtrl.factory.createFeatureLayer({ // sourceType: "geojson", // url: obj, @@ -146,7 +224,6 @@ } ) .then((response) => { - console.log("List", response); that.setLayerFilter(response.data.data.items); }); }, @@ -161,18 +238,16 @@ const a = []; // rs.filter((item) => { // if (item.targettype == "鍐涗簨鐩爣") { - // console.log(item); // // a.push(["${id} === '" + item.sid + "'", "color('#FF0000', 0.5)"]); // } // }); // a.push([ // "${id} == '1_b092c0c26de646b984801e29fba37f82'", - '${id} == 1_b092c0c26de646b984801e29fba37f82', - 'color("purple", 0.5)' + "${id} == 1_b092c0c26de646b984801e29fba37f82", + 'color("purple", 0.5)' ]); a.push(["true", "color('#E8F1F2', 0.5)"]); - console.log( tileset); tileset.style = new Cesium.Cesium3DTileStyle({ // color: "vec4(1.0,1.0,1.0, 1.0)", // 绾㈣壊 color: { @@ -180,18 +255,16 @@ [ // "${id} == '1_b092c0c26de646b984801e29fba37f82'", '${targettype} == "鍐涗簨鐩爣"', - 'color("purple", 0.5)' + 'color("purple", 0.5)' ] ] } }); // window.Cesium.when(tileset.readyPromise, function(tileset) { // var tilesetId = tileset.id; - // console.log('Tileset ID: ' + tilesetId); // }); // tileset.readyPromise.then( (item)=> { // tileset.tileVisible.addEventListener( (tile)=> { - // console.log(tile); // }) // }) } -- Gitblit v1.9.3