local earthTransforms = asset.require("scene/solarsystem/planets/earth/transforms")


local trail = asset.syncedResource({
  Name = "Gaia Trail",
  Type = "HttpSynchronization",
  Identifier = "gaia_trail",
  Version = 3
})

local GaiaPosition = {
  Identifier = "GaiaPosition",
  Parent = earthTransforms.EarthCenter.Identifier,
  Transform = {
    Translation = {
      Type = "HorizonsTranslation",
      HorizonsTextFile = {
        trail .. "gaia_orbit_horizons_1.hrz", --2013-12-19 09:55:27 to 2014-01-19 00:00:00
        trail .. "gaia_orbit_horizons_2.hrz"  --2014-01-19 00:00:00 to 2026-09-14 00:00:00
        -- Target: Gaia (spacecraft) (-139479)
        -- Observer: Earth (399 GEOCENTRIC)
        -- Start time: 2013-Dec-19 09:55:27 (first data point)
        -- End time: 2026-Sep-14 00:00:00 (last data point)
        -- Step size: First file has 40 minutes and seocnd has 1 day step size
      }
    },
  },
  GUI = {
    Name = "Position",
    Path = "/Solar System/Missions/Gaia"
  }
}

asset.onInitialize(function()
  openspace.addSceneGraphNode(GaiaPosition)
end)
  
asset.onDeinitialize(function()
  openspace.removeSceneGraphNode(GaiaPosition)
end)
  
asset.export(GaiaPosition)


asset.meta = {
  Name = "Gaia Transform",
  Version = "1.0",
  Description = [[This asset contains the position of Gaia from 2013 DEC 19 09:55:27 to
    2026 SEP 14 21:15:27. Data from JPL Horizons]],
  Author = "OpenSpace Team",
  URL = "https://ssd.jpl.nasa.gov/horizons.cgi",
  License = "NASA"
}
