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


local Name = "Nighttime Lights Comparison - 1992 and 2002"
local Identifier = "noaa-sos-land-earth_night-1992_2002"
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-2002/"


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

local layer_1992 = {
  Identifier = Identifier .. "-1992",
  Name = Name .. " (1992)",
  FilePath = syncedDirectory .. "Nightlights_1992.jpg",
  Description = Description
}

local layer_2002 = {
  Identifier = Identifier .. "-2002",
  Name = Name .. " (2002)",
  FilePath = syncedDirectory .. "Nightlights_2002.jpg",
  Description = Description
}

asset.onInitialize(function() 
  openspace.globebrowsing.addLayer(globeIdentifier, "ColorLayers", layer_1992)
  openspace.globebrowsing.addLayer(globeIdentifier, "ColorLayers", layer_2002)
end)

asset.onDeinitialize(function()
  openspace.globebrowsing.deleteLayer(globeIdentifier, "ColorLayers", layer_1992)
  openspace.globebrowsing.deleteLayer(globeIdentifier, "ColorLayers", layer_2002)
end)

asset.export(layer_1992)
asset.export(layer_2002)


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