Riku
2025-01-01 7b1293cec33b47680f08756bd1f8518d3cb1a729
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<template>
  <div>
    <!-- <el-button
      class="p-events-auto"
      type="info"
      icon="Memo"
      plain
      @click="draw"
    >
      绘制网格
    </el-button> -->
    <SatelliteManage
      class="satellite-manage"
      :gridDataList="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 gridInfo = [];
// 网格数据组
const gridDataList = ref([]);
let count = 0,
  max = 0;
// 网格数据详情
const gridDataDetailMap = new Map();
const gridDataDetailList = ref([]);
// 地图网格相关对象
let mapViews;
 
// 查询网格信息和遥感数据组
function onSearch(options) {
  fetchGridCell(options.id);
  fetchGridData(options.id);
}
 
// 获取网格信息
function fetchGridCell(groupId) {
  return fetchData(() => {
    return gridApi.fetchGridCell(groupId).then((res) => {
      gridInfo = res.data;
      drawGrid(gridInfo);
    });
  });
}
 
// 获取遥感数据组
function fetchGridData(groupId) {
  return gridApi.fetchGridData(groupId).then((res) => {
    gridDataList.value = res.data;
    count = 0;
    max = res.data.length;
    fetchGridDataDetail(res.data);
  });
}
 
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);
  // 文本标记
  const { textViews, labelsLayer } = SatelliteProxy.drawDataText(
    mapViews.points,
    gridData,
    mapViews.textViews
  );
  mapViews.textViews = textViews;
  mapViews.labelsLayer = labelsLayer;
  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>