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



local Name = "Sea Surface Temperature NOAA Model (with vegetation)"
local Identifier = "noaa-sos-oceans-gfdl_sst-land_background"
local Description = [[This dataset shows how the global ocean's surface water
temperatures vary over the course of few years. In addition to seeing the effects of the
seasonal cycle, the viewer can see how surface ocean currents and eddies transport heat
and water around the globe. The images were generated not from observations, but from a
state-of-the-art computer model of Earth's climate created at NOAA's Geophysical Fluid
Dynamics Laboratory (GFDL)]]
local URL = "https://sos.noaa.gov/catalog/datasets/sea-surface-temperature-noaa-model-with-vegetation/"


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 = "GFDL_CM2p4_SSTctl_%Y.png"
  },
  Description = Description
}

local Colorbar = {
  Identifier = Identifier,
  Name = Name,
  Enabled = asset.enabled,
  Type = "ScreenSpaceImageLocal",
  TexturePath = syncedDirectory .. "colorbar.png",
  FaceCamera = false,
  Scale = 0.04,
  CartesianPosition = { 0.85, 0.0, -2.0 }
}


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

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

asset.export(Layer)
asset.export(Colorbar)



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/"
}
