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


local Name = "Nighttime Lights Comparison - 1992 and 2009"
local Identifier = "noaa-sos-land-earth_night-1992_2009"
local Description = [[The data was recorded by the Defense Meteorological Satellite 
Program (DMSP) in the National Geophysical Data Center (NGDC), now part of NOAA National 
Centers for Environmental Information (NCEI). The data was collected using polar orbiting 
satellites that provide full cover of the globe twice a day. The satellites have an 
Operation Linescan system which allows them to detect low levels of visible-near infrared 
radiance at night]]
local URL = "https://sos.noaa.gov/catalog/datasets/nighttime-lights-comparison-1992-and-2009/"


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

local layer = {
  Identifier = Identifier,
  Name = Name,
  Enabled = asset.enabled,
  FilePath = syncedDirectory .. "5000.png",
  Description = Description
}

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

asset.onInitialize(function() 
  openspace.globebrowsing.addLayer(globeIdentifier, "ColorLayers", layer)
  openspace.addScreenSpaceRenderable(colorbar);  
end)

asset.onDeinitialize(function()
  openspace.globebrowsing.deleteLayer(globeIdentifier, "ColorLayers", layer)
  openspace.removeScreenSpaceRenderable(colorbar)
end)

asset.export(layer)
asset.export(colorbar)


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