riku
2024-12-25 234c83d83c8835667c97c962d201ab4a3ce868b8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<template>
  <div>
    <!-- <el-button
      class="p-events-auto"
      type="info"
      icon="Memo"
      plain
      @click="draw"
    >
      绘制网格
    </el-button> -->
    <SatelliteManage
      class="satellite-manage"
      :gridDataList="satelliteGridStore.gridDataList"
      :loading="loading"
      @search="onSearch"
      @row-click="handleRowClick"
    ></SatelliteManage>
    <el-row class="historical" justify="center">
      <SatelliteAnimation
        :loading="animaLoading"
        :grid-data="gridDataDetailList"
        :mapViews="mapViews"
      ></SatelliteAnimation>
    </el-row>
  </div>
</template>
<script setup>
import { map } from '@/utils/map/index_old';
import calculate from '@/utils/map/calculate';
import marks from '@/utils/map/marks';
import grid from '@/utils/map/grid';
 
import { ref } from 'vue';
import gridApi from '@/api/gridApi';
import SatelliteManage from './component/SatelliteManage.vue';
import SatelliteProxy from './SatelliteProxy';
import { useFetchData } from '@/composables/fetchData';
import { useSatelliteGridStore } from '@/stores/satellite-grid';
 
const satelliteGridStore = useSatelliteGridStore();
const { loading, fetchData } = useFetchData(10000);
const animaLoading = ref(true);
 
let count = 0,
  max = 0;
// 网格数据详情
const gridDataDetailMap = new Map();
const gridDataDetailList = ref([]);
// 地图网格相关对象
let mapViews;
 
// 查询网格信息和遥感数据组
function onSearch(options) {
  satelliteGridStore.fetchGridCell(options.id).then(() => {
    drawGrid(satelliteGridStore.gridInfo);
  });
  satelliteGridStore.fetchGridData(options.id);
}
 
function fetchGridDataDetail(dataList) {
  dataList.forEach((d) => {
    gridApi.fetchGridDataDetail(d.id, d.groupId).then((res) => {
      gridDataDetailMap.set(d.id, res.data);
      // const gridData = res.data;
      // drawTextAndColor(gridData);
      finish();
    });
  });
}
 
function finish() {
  count++;
  if (count == max) {
    animaLoading.value = false;
    const list = [];
    gridDataDetailMap.forEach((value, key) => {
      list.push(value);
    });
 
    gridDataDetailList.value = list.sort((a, b) => {
      return a.dataId - b.dataId;
    });
    console.log(gridDataDetailList.value);
  }
}
 
function drawGrid(gridInfo) {
  SatelliteProxy.clearAll(mapViews);
  mapViews = SatelliteProxy.drawPolyline(gridInfo);
}
 
// 绘制网格遥感数据值和网格颜色
function drawTextAndColor(gridData) {
  // SatelliteProxy.clearText(mapViews);
  // 文本标记
  mapViews.textViews = SatelliteProxy.drawDataText(
    mapViews.points,
    gridData,
    mapViews.textViews
  );
  SatelliteProxy.drawColor(mapViews.gridViews, gridData);
}
 
function handleRowClick(row) {
  if (gridDataDetailMap.has(row.id)) {
    const gridData = gridDataDetailMap.get(row.id);
    drawTextAndColor(gridData);
  } else {
    gridApi.fetchGridDataDetail(row.id, row.groupId).then((res) => {
      gridDataDetailMap.set(row.id, res.data);
      const gridData = res.data;
      drawTextAndColor(gridData);
    });
  }
}
</script>
<style scoped>
.satellite-manage {
}
 
.historical {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
}
</style>