chore: update satellite.js to version 6.0.0 and improve position validation in calculations
This commit is contained in:
@ -66,7 +66,7 @@ export class SatelliteCalculator {
|
||||
|
||||
try {
|
||||
const positionAndVelocity = propagate(satrec, jsDate);
|
||||
if (typeof positionAndVelocity.position === 'boolean') {
|
||||
if (positionAndVelocity === null) {
|
||||
console.warn(`卫星 ${satelliteId} 在时间 ${jsDate} 位置计算失败或已衰减。`);
|
||||
continue; // 跳过这个时间点
|
||||
}
|
||||
|
@ -35,9 +35,8 @@ export async function demo_01_OrbitGeneration(viewer: Viewer) {
|
||||
// 获取卫星位置
|
||||
const positionAndVelocity = propagate(satrec, time);
|
||||
|
||||
// 有时可能返回false
|
||||
const position = positionAndVelocity.position;
|
||||
if (typeof position === 'boolean') {
|
||||
const position = positionAndVelocity?.position;
|
||||
if (!position) {
|
||||
console.error('Error calculating satellite position');
|
||||
return;
|
||||
}
|
||||
@ -58,9 +57,9 @@ export async function demo_01_OrbitGeneration(viewer: Viewer) {
|
||||
// 获取当前位置用于放置卫星模型
|
||||
const time = new Date();
|
||||
const positionAndVelocity = propagate(satrec, time);
|
||||
const position = positionAndVelocity.position;
|
||||
const position = positionAndVelocity?.position;
|
||||
const gmst = gstime(time);
|
||||
if (typeof position === 'boolean') {
|
||||
if (!position) {
|
||||
console.error('Error calculating satellite position');
|
||||
return;
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ export async function demo_02_Track(
|
||||
|
||||
// 计算卫星位置
|
||||
const positionAndVelocity = propagate(satrec, jsDate);
|
||||
if (typeof positionAndVelocity.position === 'boolean') {
|
||||
if (positionAndVelocity === null) {
|
||||
console.error('Error calculating satellite position');
|
||||
} else {
|
||||
const gmst = gstime(jsDate);
|
||||
|
@ -97,8 +97,7 @@ class SatelliteEntity {
|
||||
// 获取地心惯性坐标系坐标
|
||||
getPositionEci(date: Date) {
|
||||
const result = propagate(this.satrec, date);
|
||||
// 检查position是否为对象且不是true
|
||||
if (typeof result.position !== 'object' || result.position === null) {
|
||||
if (result === null) {
|
||||
return null;
|
||||
}
|
||||
return result.position;
|
||||
|
Reference in New Issue
Block a user