| | |
| | | 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: [] }); |
| | |
| | | // 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, |
| | | // }); |
| | | }; |
| | | |
| | | //图层选择 |
| | |
| | | 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) => { |
| | |
| | | }); |
| | | }); |
| | | }); |
| | | |
| | | 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) => { |
| | |
| | | }; |
| | | // store.commit("SET_plotting", obj); |
| | | store.state.plottingInquireData = obj; |
| | | |
| | | setCloseWebSocket(); |
| | | inquireData.value = { |
| | | name: "path #9", |
| | | icon: "q.png", |
| | | }; |
| | | isShow.value = false; |
| | | break; |
| | | } |
| | |
| | | // 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 = []; |
| | | }; |
| | | 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; |
| | | 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); |
| | | if (!nVal) return; |
| | | setOptionStart(); |
| | | 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 } |