Clean up the layer support; Add additional configuration option to the globebrowsing customization file

This commit is contained in:
Alexander Bock
2021-05-26 18:57:06 +02:00
parent a1be8d16cf
commit 184ce70cf5
2 changed files with 32 additions and 29 deletions
+26 -24
View File
@@ -63,13 +63,12 @@ openspace.globebrowsing.documentation = {
Name = "parseInfoFile",
Arguments = "string",
Documentation =
"Parses the passed info file and returns two tables. The first return value " ..
"contains the table for the color layer of a RenderableGlobe. The second " ..
"return value contains the table for the height layer of a RenderableGlobe." ..
"Usage: local color, height = openspace.globebrowsing.parseInfoFile(file)" ..
"openspace.globebrowsing.addLayer(\"Earth\", \"ColorLayers\", color)" ..
"openspace.globebrowsing.addLayer(\"Earth\", \"HeightLayers\", height)"
"Parses the passed info file and return the table with the information " ..
"provided in the info file. The return table contains the optional keys: " ..
"'Color', 'Height', 'Node', 'Location', 'Identifier'." ..
"Usage: local t = openspace.globebrowsing.parseInfoFile(file)" ..
"openspace.globebrowsing.addLayer(\"Earth\", \"ColorLayers\", t.color)" ..
"openspace.globebrowsing.addLayer(\"Earth\", \"HeightLayers\", t.height)"
},
{
Name = "addBlendingLayersFromDirectory",
@@ -264,7 +263,13 @@ openspace.globebrowsing.parseInfoFile = function (file)
location = Location
end
return name, color, height, location, identifier
return {
Color = color,
Height = height,
Name = name,
Location = location,
Identifier = identifier
}
end
openspace.globebrowsing.addBlendingLayersFromDirectory = function (dir, node_name)
@@ -290,16 +295,14 @@ 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 c, h
_, c, h, _ = openspace.globebrowsing.parseInfoFile(file)
if c then
openspace.printInfo("Adding color layer '" .. c["Identifier"] .. "'")
openspace.globebrowsing.addLayer(node_name, "ColorLayers", c)
local t = openspace.globebrowsing.parseInfoFile(file)
if t.Color then
openspace.printInfo("Adding color layer '" .. t.Color["Identifier"] .. "'")
openspace.globebrowsing.addLayer(node_name, "ColorLayers", t.Color)
end
if h then
openspace.printInfo("Adding height layer '" .. h["Identifier"] .. "'")
openspace.globebrowsing.addLayer(node_name, "HeightLayers", h)
if t.Height then
openspace.printInfo("Adding height layer '" .. t.Height["Identifier"] .. "'")
openspace.globebrowsing.addLayer(node_name, "HeightLayers", t.Height)
end
end
end
@@ -310,19 +313,18 @@ openspace.globebrowsing.addFocusNodesFromDirectory = function (dir, node_name)
for _, file in pairs(files) do
if file and file:find('.info') then
local n, l
n, _, _, l, i = openspace.globebrowsing.parseInfoFile(file)
local t = openspace.globebrowsing.parseInfoFile(file)
if n and l then
if t.Node and t.Location then
openspace.printInfo("Creating focus node for '" .. n .. "'")
local lat = l.Center[2]
local long = l.Center[1]
local lat = t.Location.Center[2]
local long = t.Location.Center[1]
local a, b, c = openspace.globebrowsing.getGeoPosition(node_name, lat, long, 0.0)
local p = { a, b, c }
local identifier = node_name .. " - " .. i
local name = node_name .. " - " .. n
local identifier = node_name .. " - " .. t.Identifier
local name = node_name .. " - " .. t.Node
openspace.addSceneGraphNode({
Identifier = identifier,