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

local layer = {
  Identifier = "ESRI_VIIRS_Combo",
  Name = "ESRI VIIRS Combo",
  Enabled = asset.enabled,
  Type = "ByLevelTileLayer",
  LevelTileProviders = {
    {
      MaxLevel = 4,
      TileProvider = {
        Identifier = "Temporal_VIIRS_SNPP",
        Name = "Temporal VIIRS SNPP",
        Type = "TemporalTileLayer",
        Mode = "Prototyped",
        Prototyped = {
          Time = {
            Start = "2015-11-24",
            End = "Today"
          },
          TemporalResolution = "1d",
          TimeFormat = "YYYY-MM-DD",
          Prototype = openspace.globebrowsing.createTemporalGibsGdalXml(
            "VIIRS_SNPP_CorrectedReflectance_TrueColor",
            "250m",
            "jpg"
          )
        },
        PadTiles = false
      }
    },
    {
      MaxLevel = 22,
      TileProvider = {
        Identifier = "ESRI_World_Imagery",
        Name = "ESRI World Imagery",
        FilePath = asset.localResource("esri_world_imagery.wms"),
        PadTiles = false
      }
    },
  },
  PadTiles = false,
  Description = [[Level based layer combining "VIIRS SNPP (Temporal)" and ESRI World
    Imagery. "VIIRS SNPP (Temporal)" is faded out at tile level 4]]
}

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

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

asset.export("layer", layer)



asset.meta = {
  Name = "ESRI VIIRS Combo",
  Version = "1.1",
  Description = [[Level based layer combining "VIIRS SNPP (Temporal)" and ESRI World
  Imagery. "VIIRS SNPP (Temporal)" is faded out at tile level 4]],
  Author = "OpenSpace Tem",
  URL = "http://www.openspaceproject.com",
  License = "MIT License"
}
