siderust-js 0.1.0
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/.github/workflows/ci.yml +166 -0
- package/.gitmodules +9 -0
- package/CHANGELOG.md +26 -0
- package/LICENSE +661 -0
- package/README.md +138 -0
- package/package.json +12 -0
- package/qtty-js/.github/workflows/ci.yml +151 -0
- package/qtty-js/.gitmodules +3 -0
- package/qtty-js/CHANGELOG.md +31 -0
- package/qtty-js/LICENSE +661 -0
- package/qtty-js/README.md +132 -0
- package/qtty-js/package.json +20 -0
- package/qtty-js/qtty/.github/workflows/ci.yml +155 -0
- package/qtty-js/qtty/CHANGELOG.md +120 -0
- package/qtty-js/qtty/Cargo.lock +1462 -0
- package/qtty-js/qtty/Cargo.toml +12 -0
- package/qtty-js/qtty/LICENSE +661 -0
- package/qtty-js/qtty/README.md +9 -0
- package/qtty-js/qtty/qtty/Cargo.toml +41 -0
- package/qtty-js/qtty/qtty/README.md +8 -0
- package/qtty-js/qtty/qtty/examples/angles.rs +14 -0
- package/qtty-js/qtty/qtty/examples/astronomy.rs +17 -0
- package/qtty-js/qtty/qtty/examples/dimensional_arithmetic.rs +83 -0
- package/qtty-js/qtty/qtty/examples/python_integration.rs +61 -0
- package/qtty-js/qtty/qtty/examples/quickstart.rs +15 -0
- package/qtty-js/qtty/qtty/examples/ratios.rs +12 -0
- package/qtty-js/qtty/qtty/examples/serde_with_unit.rs +234 -0
- package/qtty-js/qtty/qtty/examples/serialization.rs +141 -0
- package/qtty-js/qtty/qtty/examples/serialization_advanced.rs +155 -0
- package/qtty-js/qtty/qtty/src/f32.rs +108 -0
- package/qtty-js/qtty/qtty/src/f64.rs +30 -0
- package/qtty-js/qtty/qtty/src/i128.rs +111 -0
- package/qtty-js/qtty/qtty/src/i16.rs +111 -0
- package/qtty-js/qtty/qtty/src/i32.rs +111 -0
- package/qtty-js/qtty/qtty/src/i64.rs +111 -0
- package/qtty-js/qtty/qtty/src/i8.rs +111 -0
- package/qtty-js/qtty/qtty/src/lib.rs +238 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std/Cargo.lock +83 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std/Cargo.toml +10 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std/src/lib.rs +7 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std-alloc/Cargo.lock +83 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std-alloc/Cargo.toml +10 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std-alloc/src/lib.rs +7 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-std/Cargo.lock +83 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-std/Cargo.toml +10 -0
- package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-std/src/lib.rs +5 -0
- package/qtty-js/qtty/qtty/tests/integration_tests.rs +529 -0
- package/qtty-js/qtty/qtty/tests/qtty_vec_feature_matrix.rs +58 -0
- package/qtty-js/qtty/qtty-core/Cargo.toml +41 -0
- package/qtty-js/qtty/qtty-core/README.md +8 -0
- package/qtty-js/qtty/qtty-core/examples/diesel_integration.rs +145 -0
- package/qtty-js/qtty/qtty-core/examples/quantity_db_serde.rs +215 -0
- package/qtty-js/qtty/qtty-core/src/dimension.rs +249 -0
- package/qtty-js/qtty/qtty-core/src/feature_diesel.rs +318 -0
- package/qtty-js/qtty/qtty-core/src/feature_pyo3.rs +27 -0
- package/qtty-js/qtty/qtty-core/src/feature_serde.rs +203 -0
- package/qtty-js/qtty/qtty-core/src/feature_tiberius.rs +28 -0
- package/qtty-js/qtty/qtty-core/src/lib.rs +744 -0
- package/qtty-js/qtty/qtty-core/src/macros.rs +93 -0
- package/qtty-js/qtty/qtty-core/src/quantity.rs +810 -0
- package/qtty-js/qtty/qtty-core/src/scalar.rs +1742 -0
- package/qtty-js/qtty/qtty-core/src/unit.rs +332 -0
- package/qtty-js/qtty/qtty-core/src/units/angular.rs +1228 -0
- package/qtty-js/qtty/qtty-core/src/units/area.rs +243 -0
- package/qtty-js/qtty/qtty-core/src/units/frequency.rs +179 -0
- package/qtty-js/qtty/qtty-core/src/units/length.rs +1270 -0
- package/qtty-js/qtty/qtty-core/src/units/mass.rs +488 -0
- package/qtty-js/qtty/qtty-core/src/units/mod.rs +26 -0
- package/qtty-js/qtty/qtty-core/src/units/power.rs +324 -0
- package/qtty-js/qtty/qtty-core/src/units/time.rs +667 -0
- package/qtty-js/qtty/qtty-core/src/units/unitless.rs +212 -0
- package/qtty-js/qtty/qtty-core/src/units/velocity.rs +210 -0
- package/qtty-js/qtty/qtty-core/src/units/volume.rs +269 -0
- package/qtty-js/qtty/qtty-core/tests/core.rs +628 -0
- package/qtty-js/qtty/qtty-core/tests/diesel.rs +461 -0
- package/qtty-js/qtty/qtty-core/tests/integers.rs +632 -0
- package/qtty-js/qtty/qtty-core/tests/no_cross_unit_ops.rs +35 -0
- package/qtty-js/qtty/qtty-core/tests/pyo3.rs +334 -0
- package/qtty-js/qtty/qtty-core/tests/quantity_f32.rs +276 -0
- package/qtty-js/qtty/qtty-core/tests/scalar_decimal.rs +258 -0
- package/qtty-js/qtty/qtty-core/tests/scalar_f32.rs +286 -0
- package/qtty-js/qtty/qtty-core/tests/scalar_f64_real.rs +287 -0
- package/qtty-js/qtty/qtty-core/tests/scalar_rational.rs +260 -0
- package/qtty-js/qtty/qtty-core/tests/serde.rs +256 -0
- package/qtty-js/qtty/qtty-core/tests/tiberius.rs +208 -0
- package/qtty-js/qtty/qtty-derive/Cargo.toml +23 -0
- package/qtty-js/qtty/qtty-derive/README.md +8 -0
- package/qtty-js/qtty/qtty-derive/src/lib.rs +340 -0
- package/qtty-js/qtty/qtty-ffi/ARCHITECTURE.md +3 -0
- package/qtty-js/qtty/qtty-ffi/Cargo.toml +31 -0
- package/qtty-js/qtty/qtty-ffi/README.md +9 -0
- package/qtty-js/qtty/qtty-ffi/build.rs +326 -0
- package/qtty-js/qtty/qtty-ffi/cbindgen.toml +105 -0
- package/qtty-js/qtty/qtty-ffi/include/qtty_ffi.h +1126 -0
- package/qtty-js/qtty/qtty-ffi/src/ffi.rs +1251 -0
- package/qtty-js/qtty/qtty-ffi/src/ffi_serde.rs +294 -0
- package/qtty-js/qtty/qtty-ffi/src/helpers.rs +310 -0
- package/qtty-js/qtty/qtty-ffi/src/lib.rs +229 -0
- package/qtty-js/qtty/qtty-ffi/src/macros.rs +121 -0
- package/qtty-js/qtty/qtty-ffi/src/registry.rs +274 -0
- package/qtty-js/qtty/qtty-ffi/src/types.rs +620 -0
- package/qtty-js/qtty/qtty-ffi/tests/integration_tests.rs +842 -0
- package/qtty-js/qtty/qtty-ffi/units.csv +156 -0
- package/qtty-js/qtty/qtty-ffi/units.csv.md +3 -0
- package/qtty-js/qtty-node/.prettierignore +6 -0
- package/qtty-js/qtty-node/.prettierrc.json +6 -0
- package/qtty-js/qtty-node/README.md +250 -0
- package/qtty-js/qtty-node/c8.config.json +11 -0
- package/qtty-js/qtty-node/eslint.config.js +31 -0
- package/qtty-js/qtty-node/examples/arithmetic.mjs +64 -0
- package/qtty-js/qtty-node/examples/astronomy.mjs +90 -0
- package/qtty-js/qtty-node/examples/quickstart.mjs +36 -0
- package/qtty-js/qtty-node/examples/serialization.mjs +125 -0
- package/qtty-js/qtty-node/examples/unit_factories.mjs +74 -0
- package/qtty-js/qtty-node/index.d.ts +219 -0
- package/qtty-js/qtty-node/index.js +323 -0
- package/qtty-js/qtty-node/lib/DerivedQuantity.js +122 -0
- package/qtty-js/qtty-node/lib/Quantity.js +151 -0
- package/qtty-js/qtty-node/lib/backend.js +25 -0
- package/qtty-js/qtty-node/native.cjs +306 -0
- package/qtty-js/qtty-node/package-lock.json +3223 -0
- package/qtty-js/qtty-node/package.json +70 -0
- package/qtty-js/qtty-node/units.d.ts +299 -0
- package/qtty-js/qtty-node/units.js +210 -0
- package/qtty-js/qtty-web/Cargo.lock +767 -0
- package/qtty-js/qtty-web/Cargo.toml +21 -0
- package/qtty-js/qtty-web/index.d.ts +140 -0
- package/qtty-js/qtty-web/index.js +20 -0
- package/qtty-js/qtty-web/lib/DerivedQuantity.js +58 -0
- package/qtty-js/qtty-web/lib/Quantity.js +75 -0
- package/qtty-js/qtty-web/lib/backend.js +80 -0
- package/qtty-js/qtty-web/package.json +45 -0
- package/qtty-js/qtty-web/src/lib.rs +111 -0
- package/qtty-js/scripts/ci.sh +73 -0
- package/scripts/ci.sh +123 -0
- package/siderust-core/Cargo.lock +787 -0
- package/siderust-core/Cargo.toml +18 -0
- package/siderust-core/DEDUPLICATION.md +124 -0
- package/siderust-core/src/body.rs +120 -0
- package/siderust-core/src/events.rs +184 -0
- package/siderust-core/src/lib.rs +20 -0
- package/siderust-core/src/observer.rs +55 -0
- package/siderust-core/src/position.rs +213 -0
- package/siderust-node/.prettierignore +7 -0
- package/siderust-node/.prettierrc.json +6 -0
- package/siderust-node/Cargo.lock +906 -0
- package/siderust-node/Cargo.toml +29 -0
- package/siderust-node/README.md +109 -0
- package/siderust-node/__test__/index.test.mjs +248 -0
- package/siderust-node/build.rs +5 -0
- package/siderust-node/c8.config.json +3 -0
- package/siderust-node/eslint.config.js +31 -0
- package/siderust-node/examples/01_basic_coordinates.mjs +24 -0
- package/siderust-node/examples/02_coordinate_transformations.mjs +25 -0
- package/siderust-node/examples/03_all_frames_conversions.mjs +26 -0
- package/siderust-node/examples/04_all_center_conversions.mjs +24 -0
- package/siderust-node/examples/05_target_tracking.mjs +22 -0
- package/siderust-node/examples/06_night_events.mjs +18 -0
- package/siderust-node/examples/07_moon_properties.mjs +21 -0
- package/siderust-node/examples/08_solar_system.mjs +19 -0
- package/siderust-node/examples/09_star_observability.mjs +22 -0
- package/siderust-node/examples/10_time_periods.mjs +9 -0
- package/siderust-node/examples/11_serialization.mjs +31 -0
- package/siderust-node/examples/12_runtime_ephemeris.mjs +27 -0
- package/siderust-node/examples/13_coordinate_operations.mjs +20 -0
- package/siderust-node/index.d.ts +623 -0
- package/siderust-node/index.js +79 -0
- package/siderust-node/lib/Observer.js +112 -0
- package/siderust-node/lib/Star.js +118 -0
- package/siderust-node/lib/backend.js +63 -0
- package/siderust-node/lib/wrappers.js +566 -0
- package/siderust-node/main.js +20 -0
- package/siderust-node/native.cjs +360 -0
- package/siderust-node/package-lock.json +3261 -0
- package/siderust-node/package.json +71 -0
- package/siderust-node/src/body.rs +74 -0
- package/siderust-node/src/coordinates.rs +372 -0
- package/siderust-node/src/ephemeris.rs +462 -0
- package/siderust-node/src/events.rs +577 -0
- package/siderust-node/src/lib.rs +43 -0
- package/siderust-node/src/observer.rs +132 -0
- package/siderust-node/src/phase.rs +218 -0
- package/siderust-node/src/position.rs +292 -0
- package/siderust-node/src/star.rs +200 -0
- package/siderust-web/Cargo.lock +855 -0
- package/siderust-web/Cargo.toml +34 -0
- package/siderust-web/README.md +100 -0
- package/siderust-web/__test__/index.test.mjs +118 -0
- package/siderust-web/examples/github-pages/README.md +31 -0
- package/siderust-web/examples/github-pages/index.html +135 -0
- package/siderust-web/index.d.ts +311 -0
- package/siderust-web/index.js +66 -0
- package/siderust-web/lib/Observer.js +103 -0
- package/siderust-web/lib/Star.js +116 -0
- package/siderust-web/lib/backend.js +400 -0
- package/siderust-web/lib/wrappers.js +512 -0
- package/siderust-web/package.json +55 -0
- package/siderust-web/src/body.rs +69 -0
- package/siderust-web/src/coordinates.rs +302 -0
- package/siderust-web/src/ephemeris.rs +456 -0
- package/siderust-web/src/events.rs +520 -0
- package/siderust-web/src/lib.rs +51 -0
- package/siderust-web/src/observer.rs +117 -0
- package/siderust-web/src/phase.rs +190 -0
- package/siderust-web/src/position.rs +291 -0
- package/siderust-web/src/star.rs +178 -0
- package/tempoch-js/.github/workflows/ci.yml +142 -0
- package/tempoch-js/.gitmodules +3 -0
- package/tempoch-js/CHANGELOG.md +25 -0
- package/tempoch-js/LICENSE +661 -0
- package/tempoch-js/README.md +126 -0
- package/tempoch-js/package.json +20 -0
- package/tempoch-js/scripts/ci.sh +73 -0
- package/tempoch-js/tempoch/.github/workflows/ci.yml +113 -0
- package/tempoch-js/tempoch/CHANGELOG.md +82 -0
- package/tempoch-js/tempoch/Cargo.lock +947 -0
- package/tempoch-js/tempoch/Cargo.toml +3 -0
- package/tempoch-js/tempoch/LICENSE +661 -0
- package/tempoch-js/tempoch/README.md +76 -0
- package/tempoch-js/tempoch/tempoch/Cargo.toml +27 -0
- package/tempoch-js/tempoch/tempoch/examples/periods.rs +45 -0
- package/tempoch-js/tempoch/tempoch/examples/quickstart.rs +13 -0
- package/tempoch-js/tempoch/tempoch/src/lib.rs +49 -0
- package/tempoch-js/tempoch/tempoch/tests/integration.rs +57 -0
- package/tempoch-js/tempoch/tempoch-core/Cargo.toml +24 -0
- package/tempoch-js/tempoch/tempoch-core/src/delta_t.rs +345 -0
- package/tempoch-js/tempoch/tempoch-core/src/instant.rs +811 -0
- package/tempoch-js/tempoch/tempoch-core/src/julian_date_ext.rs +142 -0
- package/tempoch-js/tempoch/tempoch-core/src/lib.rs +81 -0
- package/tempoch-js/tempoch/tempoch-core/src/period.rs +1168 -0
- package/tempoch-js/tempoch/tempoch-core/src/scales.rs +779 -0
- package/tempoch-js/tempoch/tempoch-ffi/Cargo.lock +889 -0
- package/tempoch-js/tempoch/tempoch-ffi/Cargo.toml +26 -0
- package/tempoch-js/tempoch/tempoch-ffi/build.rs +24 -0
- package/tempoch-js/tempoch/tempoch-ffi/cbindgen.toml +30 -0
- package/tempoch-js/tempoch/tempoch-ffi/src/error.rs +19 -0
- package/tempoch-js/tempoch/tempoch-ffi/src/lib.rs +82 -0
- package/tempoch-js/tempoch/tempoch-ffi/src/period.rs +101 -0
- package/tempoch-js/tempoch/tempoch-ffi/src/time.rs +711 -0
- package/tempoch-js/tempoch/tempoch-ffi/tests/ffi.rs +265 -0
- package/tempoch-js/tempoch-node/.prettierignore +6 -0
- package/tempoch-js/tempoch-node/.prettierrc.json +6 -0
- package/tempoch-js/tempoch-node/Cargo.lock +496 -0
- package/tempoch-js/tempoch-node/Cargo.toml +29 -0
- package/tempoch-js/tempoch-node/README.md +265 -0
- package/tempoch-js/tempoch-node/__test__/index.test.mjs +598 -0
- package/tempoch-js/tempoch-node/build.rs +5 -0
- package/tempoch-js/tempoch-node/c8.config.json +3 -0
- package/tempoch-js/tempoch-node/eslint.config.js +31 -0
- package/tempoch-js/tempoch-node/examples/periods.mjs +79 -0
- package/tempoch-js/tempoch-node/examples/quickstart.mjs +71 -0
- package/tempoch-js/tempoch-node/examples/timescales.mjs +92 -0
- package/tempoch-js/tempoch-node/index.d.ts +280 -0
- package/tempoch-js/tempoch-node/index.js +32 -0
- package/tempoch-js/tempoch-node/lib/JulianDate.js +176 -0
- package/tempoch-js/tempoch-node/lib/ModifiedJulianDate.js +156 -0
- package/tempoch-js/tempoch-node/lib/Period.js +133 -0
- package/tempoch-js/tempoch-node/lib/backend.js +38 -0
- package/tempoch-js/tempoch-node/lib/qttyCompat.js +92 -0
- package/tempoch-js/tempoch-node/native.cjs +317 -0
- package/tempoch-js/tempoch-node/package-lock.json +3223 -0
- package/tempoch-js/tempoch-node/package.json +56 -0
- package/tempoch-js/tempoch-node/src/lib.rs +573 -0
- package/tempoch-js/tempoch-web/Cargo.toml +23 -0
- package/tempoch-js/tempoch-web/index.d.ts +95 -0
- package/tempoch-js/tempoch-web/index.js +27 -0
- package/tempoch-js/tempoch-web/lib/JulianDate.js +170 -0
- package/tempoch-js/tempoch-web/lib/ModifiedJulianDate.js +145 -0
- package/tempoch-js/tempoch-web/lib/Period.js +121 -0
- package/tempoch-js/tempoch-web/lib/backend.js +118 -0
- package/tempoch-js/tempoch-web/package.json +46 -0
- package/tempoch-js/tempoch-web/src/lib.rs +184 -0
|
@@ -0,0 +1,566 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @siderust/siderust — Typed wrapper functions.
|
|
3
|
+
*
|
|
4
|
+
* These wrappers enforce the public JS domain types and map the raw native
|
|
5
|
+
* transport values back into `Quantity`, `JulianDate`, `ModifiedJulianDate`,
|
|
6
|
+
* and `Period` objects.
|
|
7
|
+
*
|
|
8
|
+
* @module @siderust/siderust/lib/wrappers
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
const { Quantity } = require('@siderust/qtty');
|
|
15
|
+
const { JulianDate, ModifiedJulianDate, Period } = require('@siderust/tempoch');
|
|
16
|
+
const backend = require('./backend.js');
|
|
17
|
+
const { Observer } = require('./Observer.js');
|
|
18
|
+
const { Star } = require('./Star.js');
|
|
19
|
+
|
|
20
|
+
function toNativeObserver(obs) {
|
|
21
|
+
if (!(obs instanceof Observer)) {
|
|
22
|
+
throw new Error('Expected an Observer');
|
|
23
|
+
}
|
|
24
|
+
return new backend.NativeObserver(obs._lonDeg, obs._latDeg, obs._heightM);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function toNativeStar(star) {
|
|
28
|
+
if (!(star instanceof Star)) {
|
|
29
|
+
throw new Error('Expected a Star');
|
|
30
|
+
}
|
|
31
|
+
return new backend.NativeStar(
|
|
32
|
+
star._name,
|
|
33
|
+
star._distanceLy,
|
|
34
|
+
star._massSolar,
|
|
35
|
+
star._radiusSolar,
|
|
36
|
+
star._luminositySolar,
|
|
37
|
+
star._raDeg,
|
|
38
|
+
star._decDeg,
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function toJdValue(jd) {
|
|
43
|
+
if (!(jd instanceof JulianDate)) {
|
|
44
|
+
throw new Error('Expected a JulianDate');
|
|
45
|
+
}
|
|
46
|
+
return jd.value;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function toMjdValue(mjd) {
|
|
50
|
+
if (!(mjd instanceof ModifiedJulianDate)) {
|
|
51
|
+
throw new Error('Expected a ModifiedJulianDate');
|
|
52
|
+
}
|
|
53
|
+
return mjd.value;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function toWindow(window) {
|
|
57
|
+
if (!(window instanceof Period)) {
|
|
58
|
+
throw new Error('Expected a Period');
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
start: window.start.value,
|
|
62
|
+
end: window.end.value,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function toQuantity(value, unit, label) {
|
|
67
|
+
if (!(value instanceof Quantity)) {
|
|
68
|
+
throw new Error(`${label}: expected a Quantity`);
|
|
69
|
+
}
|
|
70
|
+
return value.to(unit);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function toScalar(value, unit, label) {
|
|
74
|
+
return toQuantity(value, unit, label).value;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function toAngleValue(value, label) {
|
|
78
|
+
return toScalar(value, 'Degree', label);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function toLengthTriple(x, y, z, label) {
|
|
82
|
+
const xQuantity = toQuantity(x, x && x.unit ? x.unit : 'Meter', `${label}.x`);
|
|
83
|
+
return {
|
|
84
|
+
unit: xQuantity.unit,
|
|
85
|
+
x: xQuantity.value,
|
|
86
|
+
y: toQuantity(y, xQuantity.unit, `${label}.y`).value,
|
|
87
|
+
z: toQuantity(z, xQuantity.unit, `${label}.z`).value,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function mapPlanetInfo(raw) {
|
|
92
|
+
return {
|
|
93
|
+
name: raw.name,
|
|
94
|
+
mass: new Quantity(raw.massKg, 'Kilogram'),
|
|
95
|
+
radius: new Quantity(raw.radiusKm, 'Kilometer'),
|
|
96
|
+
semiMajorAxis: new Quantity(raw.semiMajorAxisAu, 'AstronomicalUnit'),
|
|
97
|
+
eccentricity: raw.eccentricity,
|
|
98
|
+
inclination: new Quantity(raw.inclinationDeg, 'Degree'),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function mapDirection(raw) {
|
|
103
|
+
return {
|
|
104
|
+
polar: new Quantity(raw.polarDeg, 'Degree'),
|
|
105
|
+
azimuth: new Quantity(raw.azimuthDeg, 'Degree'),
|
|
106
|
+
frame: raw.frame,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function mapCartesianEcef(raw) {
|
|
111
|
+
return {
|
|
112
|
+
x: new Quantity(raw.x, 'Meter'),
|
|
113
|
+
y: new Quantity(raw.y, 'Meter'),
|
|
114
|
+
z: new Quantity(raw.z, 'Meter'),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function mapCartesianPosition(raw, unit) {
|
|
119
|
+
return {
|
|
120
|
+
x: new Quantity(raw.x, unit),
|
|
121
|
+
y: new Quantity(raw.y, unit),
|
|
122
|
+
z: new Quantity(raw.z, unit),
|
|
123
|
+
frame: raw.frame,
|
|
124
|
+
center: raw.center,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function mapCrossingEvent(raw) {
|
|
129
|
+
return {
|
|
130
|
+
mjd: new ModifiedJulianDate(raw.mjd),
|
|
131
|
+
direction: raw.direction,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function mapCulminationEvent(raw) {
|
|
136
|
+
return {
|
|
137
|
+
mjd: new ModifiedJulianDate(raw.mjd),
|
|
138
|
+
altitude: new Quantity(raw.altitudeDeg, 'Degree'),
|
|
139
|
+
kind: raw.kind,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function mapAzimuthExtremum(raw) {
|
|
144
|
+
return {
|
|
145
|
+
mjd: new ModifiedJulianDate(raw.mjd),
|
|
146
|
+
azimuth: new Quantity(raw.azimuthDeg, 'Degree'),
|
|
147
|
+
kind: raw.kind,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function mapPeriod(raw) {
|
|
152
|
+
return new Period(new ModifiedJulianDate(raw.startMjd), new ModifiedJulianDate(raw.endMjd));
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function mapPhase(raw) {
|
|
156
|
+
return {
|
|
157
|
+
phaseAngle: new Quantity(raw.phaseAngleDeg, 'Degree'),
|
|
158
|
+
illuminatedFraction: raw.illuminatedFraction,
|
|
159
|
+
elongation: new Quantity(raw.elongationDeg, 'Degree'),
|
|
160
|
+
waxing: raw.waxing,
|
|
161
|
+
label: raw.label,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function mapPhaseEvent(raw) {
|
|
166
|
+
return {
|
|
167
|
+
mjd: new ModifiedJulianDate(raw.mjd),
|
|
168
|
+
kind: raw.kind,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function mapPeriods(periods) {
|
|
173
|
+
return periods.map(mapPeriod);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function mapCrossings(events) {
|
|
177
|
+
return events.map(mapCrossingEvent);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function mapCulminations(events) {
|
|
181
|
+
return events.map(mapCulminationEvent);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function mapAzimuthExtrema(events) {
|
|
185
|
+
return events.map(mapAzimuthExtremum);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function transformDirection(polar, azimuth, srcFrame, dstFrame, jd) {
|
|
189
|
+
return mapDirection(
|
|
190
|
+
backend.transformDirection(
|
|
191
|
+
toAngleValue(polar, 'polar'),
|
|
192
|
+
toAngleValue(azimuth, 'azimuth'),
|
|
193
|
+
srcFrame,
|
|
194
|
+
dstFrame,
|
|
195
|
+
toJdValue(jd),
|
|
196
|
+
),
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function directionToHorizontal(polar, azimuth, srcFrame, jd, observer) {
|
|
201
|
+
return mapDirection(
|
|
202
|
+
backend.directionToHorizontal(
|
|
203
|
+
toAngleValue(polar, 'polar'),
|
|
204
|
+
toAngleValue(azimuth, 'azimuth'),
|
|
205
|
+
srcFrame,
|
|
206
|
+
toJdValue(jd),
|
|
207
|
+
toNativeObserver(observer),
|
|
208
|
+
),
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function geodeticToEcef(observer) {
|
|
213
|
+
return mapCartesianEcef(backend.geodeticToEcef(toNativeObserver(observer)));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function angularSeparation(polar1, azimuth1, polar2, azimuth2, frame) {
|
|
217
|
+
return new Quantity(
|
|
218
|
+
backend.angularSeparation(
|
|
219
|
+
toAngleValue(polar1, 'polar1'),
|
|
220
|
+
toAngleValue(azimuth1, 'azimuth1'),
|
|
221
|
+
toAngleValue(polar2, 'polar2'),
|
|
222
|
+
toAngleValue(azimuth2, 'azimuth2'),
|
|
223
|
+
frame,
|
|
224
|
+
),
|
|
225
|
+
'Degree',
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function cartesianDistance(x1, y1, z1, x2, y2, z2) {
|
|
230
|
+
const lhs = toLengthTriple(x1, y1, z1, 'point1');
|
|
231
|
+
const rhs = {
|
|
232
|
+
x: toQuantity(x2, lhs.unit, 'point2.x').value,
|
|
233
|
+
y: toQuantity(y2, lhs.unit, 'point2.y').value,
|
|
234
|
+
z: toQuantity(z2, lhs.unit, 'point2.z').value,
|
|
235
|
+
};
|
|
236
|
+
return new Quantity(
|
|
237
|
+
backend.cartesianDistance(lhs.x, lhs.y, lhs.z, rhs.x, rhs.y, rhs.z),
|
|
238
|
+
lhs.unit,
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function cartesianMagnitude(x, y, z) {
|
|
243
|
+
const vector = toLengthTriple(x, y, z, 'vector');
|
|
244
|
+
return new Quantity(backend.cartesianMagnitude(vector.x, vector.y, vector.z), vector.unit);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function dotProduct(x1, y1, z1, x2, y2, z2) {
|
|
248
|
+
return backend.dotProduct(x1, y1, z1, x2, y2, z2);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function directionToCartesian(polar, azimuth) {
|
|
252
|
+
return backend.directionToCartesian(
|
|
253
|
+
toAngleValue(polar, 'polar'),
|
|
254
|
+
toAngleValue(azimuth, 'azimuth'),
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function vsop87Heliocentric(body, jd) {
|
|
259
|
+
return mapCartesianPosition(backend.vsop87Heliocentric(body, toJdValue(jd)), 'AstronomicalUnit');
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function vsop87Barycentric(body, jd) {
|
|
263
|
+
return mapCartesianPosition(backend.vsop87Barycentric(body, toJdValue(jd)), 'AstronomicalUnit');
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function vsop87SunBarycentric(jd) {
|
|
267
|
+
return mapCartesianPosition(backend.vsop87SunBarycentric(toJdValue(jd)), 'AstronomicalUnit');
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function vsop87EarthBarycentric(jd) {
|
|
271
|
+
return mapCartesianPosition(backend.vsop87EarthBarycentric(toJdValue(jd)), 'AstronomicalUnit');
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function vsop87EarthHeliocentric(jd) {
|
|
275
|
+
return mapCartesianPosition(backend.vsop87EarthHeliocentric(toJdValue(jd)), 'AstronomicalUnit');
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function vsop87MoonGeocentric(jd) {
|
|
279
|
+
return mapCartesianPosition(backend.vsop87MoonGeocentric(toJdValue(jd)), 'Kilometer');
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function transformPositionCenter(x, y, z, srcCenter, dstCenter, jd) {
|
|
283
|
+
const coords = toLengthTriple(x, y, z, 'position');
|
|
284
|
+
return mapCartesianPosition(
|
|
285
|
+
backend.transformPositionCenter(
|
|
286
|
+
coords.x,
|
|
287
|
+
coords.y,
|
|
288
|
+
coords.z,
|
|
289
|
+
srcCenter,
|
|
290
|
+
dstCenter,
|
|
291
|
+
toJdValue(jd),
|
|
292
|
+
),
|
|
293
|
+
coords.unit,
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function transformPositionFrame(x, y, z, srcFrame, dstFrame, jd) {
|
|
298
|
+
const coords = toLengthTriple(x, y, z, 'position');
|
|
299
|
+
return mapCartesianPosition(
|
|
300
|
+
backend.transformPositionFrame(coords.x, coords.y, coords.z, srcFrame, dstFrame, toJdValue(jd)),
|
|
301
|
+
coords.unit,
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function orbitalPeriod(name) {
|
|
306
|
+
return new Quantity(backend.orbitalPeriodDays(name), 'Day');
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function bodyAltitudeAt(body, observer, mjd) {
|
|
310
|
+
return new Quantity(
|
|
311
|
+
backend.bodyAltitudeAt(body, toNativeObserver(observer), toMjdValue(mjd)),
|
|
312
|
+
'Degree',
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function bodyAzimuthAt(body, observer, mjd) {
|
|
317
|
+
return new Quantity(
|
|
318
|
+
backend.bodyAzimuthAt(body, toNativeObserver(observer), toMjdValue(mjd)),
|
|
319
|
+
'Degree',
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function bodyCrossings(body, observer, window, threshold) {
|
|
324
|
+
const range = toWindow(window);
|
|
325
|
+
return mapCrossings(
|
|
326
|
+
backend.bodyCrossings(
|
|
327
|
+
body,
|
|
328
|
+
toNativeObserver(observer),
|
|
329
|
+
range.start,
|
|
330
|
+
range.end,
|
|
331
|
+
toAngleValue(threshold, 'threshold'),
|
|
332
|
+
),
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function bodyCulminations(body, observer, window) {
|
|
337
|
+
const range = toWindow(window);
|
|
338
|
+
return mapCulminations(
|
|
339
|
+
backend.bodyCulminations(body, toNativeObserver(observer), range.start, range.end),
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function bodyAboveThreshold(body, observer, window, threshold) {
|
|
344
|
+
const range = toWindow(window);
|
|
345
|
+
return mapPeriods(
|
|
346
|
+
backend.bodyAboveThreshold(
|
|
347
|
+
body,
|
|
348
|
+
toNativeObserver(observer),
|
|
349
|
+
range.start,
|
|
350
|
+
range.end,
|
|
351
|
+
toAngleValue(threshold, 'threshold'),
|
|
352
|
+
),
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function bodyBelowThreshold(body, observer, window, threshold) {
|
|
357
|
+
const range = toWindow(window);
|
|
358
|
+
return mapPeriods(
|
|
359
|
+
backend.bodyBelowThreshold(
|
|
360
|
+
body,
|
|
361
|
+
toNativeObserver(observer),
|
|
362
|
+
range.start,
|
|
363
|
+
range.end,
|
|
364
|
+
toAngleValue(threshold, 'threshold'),
|
|
365
|
+
),
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function bodyAzimuthCrossings(body, observer, window, bearing) {
|
|
370
|
+
const range = toWindow(window);
|
|
371
|
+
return mapCrossings(
|
|
372
|
+
backend.bodyAzimuthCrossings(
|
|
373
|
+
body,
|
|
374
|
+
toNativeObserver(observer),
|
|
375
|
+
range.start,
|
|
376
|
+
range.end,
|
|
377
|
+
toAngleValue(bearing, 'bearing'),
|
|
378
|
+
),
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function bodyAzimuthExtrema(body, observer, window) {
|
|
383
|
+
const range = toWindow(window);
|
|
384
|
+
return mapAzimuthExtrema(
|
|
385
|
+
backend.bodyAzimuthExtrema(body, toNativeObserver(observer), range.start, range.end),
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function starAltitudeAt(star, observer, mjd) {
|
|
390
|
+
return new Quantity(
|
|
391
|
+
backend.starAltitudeAt(toNativeStar(star), toNativeObserver(observer), toMjdValue(mjd)),
|
|
392
|
+
'Degree',
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
function starAzimuthAt(star, observer, mjd) {
|
|
397
|
+
return new Quantity(
|
|
398
|
+
backend.starAzimuthAt(toNativeStar(star), toNativeObserver(observer), toMjdValue(mjd)),
|
|
399
|
+
'Degree',
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
function starCrossings(star, observer, window, threshold) {
|
|
404
|
+
const range = toWindow(window);
|
|
405
|
+
return mapCrossings(
|
|
406
|
+
backend.starCrossings(
|
|
407
|
+
toNativeStar(star),
|
|
408
|
+
toNativeObserver(observer),
|
|
409
|
+
range.start,
|
|
410
|
+
range.end,
|
|
411
|
+
toAngleValue(threshold, 'threshold'),
|
|
412
|
+
),
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
function starCulminations(star, observer, window) {
|
|
417
|
+
const range = toWindow(window);
|
|
418
|
+
return mapCulminations(
|
|
419
|
+
backend.starCulminations(
|
|
420
|
+
toNativeStar(star),
|
|
421
|
+
toNativeObserver(observer),
|
|
422
|
+
range.start,
|
|
423
|
+
range.end,
|
|
424
|
+
),
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
function starAboveThreshold(star, observer, window, threshold) {
|
|
429
|
+
const range = toWindow(window);
|
|
430
|
+
return mapPeriods(
|
|
431
|
+
backend.starAboveThreshold(
|
|
432
|
+
toNativeStar(star),
|
|
433
|
+
toNativeObserver(observer),
|
|
434
|
+
range.start,
|
|
435
|
+
range.end,
|
|
436
|
+
toAngleValue(threshold, 'threshold'),
|
|
437
|
+
),
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
function starBelowThreshold(star, observer, window, threshold) {
|
|
442
|
+
const range = toWindow(window);
|
|
443
|
+
return mapPeriods(
|
|
444
|
+
backend.starBelowThreshold(
|
|
445
|
+
toNativeStar(star),
|
|
446
|
+
toNativeObserver(observer),
|
|
447
|
+
range.start,
|
|
448
|
+
range.end,
|
|
449
|
+
toAngleValue(threshold, 'threshold'),
|
|
450
|
+
),
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
function starAzimuthCrossings(star, observer, window, bearing) {
|
|
455
|
+
const range = toWindow(window);
|
|
456
|
+
return mapCrossings(
|
|
457
|
+
backend.starAzimuthCrossings(
|
|
458
|
+
toNativeStar(star),
|
|
459
|
+
toNativeObserver(observer),
|
|
460
|
+
range.start,
|
|
461
|
+
range.end,
|
|
462
|
+
toAngleValue(bearing, 'bearing'),
|
|
463
|
+
),
|
|
464
|
+
);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
function starAzimuthExtrema(star, observer, window) {
|
|
468
|
+
const range = toWindow(window);
|
|
469
|
+
return mapAzimuthExtrema(
|
|
470
|
+
backend.starAzimuthExtrema(
|
|
471
|
+
toNativeStar(star),
|
|
472
|
+
toNativeObserver(observer),
|
|
473
|
+
range.start,
|
|
474
|
+
range.end,
|
|
475
|
+
),
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
function intersectPeriods(periods1, periods2) {
|
|
480
|
+
const rawPeriods1 = periods1.map((period, index) => {
|
|
481
|
+
const range = toWindow(period);
|
|
482
|
+
return { startMjd: range.start, endMjd: range.end, index };
|
|
483
|
+
});
|
|
484
|
+
const rawPeriods2 = periods2.map((period, index) => {
|
|
485
|
+
const range = toWindow(period);
|
|
486
|
+
return { startMjd: range.start, endMjd: range.end, index };
|
|
487
|
+
});
|
|
488
|
+
return mapPeriods(backend.intersectPeriods(rawPeriods1, rawPeriods2));
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
function moonPhase(jd) {
|
|
492
|
+
return mapPhase(backend.moonPhase(toJdValue(jd)));
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
function moonPhaseTopocentric(jd, observer) {
|
|
496
|
+
return mapPhase(backend.moonPhaseTopocentric(toJdValue(jd), toNativeObserver(observer)));
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function findPhaseEvents(window) {
|
|
500
|
+
const range = toWindow(window);
|
|
501
|
+
return backend.findPhaseEvents(range.start, range.end).map(mapPhaseEvent);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
function moonIlluminationAbove(window, kMin) {
|
|
505
|
+
const range = toWindow(window);
|
|
506
|
+
return mapPeriods(backend.moonIlluminationAbove(range.start, range.end, kMin));
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
function moonIlluminationBelow(window, kMax) {
|
|
510
|
+
const range = toWindow(window);
|
|
511
|
+
return mapPeriods(backend.moonIlluminationBelow(range.start, range.end, kMax));
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
function moonIlluminationRange(window, kMin, kMax) {
|
|
515
|
+
const range = toWindow(window);
|
|
516
|
+
return mapPeriods(backend.moonIlluminationRange(range.start, range.end, kMin, kMax));
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
module.exports = {
|
|
520
|
+
transformDirection,
|
|
521
|
+
directionToHorizontal,
|
|
522
|
+
geodeticToEcef,
|
|
523
|
+
angularSeparation,
|
|
524
|
+
cartesianDistance,
|
|
525
|
+
cartesianMagnitude,
|
|
526
|
+
dotProduct,
|
|
527
|
+
directionToCartesian,
|
|
528
|
+
vsop87Heliocentric,
|
|
529
|
+
vsop87Barycentric,
|
|
530
|
+
vsop87SunBarycentric,
|
|
531
|
+
vsop87EarthBarycentric,
|
|
532
|
+
vsop87EarthHeliocentric,
|
|
533
|
+
vsop87MoonGeocentric,
|
|
534
|
+
transformPositionCenter,
|
|
535
|
+
transformPositionFrame,
|
|
536
|
+
orbitalPeriod,
|
|
537
|
+
bodyAltitudeAt,
|
|
538
|
+
bodyAzimuthAt,
|
|
539
|
+
bodyCrossings,
|
|
540
|
+
bodyCulminations,
|
|
541
|
+
bodyAboveThreshold,
|
|
542
|
+
bodyBelowThreshold,
|
|
543
|
+
bodyAzimuthCrossings,
|
|
544
|
+
bodyAzimuthExtrema,
|
|
545
|
+
starAltitudeAt,
|
|
546
|
+
starAzimuthAt,
|
|
547
|
+
starCrossings,
|
|
548
|
+
starCulminations,
|
|
549
|
+
starAboveThreshold,
|
|
550
|
+
starBelowThreshold,
|
|
551
|
+
starAzimuthCrossings,
|
|
552
|
+
starAzimuthExtrema,
|
|
553
|
+
intersectPeriods,
|
|
554
|
+
moonPhase,
|
|
555
|
+
moonPhaseTopocentric,
|
|
556
|
+
findPhaseEvents,
|
|
557
|
+
moonIlluminationAbove,
|
|
558
|
+
moonIlluminationBelow,
|
|
559
|
+
moonIlluminationRange,
|
|
560
|
+
getPlanet(name) {
|
|
561
|
+
return mapPlanetInfo(backend.getPlanet(name));
|
|
562
|
+
},
|
|
563
|
+
listBodies: backend.listBodies,
|
|
564
|
+
listCatalogStars: backend.listCatalogStars,
|
|
565
|
+
version: backend.version,
|
|
566
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @siderust/siderust — Astronomy primitives for Node.js.
|
|
3
|
+
*
|
|
4
|
+
* Public entrypoint. Exposes the typed JS façade classes and wrapper
|
|
5
|
+
* functions while keeping the generated N-API loader internal.
|
|
6
|
+
*
|
|
7
|
+
* @module @siderust/siderust
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
const { Observer } = require('./lib/Observer.js');
|
|
13
|
+
const { Star } = require('./lib/Star.js');
|
|
14
|
+
const wrappers = require('./lib/wrappers.js');
|
|
15
|
+
|
|
16
|
+
module.exports = {
|
|
17
|
+
Observer,
|
|
18
|
+
Star,
|
|
19
|
+
...wrappers,
|
|
20
|
+
};
|