local globe = asset.require("../../earth")



local Name = "Atmospheric Chemistry: GEOS-5 Model"
local Identifier = "noaa-sos-atmosphere-nccs_models-chem"
local Description = [[Models create a dynamic portrait of the Earth through numerical
experiments that simulate our current knowledge of the dynamical and physical processes
governing weather and climate variability. The simulation visualized here captures how
winds lift up aerosols from the Earth's surface and transport them around the globe
during the period September 1, 2006 to March 17, 2007. Such simulations allow scientists
to identify the sources and pathways of these tiny particulates that influence weather
and climate]]
local URL = "https://sos.noaa.gov/catalog/datasets/atmospheric-chemistry-geos-5-model/"


local syncedDirectory = asset.syncedResource({
  Name = Name,
  Type = "HttpSynchronization",
  Identifier = Identifier,
  Version = 1,
  UnzipFiles = true,
  UnzipFilesDestination = "images"
})


local Layer = {
  Identifier = Identifier,
  Name = Name,
  Enabled = asset.enabled,
  Type = "TemporalTileLayer",
  Mode = "Folder",
  Folder = {
    Folder = syncedDirectory .. "images",
    -- See https://en.cppreference.com/w/cpp/io/manip/get_time for an explanation of the
    -- time formatting string
    Format = "chem_%Y-%m-%d_%H-%M.png"
  },
  Description = Description
}

local Legend = {
  Identifier = Identifier,
  Name = Name,
  Enabled = asset.enabled,
  Type = "ScreenSpaceImageLocal",
  TexturePath = syncedDirectory .. "geos-5-legend.jpg",
  FaceCamera = false,
  CartesianPosition = { 0.0, -0.5, -2.0 }
}


asset.onInitialize(function()
  openspace.globebrowsing.addLayer(globe.Earth.Identifier, "ColorLayers", Layer)
  openspace.addScreenSpaceRenderable(Legend)
end)

asset.onDeinitialize(function()
  openspace.removeScreenSpaceRenderable(Legend)
  openspace.globebrowsing.deleteLayer(globe.Earth.Identifier, "ColorLayers", Layer)
end)

asset.export(Layer)
asset.export(Legend)



asset.meta = {
  Name = Name,
  Version = "1.0",
  Description = Description .. "Data provided by the National Oceanic and Atmospheric Administration",
  Author = "National Oceanic and Atmospheric Administration",
  URL = URL,
  License = "https://sos.noaa.gov/copyright/"
}
