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


local Name = "Tsunami Historical Series: Japan - 2011"
local Identifier = "noaa-sos-oceans-tsunami_historical_series-japan"
local Description = [[At 14:46 in the afternoon of March 11, 2011 (05:46 UTC), a 9.0 
moment magnitude earthquake struck near the coastline of Honshu, Japan. The Pacific 
Tsunami Warning Center (PTWC) quickly determined that the very large magnitude of this 
earthquake, its offshore location, its relatively shallow depth within the earth, and a 
history of megathrust earthquakes in the region meant that it likely moved the seafloor 
and thus posed a significant tsunami risk. As per international agreements Japanese 
authorities issued tsunami warnings for their own coastlines while PTWC began issuing 
warnings to other countries and territories in the western Pacific Ocean. The earthquake 
did in fact cause a tsunami, and over the following hours as PTWC learned more about the 
earthquake (confirming it was a megathrust and upgrading its magnitude) and its tsunami 
through forecast models and direct observation with DART sensors and coastal sea-level 
gauges PTWC would eventually issue tsunami warnings to the State of Hawaii and all 
remaining countries and territories participating the Pacific Tsunami Warning System, 
keeping warnings in some areas in effect for more than a day. PTWC's sister office, the 
West Coast and Alaska Tsunami Warning Center (now known as the National Tsunami Warning 
Center), also issued tsunami warnings for Alaska and the Pacific coasts of the United 
States and Canada. The tsunami caused the greatest devastation and over 17,000 deaths in 
Japan, where waves reached over 40 m or 130 ft. high. Outside of Japan the tsunami also 
killed one person in Papua, Indonesia and rose to greater than 5 m or 16 ft. in the 
Galapagos Islands (Ecuador), greater than 2m or 6.5 ft. in Indonesia, Russia's Kuril 
Islands, and in Chile, and rose to greater than 1 m or 3 ft. in Costa Rica, the Marquesas 
Islands (French Polynesia), Mexico, Papua New Guinea, and Peru. In the United States the 
tsunami rose to more than 5 m or 16 ft. in Hawaii, more than 2 m or 6.5 ft in California 
and Oregon, and more than 1 m or 3 ft. in the U.S. island territories of Midway and 
Saipan (Northern Mariana Islands). The tsunami also killed one person in Crescent City, 
California]]
local URL = "https://sos.noaa.gov/catalog/datasets/tsunami-historical-series-japan-2011/"


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

local layer_coastal = {
  Identifier = Identifier .. "-coastal",
  Name = Name .. " (Coastal)",
  FilePath = syncedDirectory .. "Tsunami_Coastal_Map_Japan_2011_4k.jpg",
  Description = Description
}

local layer_energy_coastal = {
  Identifier = Identifier .. "-energy_coastal",
  Name = Name .. " (Energy Coastal)",
  FilePath = syncedDirectory .. "Tsunami_Energy+Coastal_Map_Japan_2011_4k.jpg",
  Description = Description
}

local layer_energy = {
  Identifier = Identifier .. "-energy",
  Name = Name .. " (Energy)",
  FilePath = syncedDirectory .. "Tsunami_Energy_Map_Japan_2011_4k.jpg",
  Description = Description
}

local layer_null = {
  Identifier = Identifier .. "-null",
  Name = Name .. " (Null)",
  FilePath = syncedDirectory .. "Tsunami_Null_Coastal_Map_Japan_2011_4k.jpg",
  Description = Description
}


asset.onInitialize(function() 
  openspace.globebrowsing.addLayer(globeIdentifier, "ColorLayers", layer_coastal)
  openspace.globebrowsing.addLayer(globeIdentifier, "ColorLayers", layer_energy_coastal)
  openspace.globebrowsing.addLayer(globeIdentifier, "ColorLayers", layer_energy)
  openspace.globebrowsing.addLayer(globeIdentifier, "ColorLayers", layer_null)
end)

asset.onDeinitialize(function()
  openspace.globebrowsing.deleteLayer(globeIdentifier, "ColorLayers", layer_coastal)
  openspace.globebrowsing.deleteLayer(globeIdentifier, "ColorLayers", layer_energy_coastal)
  openspace.globebrowsing.deleteLayer(globeIdentifier, "ColorLayers", layer_energy)
  openspace.globebrowsing.deleteLayer(globeIdentifier, "ColorLayers", layer_null)
end)

asset.export(layer_coastal)
asset.export(layer_energy_coastal)
asset.export(layer_energy)
asset.export(layer_null)


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