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



local Name = "Species Richness - Mammals Threatened"
local Identifier = "noaa-sos-land-species_richness-mammals_threatened"
local Description = [[Understanding the biodiversity of our planet is critical for
developing conservation strategies. This series of datasets shows the biodiversity of
birds, mammals, and amphibians. Said simply, these maps show how many kinds of birds or
mammals or amphibians live in each area around the world. These maps look at just the
animals on land and don't include any marine animals. Also included are corresponding
maps of where the threatened species live, the ones at greatest risk of extinction.
Knowing where these threatened species live can help direct conservation efforts to
ensure that the places with the most vulnerable species are being protected]]
local URL = "https://sos.noaa.gov/catalog/datasets/species-richness-mammals-threatened/"


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


local Layer4096 = {
  Identifier = Identifier,
  Name = Name,
  FilePath = syncedDirectory .. "4096.png",
  Description = Description
}

local LayerWithBackground = {
  Identifier = Identifier .. "-background",
  Name = Name .. " (w/ Background)",
  FilePath = syncedDirectory .. "4096-background.png",
  Description = Description
}

local Labels = {
  Identifier = Identifier,
  Name = Name,
  Type = "ScreenSpaceImageLocal",
  TexturePath = syncedDirectory .. "labels.png",
  FaceCamera = false,
  CartesianPosition = { 0.0, -0.5, -2.0 }
}


asset.onInitialize(function()
  openspace.globebrowsing.addLayer(globe.Earth.Identifier, "ColorLayers", Layer4096)
  openspace.globebrowsing.addLayer(globe.Earth.Identifier, "ColorLayers", LayerWithBackground)
  openspace.addScreenSpaceRenderable(Labels)
end)

asset.onDeinitialize(function()
  openspace.removeScreenSpaceRenderable(Labels)
  openspace.globebrowsing.deleteLayer(globe.Earth.Identifier, "ColorLayers", LayerWithBackground)
  openspace.globebrowsing.deleteLayer(globe.Earth.Identifier, "ColorLayers", Layer4096)
end)

asset.export(Layer4096)
asset.export(LayerWithBackground)
asset.export(Labels)



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