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



local Name = "Polar Orbiting: NOAA-17 Satellite Coverage"
local Identifier = "noaa-sos-atmosphere-poes_sat"
local Description = [[Satellites allow scientists to observe the Earth from above the
atmosphere. The National Oceanic and Atmospheric Administration, NOAA, has several
different types of satellites, including geostationary and polar orbiting satellites.
These datasets show the path of Polar-orbiting Operational Environmental Satellites, or
POES for short. NOAA has two POES in operation currently, a morning and afternoon
satellite. The morning satellite crosses the equator on the sun-light side of the Earth
in the morning, and the afternoon satellite crosses in the afternoon. Both satellites
orbit the Earth 14.1 times per day]]
local URL = "https://sos.noaa.gov/catalog/datasets/polar-orbiting-noaa-17-satellite-coverage/"


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 = "poes_cover_%Y%j%H%M.jpg"
  },
  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/"
}
