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



local Name = "Typhoon Haiyan - Oct - Nov 2013"
local Identifier = "noaa-sos-atmosphere-typhoon_haiyan"
local Description = [[Typhoon Haiyan, also known in the Phillippines as Typhoon Yolanda,
may be the strongest recorded tropical cyclone to make landfall with sustained speeds up
to 195 mph. If confirmed, it would beat the previous record holder, Hurricane Camille
(1969). This dataset is taken from the Real-Time Linear IR satellite dataset from October
30th to November 12th, 2013]]
local URL = "https://sos.noaa.gov/catalog/datasets/typhoon-haiyan-oct-nov-2013/"


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


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

local Track = {
  Identifier = Identifier .. "-track",
  Name = Name .. " (Track)",
  Enabled = asset.enabled,
  FilePath = syncedDirectory .. "track.png",
  Description = Description
}


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

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

asset.export(Layer)
asset.export(Track)



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