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



local Name = "Surface Temperature"
local Identifier = "noaa-sos-land-surface_temperature"
local Description = [[These maps combine high-resolution daytime surface temperatures
derived from satellite observations for both land and sea and display them with a common
color scale. Displaying these high-resolution data with a common color scale makes
evident the large difference between surface heating on land versus the sea. It also
shows the relatively small seasonal variation in sea surface temperature over the globe
relative to land temperatures. The larger seasonal variation in average temperature of
the northern hemisphere relative to the southern hemisphere, a result of the larger land
area in the northern hemisphere, is also evident]]
local URL = "https://sos.noaa.gov/catalog/datasets/surface-temperature/"


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 Colorbar = {
  Identifier = Identifier,
  Name = Name,
  Enabled = asset.enabled,
  Type = "ScreenSpaceImageLocal",
  TexturePath = syncedDirectory .. "colorbar.png",
  FaceCamera = false,
  Scale = 0.07,
  CartesianPosition = { 1.0, 0.0, -2.0 }
}

local Colorbar2 = {
  Identifier = Identifier .. "-1",
  Name = Name .. " (1)",
  Enabled = asset.enabled,
  Type = "ScreenSpaceImageLocal",
  TexturePath = syncedDirectory .. "colorbar2.png",
  FaceCamera = false,
  CartesianPosition = { 0.0, -0.5, -2.0 }
}


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

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

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



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