@saber-usa/node-common 1.7.22 → 1.7.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/udl.js +81 -1
package/package.json
CHANGED
package/src/udl.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {fixDate} from "./fixDate.js";
|
|
2
2
|
import {
|
|
3
3
|
calcRegime,
|
|
4
|
+
cartesianToKeplerian,
|
|
4
5
|
getElsetUdlFromTle,
|
|
5
6
|
getLonAndDrift,
|
|
6
7
|
getRaanPrecession,
|
|
@@ -310,4 +311,83 @@ const enrichUdlFields = (npsOb) => {
|
|
|
310
311
|
return npsOb;
|
|
311
312
|
};
|
|
312
313
|
|
|
313
|
-
|
|
314
|
+
const getSVSatno = (udlRow) => {
|
|
315
|
+
if (udlRow.satNo) {return udlRow.satNo;}
|
|
316
|
+
if (udlRow.idOnOrbit) {return udlRow.idOnOrbit;}
|
|
317
|
+
if (!udlRow.origObjectId) {return null;}
|
|
318
|
+
|
|
319
|
+
const id = udlRow.origObjectId;
|
|
320
|
+
if (
|
|
321
|
+
/^\d+$/.test(id)
|
|
322
|
+
|| /^\d+~~.+$/.test(id) // KBR
|
|
323
|
+
) {
|
|
324
|
+
return Number.parseInt(id); // parse int will ignore everything after an invalid character
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
return null;
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
const udlToNpsState = (udlRow) => {
|
|
331
|
+
const Xpos = _.get(udlRow, "xpos", null); // kilometers
|
|
332
|
+
const Ypos = _.get(udlRow, "ypos", null);
|
|
333
|
+
const Zpos = _.get(udlRow, "zpos", null);
|
|
334
|
+
|
|
335
|
+
const Xvel = _.get(udlRow, "xvel", null); // kilometers/second
|
|
336
|
+
const Yvel = _.get(udlRow, "yvel", null);
|
|
337
|
+
const Zvel = _.get(udlRow, "zvel", null);
|
|
338
|
+
const cov = _.get(udlRow, "cov", null );
|
|
339
|
+
const covRefFrame = _.get(udlRow, "covReferenceFrame", null );
|
|
340
|
+
let keplerians = {a: null, e: null, i: null, raan: null, w: null, f: null};
|
|
341
|
+
|
|
342
|
+
if (Xpos !== null && Ypos !== null && Zpos !== null
|
|
343
|
+
&& Xvel !== null && Yvel !== null && Zvel !== null) {
|
|
344
|
+
const KM_TO_M = 1000;
|
|
345
|
+
|
|
346
|
+
const pos = [Xpos * KM_TO_M, Ypos * KM_TO_M, Zpos * KM_TO_M]; // Position, in meters
|
|
347
|
+
const vel = [Xvel * KM_TO_M, Yvel * KM_TO_M, Zvel * KM_TO_M]; // Velocity, in m/s
|
|
348
|
+
|
|
349
|
+
// [ a, e, i, Ω, ω, θ ]
|
|
350
|
+
// sma (km), eccentricity, inclination (deg), raan (deg), arg of perigee (deg), true anomaly (deg)
|
|
351
|
+
keplerians = cartesianToKeplerian(pos, vel);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
const npsState = lowerCaseObjectKeys({
|
|
355
|
+
satno: getSVSatno(udlRow),
|
|
356
|
+
Epoch: fixDate(_.get(udlRow, "epoch", null)),
|
|
357
|
+
idStateVector: _.get(udlRow, "idStateVector", null),
|
|
358
|
+
classificationMarking: _.get(udlRow, "classificationMarking", null),
|
|
359
|
+
referenceFrame: _.get(udlRow, "referenceFrame", null),
|
|
360
|
+
Pedigree: _.get(udlRow, "pedigree", null),
|
|
361
|
+
uct: _.get(udlRow, "uct", null),
|
|
362
|
+
idOnOrbit: _.get(udlRow, "idOnOrbit", null),
|
|
363
|
+
origObjectId: _.get(udlRow, "origObjectId", null),
|
|
364
|
+
descriptor: _.get(udlRow, "descriptor", null),
|
|
365
|
+
Xpos: Xpos,
|
|
366
|
+
Ypos: Ypos,
|
|
367
|
+
Zpos: Zpos,
|
|
368
|
+
Xvel: Xvel,
|
|
369
|
+
Yvel: Yvel,
|
|
370
|
+
Zvel: Zvel,
|
|
371
|
+
Covariance: JSON.stringify(cov),
|
|
372
|
+
CovarianceRefFrame: covRefFrame,
|
|
373
|
+
SemiMajorAxis: keplerians.a,
|
|
374
|
+
Eccentricity: keplerians.e,
|
|
375
|
+
Inclination: keplerians.i,
|
|
376
|
+
Raan: keplerians.raan,
|
|
377
|
+
ArgOfPerigee: keplerians.w,
|
|
378
|
+
TrueAnomaly: keplerians.f,
|
|
379
|
+
|
|
380
|
+
source: _.get(udlRow, "source", null),
|
|
381
|
+
dataMode: _.get(udlRow, "dataMode", null),
|
|
382
|
+
createdat: fixDate(_.get(udlRow, "createdAt", null)),
|
|
383
|
+
|
|
384
|
+
Latitude: null,
|
|
385
|
+
Longitude: null,
|
|
386
|
+
LonDriftDegreesPerDay: null,
|
|
387
|
+
RaanPrecessionDegreesPerDay: null,
|
|
388
|
+
Regime: 1,
|
|
389
|
+
});
|
|
390
|
+
return npsState;
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
export {udlToNpsElset, udlToNpsGroundSite, udlToNpsConjunction, udlToNpsState, enrichUdlFields};
|