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


local Name = "Japan Tsunami: Wave Propagation - March 11, 2011"
local Identifier = "noaa-sos-oceans-japan_tsunami_waves"
local Description = [[On March 11, 2011 at 2:45 p.m. local time, a 9.0 magnitude 
earthquake occurred 81 miles (130 km) off the east coast of Sendai, Honshu, Japan, 
triggering a massive tsunami. A tsunami is a series of ocean waves generated by sudden 
displacements in the sea floor, landslides, or volcanic activity. In the deep ocean, the 
tsunami wave may only be a few inches high. The tsunami wave may come gently ashore or 
may increase in height to become a fast moving wall of turbulent water several meters 
high. Forecasted wave heights in Japan were up to 66 ft (20 m) and there were many 
reports of tsunami waves three stories high in parts of Japan. Across the Pacific Ocean, 
many countries issued evacuations along the coasts because of the predicted tsunami 
waves. Propagation of the tsunami was computed with the NOAA forecast method using the 
MOST (Method of Splitting Tsunami) model with the tsunami source inferred from DART. 
Approximately 25 minutes after the earthquake, the tsunami was first recorded by one of 
the DART buoys]]
local URL = "https://sos.noaa.gov/catalog/datasets/japan-tsunami-wave-propagation-march-11-2011/"


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