master
2022-06-09 c6b04bbd291289e93131155249042c69c8d2d0bc
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
/* eslint-disable no-undef */
importScripts("../../lib/mars3d/plugins/space/worker/mars3d-tle-worker.js");
let mars3d = mars3dTle;
 
self.onmessage = function (e) {
  let arr = e.data.list;
  let time = e.data.time;
 
  let positionObj = {};
  for (let i = 0; i < arr.length; i++) {
    let item = arr[i];
 
    try {
      let 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()
};