Add the ability to use integer NAIF IDs in a SpiceTranslation

This commit is contained in:
Alexander Bock
2022-08-01 18:25:55 +02:00
parent 41a4171aeb
commit 351eb33d61
17 changed files with 42 additions and 31 deletions

View File

@@ -23,8 +23,8 @@ local lem_model = asset.syncedResource({
--landing - 1969-07-20T20:17:40
local apolloSpiceId = "-911"
local apolloLemSpiceId = "-911500"
local apolloSpiceId = -911
local apolloLemSpiceId = -911500
local Apollo11Position = {
Identifier = "Apollo11Position",

View File

@@ -9,7 +9,7 @@ local models = asset.syncedResource({
Version = 4
})
local apolloSpiceId = "-908"
local apolloSpiceId = -908
local Apollo8Launch = {
Identifier = "Apollo8Launch",

View File

@@ -9,7 +9,7 @@ local models = asset.syncedResource({
Version = 4
})
local apolloSpiceId = "-908"
local apolloSpiceId = -908
local Apollo8 = {
Identifier = "Apollo8",

View File

@@ -2,7 +2,7 @@ local earth_transforms = asset.require("scene/solarsystem/planets/earth/transfor
local moon_transforms = asset.require("scene/solarsystem/planets/earth/moon/moon")
local kernels = asset.require("./kernels").kernels
local apolloSpiceId = "-908"
local apolloSpiceId = -908
local LaunchTrail = {

View File

@@ -104,7 +104,7 @@ local TranslationKeyframes = {
Frame = "IAU_MARS",
Kernels = iKernels,
FixedDate = "2018 NOV 26 19:45:34"
},
}
}
local RotationKeyframes = {
@@ -770,7 +770,7 @@ local Insight_Trail = {
Type = "RenderableTrailTrajectory",
Translation = {
Type = "SpiceTranslation",
Target = "-189",
Target = -189,
Observer = "MARS",
Frame = "IAU_MARS",
Kernels = iKernels

View File

@@ -29,7 +29,7 @@ local JWSTTrailLaunch = {
Type = "RenderableTrailTrajectory",
Translation = {
Type = 'SpiceTranslation',
Target = '170', -- JWST
Target = 170, -- JWST
Observer = 'EARTH',
Frame = 'IAU_EARTH',
Kernels = { kernels .. "webb.bsp" }
@@ -62,7 +62,7 @@ local JWSTTrailCruise = {
Type = "RenderableTrailTrajectory",
Translation = {
Type = 'SpiceTranslation',
Target = '170', -- JWST
Target = 170, -- JWST
Observer = 'EARTH',
Frame = 'GALACTIC',
Kernels = { kernels .. "webb.bsp" }
@@ -95,8 +95,8 @@ local JWSTTrailOrbit = {
Type = "RenderableTrailOrbit",
Translation = {
Type = 'SpiceTranslation',
Target = '170', -- JWST
Observer = '392', -- L2
Target = 170, -- JWST
Observer = 392, -- L2
Frame = 'GALACTIC',
Kernels = { kernels .. "webb.bsp" }
},
@@ -125,7 +125,7 @@ local JWSTSunTrail = {
Type = "RenderableTrailOrbit",
Translation = {
Type = 'SpiceTranslation',
Target = '170', -- JWST
Target = 170, -- JWST
Observer = 'SSB',
Frame = 'GALACTIC',
Kernels = { kernels .. "webb.bsp" }

View File

@@ -23,22 +23,22 @@ local JWSTPosition = {
Keyframes = {
[launchTime] = {
Type = 'SpiceTranslation',
Target = '170', -- JWST
Target = 170, -- JWST
Observer = 'EARTH',
Frame = 'IAU_EARTH',
Kernels = { kernels .. "webb.bsp" }
},
[detachTime] = {
Type = 'SpiceTranslation',
Target = '170', -- JWST
Target = 170, -- JWST
Observer = 'EARTH',
Frame = 'GALACTIC',
Kernels = { kernels .. "webb.bsp" }
},
[L2orbitInsertionTime] = {
Type = 'SpiceTranslation',
Target = '170', -- JWST
Observer = '392', -- L2
Target = 170, -- JWST
Observer = 392, -- L2
Frame = 'GALACTIC',
Kernels = { kernels .. "webb.bsp" }
}

View File

@@ -4,7 +4,7 @@ local earthTransforms = asset.require("scene/solarsystem/planets/earth/transform
local BENNU_BODY = "2101955"
local BENNU_BODY = 2101955
local OsirisRexTrailEarth = {
Identifier = "OsirisRexTrailEarth",

View File

@@ -2,7 +2,7 @@ local transforms = asset.require("scene/solarsystem/sun/transforms")
local BENNU_BODY = "2101955"
local BENNU_BODY = 2101955
local BennuBarycenter = {
Identifier = "BennuBarycenter",

View File

@@ -8,7 +8,7 @@ local kernels = asset.syncedResource({
Version = 2
})
local perseverance_id = "-168"
local perseverance_id = -168
local m2020_kernels = {
kernels .. "m2020.tf",

View File

@@ -11,7 +11,7 @@ local kernelsFolder = asset.syncedResource({
local kernelsList = { kernelsFolder .. "p10-a.bsp" }
local Pioneer10NAIF = "-23"
local Pioneer10NAIF = -23
local Pioneer10 = {
Identifier = "Pioneer_10",

View File

@@ -14,7 +14,7 @@ local kernelsList = {
kernelsFolder .. "p11_sat336.bsp"
}
local Pioneer11NAIF = "-24"
local Pioneer11NAIF = -24
local Pioneer11 = {
Identifier = "Pioneer_11",

View File

@@ -21,7 +21,7 @@ local L1Position = {
Transform = {
Translation = {
Type = "SpiceTranslation",
Target = "391", -- L1
Target = 391, -- L1
Observer = "SSB",
Kernels = kernels .. "L1_de431.bsp"
}

View File

@@ -21,7 +21,7 @@ local L2Position = {
Transform = {
Translation = {
Type = "SpiceTranslation",
Target = "392", -- L2
Target = 392, -- L2
Observer = "SSB",
Kernels = kernels .. "L2_de431.bsp"
}

View File

@@ -21,7 +21,7 @@ local L4Position = {
Transform = {
Translation = {
Type = "SpiceTranslation",
Target = "394", -- L4
Target = 394, -- L4
Observer = "SSB",
Kernels = kernels .. "L4_de431.bsp"
}

View File

@@ -21,7 +21,7 @@ local L5Position = {
Transform = {
Translation = {
Type = "SpiceTranslation",
Target = "395", -- L5
Target = 395, -- L5
Observer = "SSB",
Kernels = kernels .. "L5_de431.bsp"
}

View File

@@ -35,6 +35,7 @@
#include <ghoul/misc/profiling.h>
#include <filesystem>
#include <optional>
#include <variant>
namespace {
constexpr openspace::properties::Property::PropertyInfo TargetInfo = {
@@ -69,12 +70,10 @@ namespace {
struct [[codegen::Dictionary(SpiceTranslation)]] Parameters {
// [[codegen::verbatim(TargetInfo.description)]]
std::string target
[[codegen::annotation("A valid SPICE NAIF name or identifier")]];
std::variant<std::string, int> target;
// [[codegen::verbatim(ObserverInfo.description)]]
std::string observer
[[codegen::annotation("A valid SPICE NAIF name or identifier")]];
std::variant<std::string, int> observer;
std::optional<std::string> frame
[[codegen::annotation("A valid SPICE NAIF name for a reference frame")]];
@@ -162,8 +161,20 @@ SpiceTranslation::SpiceTranslation(const ghoul::Dictionary& dictionary)
_fixedDate = p.fixedDate.value_or(_fixedDate);
addProperty(_fixedDate);
_target = p.target;
_observer = p.observer;
if (std::holds_alternative<std::string>(p.target)) {
_target = std::get<std::string>(p.target);
}
else {
_target = std::to_string(std::get<int>(p.target));
}
if (std::holds_alternative<std::string>(p.observer)) {
_observer = std::get<std::string>(p.observer);
}
else {
_observer = std::to_string(std::get<int>(p.observer));
}
_frame = p.frame.value_or(_frame);
}