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



local Name = "Sea Ice Animation - 2009"
local Identifier = "noaa-sos-oceans-2009_ice_animation"
local Description = [[Sea ice is simply ocean water that has frozen. At least 15% of the
ocean is covered by sea ice some part of the year. This means that on average, sea ice
covers almost 10 million square miles (about 25 million square kilometers) of the Earth.
Sea ice concentrations are monitored closely by scientists because changing sea ice
concentrations can have a huge impact on the rest of the globe. Global warming is
amplified in polar regions. Because of this, monitoring changes in sea ice can be a good
indicator of climate change. The Global Snow and Ice Cover Map that is used in this
dataset is created from a combination of observations from NOAA Advanced Very High
Resolution Radiometer, Meteosat Second Generation Satellite Spectral Response
Characterisation, GOES Imager and Defense Meteorological Satellite Program Special Sensor
Microwave/Imager. The resolution is 2 km]]
local URL = "https://sos.noaa.gov/catalog/datasets/sea-ice-animation-2009/"


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


local Layer = {
  Identifier = Identifier,
  Name = Name,
  Enabled = asset.enabled,
  Type = "ImageSequenceTileLayer",
  FolderPath = syncedDirectory .. "4096",
  Description = Description
}

local Colorbar2007to2009 = {
  Identifier = Identifier .. "-2007_2009",
  Name = Name .. " (2007-2009 Compare)",
  Enabled = asset.enabled,
  Type = "ScreenSpaceImageLocal",
  TexturePath = syncedDirectory .. "2007-2009-Compare.png",
  FaceCamera = false,
  CartesianPosition = { -0.85, -0.5, -2.0 }
}

local Colorbar2008Minimum = {
  Identifier = Identifier .. "-2008_minimum",
  Name = Name .. " (2008 Minimum)",
  Enabled = asset.enabled,
  Type = "ScreenSpaceImageLocal",
  TexturePath = syncedDirectory .. "2008-Minimum-Label.png",
  FaceCamera = false,
  CartesianPosition = { 0.6, -0.4, -2.0 }
}

local Colorbar2009IceConcentration = {
  Identifier = Identifier .. "-2009_iceconcentration",
  Name = Name .. " (2009 Ice Concentration)",
  Enabled = asset.enabled,
  Type = "ScreenSpaceImageLocal",
  TexturePath = syncedDirectory .. "2009-IceConcentration-Label.png",
  FaceCamera = false,
  CartesianPosition = { 0.6, -0.6, -2.0 }
}


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

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

asset.export(Layer)
asset.export(Colorbar2007to2009)
asset.export(Colorbar2008Minimum)
asset.export(Colorbar2009IceConcentration)



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