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



local Name = "Earthquakes and Eruptions - 1960 - 2010"
local Identifier = "noaa-sos-land-earthquakes_and_eruptions"
local Description = [[Most of Earth's earthquakes and volcanic eruptions occur at the
boundaries of the tectonic plates. This dataset shows all earthquakes of magnitude 5.0 or
greater from 1960 through 2010. The earthquakes are illustrated with a large white dot at
the time of the event. The size of the dot is proportional to the magnitude of the
earthquake. A musical tone is generated for the larger events. The larger the earthquake,
the lower the tone. The white dots eventually turn gray and slowly shrink to single-pixel
dots]]
local URL = "https://sos.noaa.gov/catalog/datasets/earthquakes-and-eruptions-1960-2010/"


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


local Layer = {
  Identifier = Identifier,
  Name = Name,
  Enabled = asset.enabled,
  Type = "ImageSequenceTileLayer",
  FolderPath = syncedDirectory .. "4096",
  Description = Description
}

local Legend = {
  Identifier = Identifier,
  Name = Name,
  Enabled = asset.enabled,
  Type = "ScreenSpaceImageLocal",
  TexturePath = syncedDirectory .. "eqmaglegend.png",
  FaceCamera = false,
  CartesianPosition = { 0.0, -0.5, -2.0 }
}


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

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

asset.export(Layer)
asset.export(Legend)



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