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

local layer =  {
  Identifier = "Earth_at_Night_Temporal_Blue_Yellow",
  Name = "Earth at Night Blue Yellow (Temporal)",
  Enabled = asset.enabled,
  Type = "TemporalTileLayer",
  Mode = "Prototyped",
  Prototyped = {
    Time = {
      Start = "2021-04-30",
      End = "Yesterday"
    },
    TemporalResolution = "1d",
    TimeFormat = "YYYY-MM-DD",
    Prototype = openspace.globebrowsing.createTemporalGibsGdalXml(
      "VIIRS_SNPP_DayNightBand_AtSensor_M15",
      "500m",
      "jpg"
    )
  },
  Description = [[The VIIRS Nighttime Imagery (Day/Night Band, Enhanced Near Constant
    Contrast) layer shows the Earth's surface and atmosphere using a sensor designed
    to capture low-light emission sources, under varying illumination conditions. It
    is displayed as a grey-scale image. Sources of illumination include both natural
    and anthropogenic sources of light emissions. Lunar reflection can be used to
    highlight the location and features of clouds and other terrestrial features such
    as sea ice and snow cover when there is partial to full moon conditions. When
    there is no moonlight, natural and anthropogenic night time light emissions are
    highlighted such as city lights, lightning, auroras, fires, gas flares, and
    fishing fleets. This layer is useful for showing patterns of human activity and
    energy behaviors such as cities and highways, the holiday periods, the tracking
    of shipping and fishing fleets at night and, the burning of waste natural gas
    (gas flares) from on and offshore oil/gas production sites. <br><br>The VIIRS
    Nighttime Imagery (Day/Night Band, Enhanced Near Constant Contrast) layer is
    available from the Visible Infrared Imaging Radiometer Suite (VIIRS) on the joint
    NASA/NOAA Suomi National Polar orbiting Partnership (Suomi NPP) satellite.
    The sensor resolution is 750 m at nadir, imagery resolution is 500 m, and the
    temporal resolution is daily. (Description from NASA Worldview)]],
}

asset.onInitialize(function()
  openspace.globebrowsing.addLayer(globeIdentifier, "NightLayers", layer)
end)

asset.onDeinitialize(function()
  openspace.globebrowsing.deleteLayer(globeIdentifier, "NightLayers", layer)
end)

asset.export("layer", layer)



asset.meta = {
  Name = "Earth at Night Blue Yellow(Temporal)",
  Version = "1.1",
  Description = "Temporal layer for earth with daily night image",
  Author = "OpenSpace Team",
  URL = "https://worldview.earthdata.nasa.gov/?l=VIIRS_SNPP_DayNightBand_ENCC",
  License = "NASA"
}
