From 6f7bbdd390abdcdb2cdaef980bc69816a3ff2202 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期四, 08 五月 2025 17:38:43 +0800
Subject: [PATCH] 添加动态污染溯源相关逻辑(待完成)
---
src/views/historymode/HistoryMode.vue | 24 +++++++
src/api/dataAnalysisApi.js | 14 ++++
src/api/index.js | 2
src/utils/map/3dLayer.js | 76 +++++++++++++++++++++++++
src/utils/map/pollution_trace.js | 24 ++++++++
5 files changed, 137 insertions(+), 3 deletions(-)
diff --git a/src/api/dataAnalysisApi.js b/src/api/dataAnalysisApi.js
new file mode 100644
index 0000000..9b57b3d
--- /dev/null
+++ b/src/api/dataAnalysisApi.js
@@ -0,0 +1,14 @@
+import { $http } from './index';
+
+export default {
+ /**
+ * 姹℃煋婧簮鍒嗘瀽
+ * @param {String} missionCode
+ * @returns
+ */
+ pollutionTrace(missionCode) {
+ return $http
+ .get(`air/analysis/pollution/trace`, { params: { missionCode } })
+ .then((res) => res.data);
+ }
+};
diff --git a/src/api/index.js b/src/api/index.js
index 11a5208..559cc74 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -1,7 +1,7 @@
import axios from 'axios';
import { ElMessage } from 'element-plus';
-const debug = false;
+const debug = true;
let ip1 = 'http://47.100.191.150:9029/';
// console.log(import.meta.env);
diff --git a/src/utils/map/3dLayer.js b/src/utils/map/3dLayer.js
index 01ff1d2..5f8c16f 100644
--- a/src/utils/map/3dLayer.js
+++ b/src/utils/map/3dLayer.js
@@ -166,6 +166,78 @@
_cylinder = cylinder;
}
+/**
+ * 缁樺埗楂樹寒鐨勬薄鏌撳尯鍩�3D绔嬮潰
+ */
+var _polCylinder = undefined;
+var _polFactorDatas = {
+ lnglats: [],
+ heights: [],
+ type: ''
+ },
+ //褰撳墠閫変腑鐨勭洃娴嬪洜瀛愭暟鎹�
+ _polFactor = {};
+function drawHighLight3DLayer(fDatas, factor) {
+ const offsetH = 40;
+
+ const lnglats_GD = fDatas.lnglats_GD;
+ const coors = fDatas.coors_GD;
+ const heights = factor.heights;
+ const colors = factor.colors;
+ const bColors = factor.bottomColors;
+
+ // eslint-disable-next-line no-undef
+ var cylinder = new AMap.Object3D.Mesh();
+ cylinder.backOrFront = 'both';
+ cylinder.transparent = true;
+
+ var geometry = cylinder.geometry;
+
+ const scale = _getScale(_minH, _maxH);
+ for (let i = 0; i < coors.length; i++) {
+ var r = lnglats_GD[i];
+ var lastP = lnglats_GD[i - 1];
+ var p = coors[i];
+ var h = (heights[i] - _minH) * scale + _minHeight;
+ if (heights[i] == -1) {
+ h = -1;
+ }
+
+ geometry.vertices.push(p.x, p.y, 0 - h); //搴曢儴椤剁偣
+ geometry.vertices.push(p.x, p.y, 0 - h - offsetH); //椤堕儴椤剁偣
+
+ if (i > 0) {
+ // eslint-disable-next-line no-undef
+ var distance = AMap.GeometryUtil.distance(r, lastP);
+ //涓や釜鏁版嵁鐐规渶灏忛棿闅旀椂闂翠负4s锛屽亣璁捐溅閫熸寜鐓�120km/h璁$畻锛�4s琛岄┒鏈�澶ц窛绂讳綔涓�132绫筹紝
+ //璁惧畾瓒呰繃1鍒嗛挓鐨勬暟鎹粯鍒剁壒娈婄殑杩炵嚎
+ if (distance <= 500 && h != -1) {
+ var bottomIndex = i * 2;
+ var topIndex = bottomIndex + 1;
+ var lastBottomIndex = bottomIndex - 2;
+ var lastTopIndex = bottomIndex - 1;
+ geometry.faces.push(bottomIndex, topIndex, lastTopIndex);
+ geometry.faces.push(bottomIndex, lastBottomIndex, lastTopIndex);
+ }
+ }
+
+ // const color = [1, 1, 1, 0.75]
+ const color = [1, 0, 0, 0.75];
+ geometry.vertexColors.push.apply(geometry.vertexColors, color); //搴曢儴椤剁偣棰滆壊
+ geometry.vertexColors.push.apply(geometry.vertexColors, color); //椤堕儴椤剁偣棰滆壊
+ }
+
+ // 7.鏍规嵁鍚堝苟閫夐」閲嶇疆鎴栨柊澧炲綋鍓嶇紦瀛樻暟鎹�
+ _polFactorDatas = fDatas;
+ _polFactor = factor;
+ if (_polCylinder != undefined) {
+ object3Dlayer.remove(_polCylinder);
+ }
+ object3Dlayer.add(cylinder);
+
+ _polCylinder = cylinder;
+}
+
export default {
clear() {
map.off('zoomend', onMapZoom);
@@ -211,5 +283,7 @@
if (lnglats_GD.length > 0) {
map.on('zoomend', onMapZoom);
}
- }
+ },
+
+ drawHighLight3DLayer
};
diff --git a/src/utils/map/pollution_trace.js b/src/utils/map/pollution_trace.js
new file mode 100644
index 0000000..c61a9cc
--- /dev/null
+++ b/src/utils/map/pollution_trace.js
@@ -0,0 +1,24 @@
+/**
+ * 姹℃煋婧簮
+ */
+
+/**
+ * 缁樺埗楂樹寒鐨勬薄鏌撳尯鍩�3D绔嬮潰
+ */
+function drawHighLight3DLayer() {}
+
+/**
+ * 缁樺埗娑夊強鐨勬薄鏌撳満鏅�
+ */
+function drawPollutionScene() {}
+
+/**
+ * 缁樺埗鍙嶅悜婧簮鎵囧舰
+ */
+function drawSectors() {}
+
+export default {
+ drawHighLight3DLayer,
+ drawPollutionScene,
+ drawSectors
+};
diff --git a/src/views/historymode/HistoryMode.vue b/src/views/historymode/HistoryMode.vue
index 212d022..1772dfd 100644
--- a/src/views/historymode/HistoryMode.vue
+++ b/src/views/historymode/HistoryMode.vue
@@ -8,6 +8,13 @@
@search="onSearch"
></SearchBar>
<TrajectoryState v-show="status != 0" :status="status"></TrajectoryState>
+ <el-button
+ type="primary"
+ class="p-events-auto el-button-custom"
+ @click="handleClick"
+ >
+ 鍒嗘瀽
+ </el-button>
</el-row>
<el-row class="m-t-2">
<FactorRadio
@@ -64,6 +71,7 @@
import DataSheet from './component/DataSheet.vue';
import { ElMessage } from 'element-plus';
import { fetchHistoryData } from '@/utils/factor/data';
+import dataAnalysisApi from '@/api/dataAnalysisApi';
import { mapStores } from 'pinia';
import { useSceneStore } from '@/stores/scene';
@@ -196,9 +204,10 @@
});
},
onSearch(option) {
- const { deviceType, deviceCode, timeArray } = option;
+ const { deviceType, deviceCode, timeArray, mission } = option;
this.deviceType = deviceType;
this.deviceCode = deviceCode;
+ this.mission = mission;
let startTime, endTime;
if (timeArray && timeArray.length == 2) {
startTime = moment(timeArray[0]).format('YYYY-MM-DD HH:mm:ss');
@@ -214,6 +223,19 @@
perPage: pageSize
}).then((res) => this.onFetchData(deviceType, res.data));
});
+ },
+ handleClick() {
+ const { missionCode } = this.mission;
+ dataAnalysisApi.pollutionTrace(missionCode).then((res) => {
+ res.data.forEach((e) => {
+ const fDatas = new FactorDatas();
+ fDatas.setData(e.dataVoList, this.drawMode, () => {
+ fDatas.refreshHeight(this.factorType);
+ Layer.drawHighLight3DLayer(fDatas, fDatas.factor[this.factorType]);
+ console.log(e.dataVoList);
+ });
+ });
+ });
}
},
mounted() {
--
Gitblit v1.9.3