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



local Name = "Fires - 2009"
local Identifier = "noaa-sos-land-fire"
local Description = [[In order to monitor the fires occurring globally, a special sensor
has been mounted on the Terra and Aqua satellites. The sensor, named the Moderate
Resolution Imaging Spectroradiometer (MODIS), is able to provide daily satellite images
of the Earth's landmasses in near real-time using the MODIS Rapid Response System. There
are many uses for the data collected from MODIS, such as monitoring global fires by
detecting the abnormally high temperature anomalies at the surface. When a location is
much warmer than the surrounding area, it suggests the presence of a fire or a lava flow.
It is important to know the size, location and intensity of fires because of the damage
that they can cause, and also to help scientists understand the emissions from the fires
and their short- and long-term effects on ecosystems]]
local URL = "https://sos.noaa.gov/catalog/datasets/fires-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 = "TemporalTileLayer",
  Mode = "Folder",
  Folder = {
    Folder = syncedDirectory .. "4096",
    -- See https://en.cppreference.com/w/cpp/io/manip/get_time for an explanation of the
    -- time formatting string
    Format = "firemap.%Y%j-%Y%j.4096x2048.png"
  },
  Description = Description
}


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

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

asset.export(Layer)



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