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



local Name = "NOAA Science on a Sphere. Agriculture: Pastureland Intensity"
local Identifier = "noaa-sos-land-agriculture-pastureland"
local Description = [[These visualizations, created by the University of Minnesota's
Institute on the Environment, show the global land use intensity for pastureland and
cropland. Cropland is land devoted to growing plants for humans use for food, material,
or fuel. Pastureland is land used for raising and grazing animals. Altogether, cropland
covers about 16 million square kilometers, an area of land approximately the size of
South America. Global pastureland occupies more than 30 million square kilometers, about
the area of Africa]]
local URL = "https://sos.noaa.gov/catalog/datasets/agriculture-pastureland-intensity/"


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


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

local LayerCountries = {
  Identifier = Identifier .. "-countries",
  Name = Name .. " (w/ countries)",
  Enabled = asset.enabled,
  FilePath = syncedDirectory .. "4096_countries.png",
  Description = Description
}

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


asset.onInitialize(function()
  openspace.globebrowsing.addLayer(globe.Earth.Identifier, "ColorLayers", Layer)
  openspace.globebrowsing.addLayer(globe.Earth.Identifier, "ColorLayers", LayerCountries)
  openspace.addScreenSpaceRenderable(Legend)
end)

asset.onDeinitialize(function()
  openspace.removeScreenSpaceRenderable(Legend)
  openspace.globebrowsing.deleteLayer(globe.Earth.Identifier, "ColorLayers", LayerCountries)
  openspace.globebrowsing.deleteLayer(globe.Earth.Identifier, "ColorLayers", Layer)
end)

asset.export(Layer)
asset.export(LayerCountries)
asset.export(Legend)



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