fuchengshen
2022-07-09 3a25c05b5ab837714f30469cdcb1e2a77d8d7f6c
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
 
 
// eslint-disable-next-line no-undef
importScripts("/lib/mars3d/plugins/space/worker/mars3d-tle-worker.js")
 
// eslint-disable-next-line no-undef
const mars3d = mars3dTle
 
self.onmessage = function (e) {
  const arr = e.data.list
  const time = e.data.time
 
  const positionObj = {}
  for (let i = 0; i < arr.length; i++) {
    const item = arr[i]
 
    try {
      const position = mars3d.Tle.getEcfPosition(item.tle1, item.tle2, time) // 计算卫星位置
      if (position) {
        positionObj[item.id] = position
      }
    } catch (err) {
      continue
    }
  }
 
  // self代表子线程自身
  self.postMessage({ time: time, positionObj: positionObj })
  // self.close()
}