1
0
Fork 0

Scenery data attribution - sources.xml

Read a sources.xml file in Scenery directories and copy into
the property tree under /scenery/sources

Expected format:

<?xml version="1.0"?>
<PropertyList>
    <source>
        <name>Corine Land Cover (CLC) 2018, Version 2020_20u1</name>
        <link>http://web.archive.org/web/20221112175615/https://land.copernicus.eu/pan-european/corine-land-cover/clc2018?tab=metadata%2A</link>
        <license>GMES Open License</license>
    </source>
    <source>
        <name>NASADEM Merged DEM Global 1 arc second V001</name>
        <link>https://www.earthdata.nasa.gov/</link>
        <license>Public Domain</license>
    </source>
    <source>
        <name>OpenStreetMap</name>
        <link>https://www.openstreetmap.org/copyright</link>
        <license>Open Data Commons Open Database License</license>
    </source>
</PropertyList>
This commit is contained in:
Stuart Buchanan 2022-11-12 20:45:01 +00:00
parent 9b4bd6fdcb
commit 535c5a5ff1

View file

@ -402,7 +402,7 @@ void FGGlobals::append_fg_scenery (const SGPath &path)
return; return;
} }
// tell the ResouceManager about the scenery path // tell the ResourceManager about the scenery path
// needed to load Models from this scenery path // needed to load Models from this scenery path
simgear::ResourceManager::instance()->addBasePath(abspath, simgear::ResourceManager::PRIORITY_DEFAULT); simgear::ResourceManager::instance()->addBasePath(abspath, simgear::ResourceManager::PRIORITY_DEFAULT);
@ -416,6 +416,35 @@ void FGGlobals::append_fg_scenery (const SGPath &path)
// temporary fix so these values survive reset // temporary fix so these values survive reset
n->setAttribute(SGPropertyNode::PRESERVE, true); n->setAttribute(SGPropertyNode::PRESERVE, true);
// Add any sources.xml file to the property tree so we can provide attribution through the GUI
SGPath sources = SGPath(abspath);
sources.append("sources.xml");
SG_LOG(SG_TERRAIN, SG_DEBUG, "Looking for source file " << sources << ". Exists ? " << sources.exists());
if (sources.exists()) {
// Determine the next free indice under /scenery/sources
SGPropertyNode* sourcesProp = fgGetNode("/scenery/sources", true);
int propIndex = 0;
while (sourcesProp->getChild("directory", propIndex) != NULL) {
++propIndex;
}
sourcesProp = sourcesProp->getChild("directory", propIndex++, true);
// Add a reference to the path itself
sourcesProp->setStringValue("path", abspath.utf8Str());
// Now load the sources file into /scenery/sources/source[n]
if(!fgLoadProps(sources.utf8Str(), sourcesProp, false))
{
SG_LOG(SG_TERRAIN, SG_ALERT, "Unable to load sources file " << sources.utf8Str());
}
// Ensure these properties cannot be over-ridden, and preserve them across a reset.
sourcesProp->setAttribute(SGPropertyNode::WRITE, false);
sourcesProp->setAttribute(SGPropertyNode::PRESERVE, true);
}
} }
void FGGlobals::append_read_allowed_paths(const SGPath &path) void FGGlobals::append_read_allowed_paths(const SGPath &path)