From f7ff2e33da8b537376ec86e636ba0d581e3fc05d Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 6 Feb 2023 23:07:21 +0100 Subject: [PATCH] Properly report an error when an .info file is missing the identifier, preventing the addition of a layer without one (closes #2490) --- apps/OpenSpace/ext/sgct | 2 +- .../globebrowsing/scripts/layer_support.lua | 21 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/apps/OpenSpace/ext/sgct b/apps/OpenSpace/ext/sgct index 5a42316a64..4a555d7922 160000 --- a/apps/OpenSpace/ext/sgct +++ b/apps/OpenSpace/ext/sgct @@ -1 +1 @@ -Subproject commit 5a42316a648c7402cf6d20ec49dd56da14b7ca4a +Subproject commit 4a555d7922d161a0ada27e060e3741cfd6c336fa diff --git a/modules/globebrowsing/scripts/layer_support.lua b/modules/globebrowsing/scripts/layer_support.lua index d9c89cc383..8f58ac41f7 100644 --- a/modules/globebrowsing/scripts/layer_support.lua +++ b/modules/globebrowsing/scripts/layer_support.lua @@ -10,7 +10,7 @@ openspace.globebrowsing.documentation = { { Name = "createGibsGdalXml", Arguments = { layerName = "String", date = "String", resolution = "String", format = "String" }, - Documentation = + Documentation = "Creates an XML configuration for a GIBS dataset." .. "Arguments are: layerName, date, resolution, format." .. "For all specifications, see " .. @@ -94,7 +94,7 @@ openspace.globebrowsing.addGibsLayer = function(layer, resolution, format, start end local layer = { - Identifier = layerName, + Identifier = layerName, Type = "TemporalTileLayer", Mode = "Prototyped", Prototyped = { @@ -207,7 +207,7 @@ openspace.globebrowsing.parseInfoFile = function (file) file_func() else openspace.printError('Error loading file "' .. file .. '": '.. error) - return nil, nil, nil, nil + return nil end -- Hoist the global variables into local space @@ -220,11 +220,11 @@ openspace.globebrowsing.parseInfoFile = function (file) -- Now we can start local name = Name or Identifier - local identifier = Identifier or Name + local identifier = Identifier - if name == nil and identifier == nil then - openspace.printError('Error loading file "' .. file .. '": No "Name" or "Identifier" found') - return nil, nil, nil, nil + if identifier == "" then + openspace.printError('Error loading file "' .. file .. '": No "Identifier" found') + return nil end local color = nil @@ -287,11 +287,12 @@ openspace.globebrowsing.addBlendingLayersFromDirectory = function (dir, node_nam for _, file in pairs(files) do if file and file:find('.info') and ends_with(file, '.info') then local t = openspace.globebrowsing.parseInfoFile(file) - if t.Color then + + if t and t.Color then openspace.printInfo("Adding color layer '" .. t.Color["Identifier"] .. "'") openspace.globebrowsing.addLayer(node_name, "ColorLayers", t.Color) end - if t.Height then + if t and t.Height then openspace.printInfo("Adding height layer '" .. t.Height["Identifier"] .. "'") openspace.globebrowsing.addLayer(node_name, "HeightLayers", t.Height) end @@ -306,7 +307,7 @@ openspace.globebrowsing.addFocusNodesFromDirectory = function (dir, node_name) if file and file:find('.info') then local t = openspace.globebrowsing.parseInfoFile(file) - if node_name and t.Location then + if node_name and t and t.Location then openspace.printInfo("Creating focus node for '" .. node_name .. "'") local lat = t.Location.Center[1]