From 64e1db9d04bd4e2dd8ee4e61f2ec1de922c2f84d Mon Sep 17 00:00:00 2001 From: surprise <15810472099@163.com> Date: 星期二, 28 十一月 2023 10:53:06 +0800 Subject: [PATCH] 标绘查询点,多边形添加最大最小值,线查询添加单位 --- src/views/plotting/plottingInquire.vue | 279 +++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 178 insertions(+), 101 deletions(-) diff --git a/src/views/plotting/plottingInquire.vue b/src/views/plotting/plottingInquire.vue index bb13cdf..8dc5768 100644 --- a/src/views/plotting/plottingInquire.vue +++ b/src/views/plotting/plottingInquire.vue @@ -147,6 +147,8 @@ <div class="table_head_td">搴忓彿</div> <div class="table_head_td"> <span>鍥惧眰鍚�</span> + <span>鏈�澶у��</span> + <span>鏈�灏忓��</span> <span>鍒嗘瀽缁撴灉</span> </div> </div> @@ -154,7 +156,10 @@ <div class="table_tr" v-for="(e, i) in resultList" :key="i"> <div class="table_td">{{ i + 1 }}</div> <div class="table_td"> + <span>{{ e.layerName }}</span> + <span>{{ e.max }}</span> + <span>{{ e.min }}</span> <span>{{ e.avg }}</span> </div> </div> @@ -318,7 +323,7 @@ let layerNameNum = 0; let geoWkt = ref(null); let geoWktFlag = ref(false); -let ws = ref(null); +let wktType = ref(null); //鏂板鍥捐〃 const addCharts = () => { layerArr.value.push({ layerName: `null${layerNameNum}`, points: [] }); @@ -347,17 +352,25 @@ // if (store.state.plottingInquireData.entitiesData.icon == "d.png") { // } - selectPoint({ - pixel: val, - wkt: store.state.plottingInquireData.entitiesData.wkt, - }); + // selectPoint({ + // pixel: val, + // wkt: store.state.plottingInquireData.entitiesData.wkt, + // }); + setOptionStart(); + setWebScoKet("Point", store.state.plottingInquireData.entitiesData.wkt, val); }; //鑺傜偣閫夋嫨 const nodesChange = (val) => { - selectPolyline({ - nodes: val, - wkt: store.state.plottingInquireData.entitiesData.wkt, - }); + setOptionStart(); + setWebScoKet( + "PolyLine", + store.state.plottingInquireData.entitiesData.wkt, + val + ); + // selectPolyline({ + // nodes: val, + // wkt: store.state.plottingInquireData.entitiesData.wkt, + // }); }; //鍥惧眰閫夋嫨 @@ -403,6 +416,7 @@ return ElMessage.error("鏌ヨ閿欒"); } + debugger dt.result.forEach((e) => { if (e.code != 200) { e.avg = "-"; @@ -414,8 +428,11 @@ e.min = e.minList.toString(); e.lng = store.state.plottingInquireData.entitiesData.lng; e.lat = store.state.plottingInquireData.entitiesData.lat; + resultList.value.push(e); }); + + console.log(resultList.value); }; //闈㈡煡璇㈡帴鍙� const selectPolygon = async (res) => { @@ -463,12 +480,12 @@ }); }); }); - + console.log(dt.result); layeroptions.value = dt.result; layerValue.value = layeroptions.value[0].layerName; layerArr.value.push(dt.result[0]); - chartIsshow.value = true; + layerData.value = dt.result[0]; // dt.result.forEach((e) => { @@ -505,6 +522,12 @@ }; // store.commit("SET_plotting", obj); store.state.plottingInquireData = obj; + + setCloseWebSocket(); + inquireData.value = { + name: "path #9", + icon: "q.png", + }; isShow.value = false; break; } @@ -515,101 +538,153 @@ // emits("setCloseplotting", false); // }; let chartIsshow = ref(false); -const setMenuClose = ()=>{ +const setMenuClose = () => { + isShow.value = false; setCloseWebSocket(); - isShow.value=false; -} -const setCloseWebSocket = () => { - if( Window.ws){ - Window.ws.close(); - Window.ws.onclose = () => { - console.log("鏈嶅姟鍣ㄥ叧闂�"); + store.state.plottingInquireData = null; + inquireData.value = { + name: "path #9", + icon: "q.png", }; - Window.ws = null; +}; +const setCloseWebSocket = () => { + if (Window.ws) { + Window.ws.close(); + Window.ws.onclose = () => { + console.log("鏈嶅姟鍣ㄥ叧闂�"); + }; + Window.ws = null; } - }; const setWebScoKet = async (type, wkt, node) => { const data = await rasterAnalysis_selectByWktForPost({ wkt: wkt, size: node, }); - console.log(data) + if (data) { return; - } else { - - Window.ws.option = () => {}; - Window.ws.onmessage = (msg) => { - // console.log('鏉ヨ嚜鏈嶅姟鍣ㄧ鐨勬暟鎹細' + msg.data); //鐩戝惉鎺ュ彈鏉ヨ嚜鏈嶅姟绔殑淇℃伅 - if (msg.data != "杩炴帴鎴愬姛") { - var val = JSON.parse(msg.data); - console.log(val); - - if (val.analysisForPost) { - console.log(val); - } - } else { - console.log(msg.data); - } - }; } +}; +const setOptionStart = () => { + + resultList.value = []; + layerArr.value = []; + layeroptions.value = []; + layerValue.value = ''; +}; +const setWebSocketStart = () => { + // if (Window.ws) { + // setCloseWebSocket(); + // } + setOptionStart(); + var token = getToken(); + var url = socketUrl + "?token=" + token; + Window.ws = new WebSocket(url); + Window.ws.option = () => {}; + Window.ws.onmessage = (msg) => { + // console.log('鏉ヨ嚜鏈嶅姟鍣ㄧ鐨勬暟鎹細' + msg.data); //鐩戝惉鎺ュ彈鏉ヨ嚜鏈嶅姟绔殑淇℃伅 + if (msg.data != "杩炴帴鎴愬姛") { + var val = JSON.parse(msg.data); + + if (val.analysisForPost && val.analysisForPost.token == token) { + var data = val.analysisForPost; + console.log(data) + switch (wktType.value) { + case "Point": + setWebSocketPoint(data); + break; + case "Polygon": + setWebSocketPoint(data); + break; + case "LineString": + setWebSocketPLine(data); + break; + } + } + } + }; +}; +const setWebSocketPoint = (res) => { + var obj = { + avg: res.avgList.length <= 0 ? "--" : res.avgList.toString(), + layerName: res.layerName, + max: res.maxList.length <= 0 ? "--" : res.maxList.toString(), + min: res.minList.length <= 0 ? "--" : res.minList.toString(), + lng: store.state.plottingInquireData.entitiesData.lng, + lat: store.state.plottingInquireData.entitiesData.lat, + }; + resultList.value.push(obj); +}; +const setWebSocketPLine = (res) => { + res.points.forEach((element) => { + element.vals.forEach((v) => { + v = keepThreeNum(v); + }); + }); + layeroptions.value.push(res); + var data = layeroptions.value[0]; + layerValue.value = data.layerName; + layerArr.value.push(data); + layerData.value = data; }; watch( () => store.state.plottingInquireData, (nVal, oVal) => { - if (Window.ws) { - setCloseWebSocket(); - } - var url = socketUrl+"?token=" + getToken(); - Window.ws = new WebSocket(url); - isShow.value = nVal.isshow; - inquireData.value = nVal.entitiesData; - geoWktFlag.value = false; - if (inquireData.value.wkt) { - var wkt = WKT.parse(inquireData.value.wkt); + setOptionStart(); + setCloseWebSocket(); + if (!nVal) return; + if (nVal.entitiesData.name != inquireData.value.name) { + isShow.value = nVal.isshow; + inquireData.value = nVal.entitiesData; + geoWktFlag.value = false; + if (inquireData.value.wkt) { + var wkt = WKT.parse(inquireData.value.wkt); + wktType.value = wkt.type; + if (wkt.type == "Point") { + geoWkt.value = + wkt.coordinates[0].toFixed(6) + " " + wkt.coordinates[1].toFixed(6); + geoWktFlag.value = true; + } + if (wkt.type == "Polygon") { + var Polygon = turf.multiPolygon([wkt.coordinates]); + var center = turf.center(Polygon); + geoWkt.value = + center.geometry.coordinates[0].toFixed(6) + + " " + + center.geometry.coordinates[1].toFixed(6); + geoWktFlag.value = true; + } + } + setWebSocketStart(); - if (wkt.type == "Point") { - geoWkt.value = - wkt.coordinates[0].toFixed(6) + " " + wkt.coordinates[1].toFixed(6); - geoWktFlag.value = true; + if (nVal.entitiesData.icon == "x.png") { + pixelIsShow.value = true; + chartIsshow.value = true; + setWebScoKet("pline", nVal.entitiesData.wkt, ScopeBox.value.nodes); + // selectPolyline({ + // nodes: ScopeBox.value.nodes, + // wkt: nVal.entitiesData.wkt, + // }); } - if (wkt.type == "Polygon") { - var Polygon = turf.multiPolygon([wkt.coordinates]); - var center = turf.center(Polygon); - geoWkt.value = - center.geometry.coordinates[0].toFixed(6) + - " " + - center.geometry.coordinates[1].toFixed(6); - geoWktFlag.value = true; + if (nVal.entitiesData.icon == "m.png") { + chartIsshow.value = false; + // if (nVal.entitiesData.name == oVal.entitiesData.name) { + // return; + // } + pixelIsShow.value = false; + // selectPolygon({ wkt: nVal.entitiesData.wkt }); + setWebScoKet("polygon", nVal.entitiesData.wkt, 0); } - } - - if (nVal.entitiesData.icon == "x.png") { - pixelIsShow.value = true; - setWebScoKet("pline", nVal.entitiesData.wkt, ScopeBox.value.nodes); - // selectPolyline({ - // nodes: ScopeBox.value.nodes, - // wkt: nVal.entitiesData.wkt, - // }); - } - if (nVal.entitiesData.icon == "m.png") { - chartIsshow.value = false; - if (nVal.entitiesData.name == oVal.entitiesData.name) { - return; + if (nVal && nVal.entitiesData.icon == "d.png") { + chartIsshow.value = false; + pixelIsShow.value = true; + // selectPoint({ + // pixel: ScopeBox.value.pixel, + // wkt: nVal.entitiesData.wkt, + // }); + setWebScoKet("polygon", nVal.entitiesData.wkt, ScopeBox.value.pixel); } - pixelIsShow.value = false; - // selectPolygon({ wkt: nVal.entitiesData.wkt }); - setWebScoKet("polygon", nVal.entitiesData.wkt, 0); - } - if (nVal && nVal.entitiesData.icon == "d.png") { - chartIsshow.value = false; - pixelIsShow.value = true; - // selectPoint({ - // pixel: ScopeBox.value.pixel, - // wkt: nVal.entitiesData.wkt, - // }); - setWebScoKet("polygon", nVal.entitiesData.wkt, ScopeBox.value.pixel); } }, { deep: true } @@ -621,7 +696,7 @@ position: absolute; right: 26px; top: 80px; - width: 320px; + width: 400px; background: rgba(7, 8, 14, 0.8); z-index: 100; @@ -789,7 +864,7 @@ } .table_head_td:nth-child(2) { - width: 237px; + width:16.34375vw; display: flex; justify-content: space-between; align-items: center; @@ -819,12 +894,17 @@ align-items: center; border-right: 1px solid rgba(214, 228, 255, 0.4); box-sizing: border-box; - + div{ + width: 100%; + background: skyblue; + height: 100%; + } // padding: 5px; // white-space: nowrap; span { + display: block; - width: 50%; + width: 17%; word-wrap: break-word; // white-space: pre; text-align: left; @@ -835,22 +915,19 @@ // justify-content: flex-end; // margin-left: 5%; // float: right; - width: 40%; - text-align: right; + // width:16.34375vw; + text-align: center; + // background: skyblue; } } .table_td:nth-child(2) { - width: 237px; + width: 16.34375vw; display: flex; - justify-content: space-between; - align-items: center; - // padding: 0 10px; - padding-left: 10px; - padding-right: 10px; - padding-top: 5px; - padding-bottom: 5px; - border-right: 0; + justify-content: space-between; + align-items: center; + padding: 0 10px; + border-right: 0; } } -- Gitblit v1.9.3