local globeIdentifier = asset.require("../../earth").Earth.Identifier


local Name = "Float Tracks: Argo (buoy depths animation)"
local Identifier = "noaa-sos-oceans-argo_buoy_waterfall"
local Description = [["Argo is a global array of 3,000 free-drifting profiling floats 
that measures the temperature and salinity of the upper 2000 m of the ocean. This allows, 
for the first time, continuous monitoring of the temperature, salinity, and velocity of 
the upper ocean, with all data being relayed and made publicly available within hours 
after collection." - from the Argo website. In Greek mythology, Jason sailed on the ship 
Argo to capture a golden fleece. In the world of oceanography, Jason is a satellite 
altimeter that allows scientists to measure the heights of the ocean surfaces. This 
worldwide buoy program was named Argo because the data from the Jason project and from 
this buoy project will be used together in computer models to help forecast ocean 
climate]]
local URL = "https://sos.noaa.gov/catalog/datasets/float-tracks-argo-buoy-depths-animation/"


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

local imagesDestination = syncedDirectory .. "images"

local layer = {
  Identifier = Identifier,
  Name = Name,
  Enabled = asset.enabled,
  Type = "ImageSequenceTileLayer",
  FolderPath = imagesDestination,
  Description = Description
}

asset.onInitialize(function()
  if not openspace.directoryExists(imagesDestination) then
    openspace.printInfo("Extracting " .. Name)
    openspace.unzipFile(syncedDirectory .. "4096.zip", imagesDestination, true)
  end

  openspace.globebrowsing.addLayer(globeIdentifier, "ColorLayers", layer)
end)

asset.onDeinitialize(function()
  openspace.globebrowsing.deleteLayer(globeIdentifier, "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/"
}
