diff --git a/data/scene/lodearth/lodearth.mod b/data/scene/lodearth/lodearth.mod index 9e2fe6fa64..af0aae94f4 100644 --- a/data/scene/lodearth/lodearth.mod +++ b/data/scene/lodearth/lodearth.mod @@ -1,7 +1,7 @@ return { -- Earth barycenter module { - Name = "EarthBarycenter", + Name = "EarthCenterOfMass", Parent = "SolarSystemBarycenter", Transform = { Translation = { @@ -34,7 +34,7 @@ return { -- RenderableGlobe module { Name = "LodEarth", - Parent = "EarthBarycenter", + Parent = "EarthCenterOfMass", Transform = { Rotation = { Type = "SpiceRotation", @@ -118,6 +118,8 @@ return { Name = "Terrain tileset", FilePath = "map_service_configs/TERRAIN.wms", Enabled = true, + MinimumPixelSize = 90, + DoPreProcessing = true, }, }, HeightMapOverlays = { diff --git a/data/scene/lodmars/lodmars.mod b/data/scene/lodmars/lodmars.mod index b378e8859b..b95ebdf89d 100644 --- a/data/scene/lodmars/lodmars.mod +++ b/data/scene/lodmars/lodmars.mod @@ -1,13 +1,9 @@ +local marsEllipsoid = {3396190.0, 3396190.0, 3376200.0} return { -- Mars barycenter module { - Name = "MarsBarycenter", + Name = "MarsCenterOfMass", Parent = "SolarSystemBarycenter", - }, - -- RenderableGlobe module - { - Name = "LodMars", - Parent = "MarsBarycenter", Transform = { Translation = { Type = "SpiceEphemeris", @@ -18,6 +14,13 @@ return { "${OPENSPACE_DATA}/spice/de430_1850-2150.bsp" } }, + }, + }, + -- RenderableGlobe module + { + Name = "LodMars", + Parent = "MarsCenterOfMass", + Transform = { Rotation = { Type = "SpiceRotation", SourceFrame = "IAU_MARS", @@ -30,9 +33,7 @@ return { }, Renderable = { Type = "RenderableGlobe", - Frame = "IAU_MARS", - Body = "MARS BARYCENTER", - Radii = {3396190.0, 3396190.0, 3376200.0}, -- Mars' radii + Radii = marsEllipsoid, -- Mars' radii CameraMinHeight = 1000, InteractionDepthBelowEllipsoid = 10000, -- Useful when having negative height map values SegmentsPerPatch = 90, @@ -51,7 +52,6 @@ return { { Name = "MARS_Viking_MDIM21", FilePath = "map_service_configs/MARS_Viking_MDIM21.xml", - Enabled = true, }, { Name = "Mars Viking Clr", @@ -92,15 +92,21 @@ return { Name = "Mola Elevation", FilePath = "map_service_configs/Mola_Elevation.xml", Enabled = true, + MinimumPixelSize = 90, + DoPreProcessing = true, }, { Name = "West_Candor_Chasma_DEM_longlat_global", FilePath = "map_datasets/West_Candor_Chasma_DEM_longlat_global.vrt", --Enabled = true, + MinimumPixelSize = 90, + DoPreProcessing = true, }, { Name = "Layered Rock Outcrops in Southwest Candor Chasma", FilePath = "map_datasets/Layered_Rock_Outcrops_in_Southwest_Candor_Chasma_DEM.vrt", + MinimumPixelSize = 90, + DoPreProcessing = true, }, }, HeightMapOverlays = { @@ -113,7 +119,7 @@ return { -- MarsTrail module { Name = "MarsTrail", - Parent = "MarsBarycenter", + Parent = "Sun", Renderable = { Type = "RenderableTrail", Body = "MARS BARYCENTER", diff --git a/modules/globebrowsing/CMakeLists.txt b/modules/globebrowsing/CMakeLists.txt index cf589d9810..f6720542c5 100644 --- a/modules/globebrowsing/CMakeLists.txt +++ b/modules/globebrowsing/CMakeLists.txt @@ -62,7 +62,6 @@ set(HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileioresult.h ${CMAKE_CURRENT_SOURCE_DIR}/tile/asynctilereader.h ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovidermanager.h - ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileproviderfactory.h ${CMAKE_CURRENT_SOURCE_DIR}/tile/layeredtextureshaderprovider.h ${CMAKE_CURRENT_SOURCE_DIR}/tile/layeredtextures.h ${CMAKE_CURRENT_SOURCE_DIR}/tile/pixelregion.h @@ -114,7 +113,6 @@ set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileioresult.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tile/asynctilereader.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovidermanager.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/tile/tileproviderfactory.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tile/layeredtextureshaderprovider.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tile/layeredtextures.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tile/pixelregion.cpp diff --git a/modules/globebrowsing/globebrowsingmodule.cpp b/modules/globebrowsing/globebrowsingmodule.cpp index c4bdc00a2b..4b3753c7ff 100644 --- a/modules/globebrowsing/globebrowsingmodule.cpp +++ b/modules/globebrowsing/globebrowsingmodule.cpp @@ -30,8 +30,15 @@ #include #include +#include #include +#include +#include +#include +#include +#include + namespace openspace { @@ -40,28 +47,23 @@ namespace openspace { {} void GlobeBrowsingModule::internalInitialize() { - /* - auto fRenderable = FactoryManager::ref().factory(); - ghoul_assert(fRenderable, "Renderable factory was not created"); - - fRenderable->registerClass("Planet"); - fRenderable->registerClass("RenderableTestPlanet"); - //fRenderable->registerClass("PlanetTestGeometry"); - - auto fPlanetGeometry = FactoryManager::ref().factory(); - ghoul_assert(fPlanetGeometry, "Planet test geometry factory was not created"); - fPlanetGeometry->registerClass("SimpleSphereTest"); - - */ - - - - auto fRenderable = FactoryManager::ref().factory(); ghoul_assert(fRenderable, "Renderable factory was not created"); - fRenderable->registerClass("RenderableGlobe"); + + void addFactory(std::unique_ptr factory); + + // add Tile Provider factory + FactoryManager::ref().addFactory( + std::make_unique>()); + + auto fTileProvider = FactoryManager::ref().factory(); + fTileProvider->registerClass("LRUCaching"); + fTileProvider->registerClass("SingleImage"); + fTileProvider->registerClass("Temporal"); + fTileProvider->registerClass("ChunkIndex"); + } } // namespace openspace diff --git a/modules/globebrowsing/tile/tileprovider/cachingtileprovider.cpp b/modules/globebrowsing/tile/tileprovider/cachingtileprovider.cpp index defef66ff3..4e4bd7defb 100644 --- a/modules/globebrowsing/tile/tileprovider/cachingtileprovider.cpp +++ b/modules/globebrowsing/tile/tileprovider/cachingtileprovider.cpp @@ -38,12 +38,69 @@ namespace { - const std::string _loggerCat = "TileProvider"; + const std::string _loggerCat = "CachingTileProvider"; + + const std::string KeyDoPreProcessing = "DoPreProcessing"; + const std::string KeyMinimumPixelSize = "MinimumPixelSize"; + const std::string KeyFilePath = "FilePath"; + const std::string KeyCacheSize = "CacheSize"; + const std::string KeyFlushInterval = "FlushInterval"; } namespace openspace { + CachingTileProvider::CachingTileProvider(const ghoul::Dictionary& dictionary) + : _framesSinceLastRequestFlush(0) + { + // + std::string name = "Name unspecified"; + dictionary.getValue("Name", name); + std::string _loggerCat = "CachingTileProvider : " + name; + + + // 1. Get required Keys + std::string filePath; + if (!dictionary.getValue(KeyFilePath, filePath)) { + throw std::runtime_error("Must define key '" + KeyFilePath + "'"); + } + + // 2. Initialize default values for any optional Keys + TileDataset::Configuration config; + config.doPreProcessing = false; + config.minimumTilePixelSize = 512; + + // getValue does not work for integers + double minimumPixelSize; + double cacheSize = 512; + double framesUntilRequestFlush = 60; + + // 3. Check for used spcified optional keys + if (dictionary.getValue(KeyDoPreProcessing, config.doPreProcessing)) { + LDEBUG("Default doPreProcessing overridden: " << config.doPreProcessing); + } + if (dictionary.getValue(KeyMinimumPixelSize, minimumPixelSize)) { + LDEBUG("Default minimumPixelSize overridden: " << minimumPixelSize); + config.minimumTilePixelSize = static_cast(minimumPixelSize); + } + if (dictionary.getValue(KeyCacheSize, cacheSize)) { + LDEBUG("Default cacheSize overridden: " << cacheSize); + } + if (dictionary.getValue(KeyFlushInterval, framesUntilRequestFlush)) { + LDEBUG("Default framesUntilRequestFlush overridden: " << framesUntilRequestFlush); + } + + + // Initialize instance variables + auto tileDataset = std::make_shared(filePath, config); + + // only one thread per provider supported atm + auto threadPool = std::make_shared(1); + + _asyncTextureDataProvider = std::make_shared(tileDataset, threadPool); + _tileCache = std::make_shared(cacheSize); + _framesUntilRequestFlush = framesUntilRequestFlush; + } CachingTileProvider::CachingTileProvider(std::shared_ptr tileReader, std::shared_ptr tileCache, diff --git a/modules/globebrowsing/tile/tileprovider/cachingtileprovider.h b/modules/globebrowsing/tile/tileprovider/cachingtileprovider.h index f06c7e774b..5f569793e7 100644 --- a/modules/globebrowsing/tile/tileprovider/cachingtileprovider.h +++ b/modules/globebrowsing/tile/tileprovider/cachingtileprovider.h @@ -25,7 +25,6 @@ #ifndef __CACHING_TILE_PROVIDER_H__ #define __CACHING_TILE_PROVIDER_H__ -#include #include #include // absPath @@ -51,6 +50,7 @@ namespace openspace { class CachingTileProvider : public TileProvider { public: + CachingTileProvider(const ghoul::Dictionary& dictionary); CachingTileProvider( std::shared_ptr tileReader, @@ -101,7 +101,6 @@ namespace openspace { int _framesSinceLastRequestFlush; int _framesUntilRequestFlush; - std::shared_ptr _asyncTextureDataProvider; }; diff --git a/modules/globebrowsing/tile/tileprovider/singleimageprovider.cpp b/modules/globebrowsing/tile/tileprovider/singleimageprovider.cpp index f7d38c0561..b7e8b010f0 100644 --- a/modules/globebrowsing/tile/tileprovider/singleimageprovider.cpp +++ b/modules/globebrowsing/tile/tileprovider/singleimageprovider.cpp @@ -38,11 +38,21 @@ namespace { const std::string _loggerCat = "SingleImageProvider"; + + const std::string KeyFilePath = "FilePath"; } namespace openspace { + SingleImageProvider::SingleImageProvider(const ghoul::Dictionary& dictionary) { + // Required input + if (!dictionary.getValue(KeyFilePath, _imagePath)) { + throw std::runtime_error("Must define key '" + KeyFilePath + "'"); + } + + reset(); + } SingleImageProvider::SingleImageProvider(const std::string& imagePath) diff --git a/modules/globebrowsing/tile/tileprovider/singleimageprovider.h b/modules/globebrowsing/tile/tileprovider/singleimageprovider.h index 7b55f9c0f9..dd8143e7b9 100644 --- a/modules/globebrowsing/tile/tileprovider/singleimageprovider.h +++ b/modules/globebrowsing/tile/tileprovider/singleimageprovider.h @@ -51,6 +51,8 @@ namespace openspace { class SingleImageProvider : public TileProvider { public: + + SingleImageProvider(const ghoul::Dictionary& dictionary); SingleImageProvider(const std::string& imagePath); virtual ~SingleImageProvider() { } diff --git a/modules/globebrowsing/tile/tileprovider/temporaltileprovider.cpp b/modules/globebrowsing/tile/tileprovider/temporaltileprovider.cpp index 4adaef4a26..567d22572f 100644 --- a/modules/globebrowsing/tile/tileprovider/temporaltileprovider.cpp +++ b/modules/globebrowsing/tile/tileprovider/temporaltileprovider.cpp @@ -25,7 +25,8 @@ #include #include -#include +#include + #include @@ -46,6 +47,12 @@ namespace { const std::string _loggerCat = "TemporalTileProvider"; + + const std::string KeyDoPreProcessing = "DoPreProcessing"; + const std::string KeyMinimumPixelSize = "MinimumPixelSize"; + const std::string KeyFilePath = "FilePath"; + const std::string KeyCacheSize = "CacheSize"; + const std::string KeyFlushInterval = "FlushInterval"; } @@ -53,16 +60,21 @@ namespace openspace { const std::string TemporalTileProvider::TIME_PLACEHOLDER("${OpenSpaceTimeId}"); - TemporalTileProvider::TemporalTileProvider(const std::string& datasetFile, - const TileProviderInitData& tileProviderInitData) - : _datasetFile(datasetFile) - , _tileProviderInitData(tileProviderInitData) + + TemporalTileProvider::TemporalTileProvider(const ghoul::Dictionary& dictionary) + : _initDict(dictionary) { - std::ifstream in(datasetFile.c_str()); - ghoul_assert(errno == 0, strerror(errno) << std::endl << datasetFile); + + if (!dictionary.getValue(KeyFilePath, _datasetFile)) { + throw std::runtime_error("Must define key '" + KeyFilePath + "'"); + } + + + std::ifstream in(_datasetFile.c_str()); + ghoul_assert(errno == 0, strerror(errno) << std::endl << _datasetFile); // read file - std::string xml( (std::istreambuf_iterator(in)), (std::istreambuf_iterator())); + std::string xml((std::istreambuf_iterator(in)), (std::istreambuf_iterator())); _gdalXmlTemplate = consumeTemporalMetaData(xml); _defaultTile = getTileProvider()->getDefaultTile(); } @@ -185,7 +197,8 @@ namespace openspace { std::shared_ptr TemporalTileProvider::initTileProvider(TimeKey timekey) { std::string gdalDatasetXml = getGdalDatasetXML(timekey); - return TileProviderFactory::ref()->create("LRUCaching", gdalDatasetXml, _tileProviderInitData); + _initDict.setValue(KeyFilePath, gdalDatasetXml); + return std::make_shared(_initDict); } std::string TemporalTileProvider::getGdalDatasetXML(Time t) { diff --git a/modules/globebrowsing/tile/tileprovider/temporaltileprovider.h b/modules/globebrowsing/tile/tileprovider/temporaltileprovider.h index 211becda87..d53ec668f9 100644 --- a/modules/globebrowsing/tile/tileprovider/temporaltileprovider.h +++ b/modules/globebrowsing/tile/tileprovider/temporaltileprovider.h @@ -27,6 +27,7 @@ #include +#include #include #include @@ -102,8 +103,7 @@ namespace openspace { class TemporalTileProvider : public TileProvider { public: - TemporalTileProvider(const std::string& datasetFile, const TileProviderInitData& tileProviderInitData); - + TemporalTileProvider(const ghoul::Dictionary& dictionary); // These methods implements TileProvider @@ -143,16 +143,20 @@ namespace openspace { // Members variables // ////////////////////////////////////////////////////////////////////////////////// - const std::string _datasetFile; + std::string _datasetFile; std::string _gdalXmlTemplate; std::unordered_map > _tileProviderMap; - TileProviderInitData _tileProviderInitData; + + // Used for creation of time specific instances of CachingTileProvider + ghoul::Dictionary _initDict; + Tile _defaultTile; std::shared_ptr _currentTileProvider; + TimeFormat * _timeFormat; TimeQuantizer _timeQuantizer; }; diff --git a/modules/globebrowsing/tile/tileprovider/texttileprovider.h b/modules/globebrowsing/tile/tileprovider/texttileprovider.h index ff7326ada8..363d5c0ea7 100644 --- a/modules/globebrowsing/tile/tileprovider/texttileprovider.h +++ b/modules/globebrowsing/tile/tileprovider/texttileprovider.h @@ -56,6 +56,7 @@ namespace openspace { */ class TextTileProvider : public TileProvider { public: + TextTileProvider(const glm::uvec2& textureSize = {512, 512}, size_t fontSize = 48); virtual ~TextTileProvider(); diff --git a/modules/globebrowsing/tile/tileprovider/tileprovider.cpp b/modules/globebrowsing/tile/tileprovider/tileprovider.cpp index 5e73089d24..a35e553b54 100644 --- a/modules/globebrowsing/tile/tileprovider/tileprovider.cpp +++ b/modules/globebrowsing/tile/tileprovider/tileprovider.cpp @@ -24,6 +24,8 @@ #include +#include + #include @@ -31,9 +33,33 @@ namespace { const std::string _loggerCat = "TileProvider"; + + const std::string KeyType = "Type"; } namespace openspace { +TileProvider* TileProvider::createFromDictionary(const ghoul::Dictionary& dictionary) { + if (!dictionary.hasValue(KeyType)) { + LERROR("TileProvider did not have key '" << KeyType << "'"); + return nullptr; + } + + std::string type; + dictionary.getValue(KeyType, type); + ghoul::TemplateFactory* factory + = FactoryManager::ref().factory(); + TileProvider* result = factory->create(type, dictionary); + + if (result == nullptr) { + LERROR("Failed creating Ephemeris object of type '" << type << "'"); + return nullptr; + } + + return result; +} + +TileProvider::TileProvider(const ghoul::Dictionary& dictionary) { }; + } // namespace openspace diff --git a/modules/globebrowsing/tile/tileprovider/tileprovider.h b/modules/globebrowsing/tile/tileprovider/tileprovider.h index 82f3ca4849..731bd25a20 100644 --- a/modules/globebrowsing/tile/tileprovider/tileprovider.h +++ b/modules/globebrowsing/tile/tileprovider/tileprovider.h @@ -27,6 +27,7 @@ #include // absPath #include +#include #include @@ -41,15 +42,15 @@ namespace openspace { - using namespace ghoul::opengl; - - - - class TileProvider { public: + static TileProvider* createFromDictionary(const ghoul::Dictionary& dictionary); + + TileProvider() {}; + TileProvider(const ghoul::Dictionary& dictionary); + virtual ~TileProvider() { } virtual Tile getTile(const ChunkIndex& chunkIndex) = 0; diff --git a/modules/globebrowsing/tile/tileproviderfactory.cpp b/modules/globebrowsing/tile/tileproviderfactory.cpp deleted file mode 100644 index c50a4d0e9e..0000000000 --- a/modules/globebrowsing/tile/tileproviderfactory.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014-2016 * -* * -* Permission is hereby granted, free of charge, to any person obtaining a copy of this * -* software and associated documentation files (the "Software"), to deal in the Software * -* without restriction, including without limitation the rights to use, copy, modify, * -* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * -* permit persons to whom the Software is furnished to do so, subject to the following * -* conditions: * -* * -* The above copyright notice and this permission notice shall be included in all copies * -* or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * -* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * -* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * -* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * -* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * -* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * -****************************************************************************************/ - -#include -#include - -#include -#include -#include -#include - -#include - -#include "cpl_minixml.h" - - -namespace { - const std::string _loggerCat = "TileProviderFactory"; -} - - -namespace openspace { - - std::shared_ptr TileProviderFactory::_ref = nullptr; - - - TileProviderFactory::TileProviderFactory() { - initialize(); - } - - - std::shared_ptr TileProviderFactory::ref() { - if (_ref == nullptr) { - // Need to explicitly use new here, since constructor is private - TileProviderFactory* ptr = new TileProviderFactory(); - _ref = std::shared_ptr(ptr); - } - return _ref; - } - - std::shared_ptr TileProviderFactory::create(const std::string& type, - const std::string& desc, const TileProviderInitData& initData) - { - auto concreteFactoryIterator = _factoryMap.find(type); - - if (concreteFactoryIterator == _factoryMap.end()) { - LERROR("Unknown type: " << type); - return nullptr; - } - - std::shared_ptr tileProvider; - - try { - tileProvider = concreteFactoryIterator->second(desc, initData); - } - catch (const std::exception& e) { - LERROR(e.what()); - } - catch (...) { - LERROR("Could not open dataset:\n" << desc << "\n"); - } - return tileProvider; - } - - void TileProviderFactory::initialize() { - _factoryMap.insert({"LRUCaching", [](const std::string& desc, const TileProviderInitData& initData) { - TileDataset::Configuration config; - config.doPreProcessing = initData.preprocessTiles; - config.minimumTilePixelSize = initData.minimumPixelSize; - - auto tileDataset = std::make_shared(desc, config); - auto threadPool = std::make_shared(1); - auto tileReader = std::make_shared(tileDataset, threadPool); - auto tileCache = std::make_shared(initData.cacheSize); - auto tileProvider = std::make_shared(tileReader, tileCache, initData.framesUntilRequestQueueFlush); - return tileProvider; - }}); - - _factoryMap.insert({ "Temporal", [](const std::string& file, const TileProviderInitData& initData) { - CPLXMLNode * node = CPLParseXMLFile(file.c_str()); - if (!node) { - throw ghoul::RuntimeError("Unable to parse file:\n" + file); - } - if (std::string(node->pszValue) == "OpenSpaceTemporalGDALDataset") { - auto tileProvider = std::make_shared(file, initData); - return tileProvider; - } - }}); - - _factoryMap.insert({ "SingleImage", [](const std::string& file, const TileProviderInitData& initData) { - auto tileProvider = std::make_shared(file); - return tileProvider; - } }); - - _factoryMap.insert({ "ChunkIndex", [](const std::string& file, const TileProviderInitData& initData) { - auto tileProvider = std::make_shared(); - return tileProvider; - } }); - } - - -} // namespace openspace diff --git a/modules/globebrowsing/tile/tileproviderfactory.h b/modules/globebrowsing/tile/tileproviderfactory.h deleted file mode 100644 index d963d42f93..0000000000 --- a/modules/globebrowsing/tile/tileproviderfactory.h +++ /dev/null @@ -1,61 +0,0 @@ -/***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014-2016 * -* * -* Permission is hereby granted, free of charge, to any person obtaining a copy of this * -* software and associated documentation files (the "Software"), to deal in the Software * -* without restriction, including without limitation the rights to use, copy, modify, * -* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * -* permit persons to whom the Software is furnished to do so, subject to the following * -* conditions: * -* * -* The above copyright notice and this permission notice shall be included in all copies * -* or substantial portions of the Software. * -* * -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * -* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * -* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * -* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * -* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * -* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * -****************************************************************************************/ - -#ifndef __TILE_PROVIDER_FACTORY_H__ -#define __TILE_PROVIDER_FACTORY_H__ - - -#include - -#include - -#include -#include -#include - - -namespace openspace { - - class TileProviderFactory { - public: - - static std::shared_ptr ref(); - - std::shared_ptr create(const std::string& type, const std::string& desc, const TileProviderInitData& initData); - - private: - - TileProviderFactory(); - void initialize(); - - typedef std::function(const std::string&, const TileProviderInitData&)> ConcreteFactory; - - std::unordered_map _factoryMap; - - static std::shared_ptr _ref; - }; - - -} // namespace openspace -#endif // __TILE_PROVIDER_FACTORY_H__ \ No newline at end of file diff --git a/modules/globebrowsing/tile/tileprovidermanager.cpp b/modules/globebrowsing/tile/tileprovidermanager.cpp index 5036891244..43dba6486e 100644 --- a/modules/globebrowsing/tile/tileprovidermanager.cpp +++ b/modules/globebrowsing/tile/tileprovidermanager.cpp @@ -22,8 +22,9 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ +#include + #include -#include #include @@ -133,16 +134,18 @@ namespace openspace { std::string type = "LRUCaching"; // if type is unspecified texDict.getValue("Type", type); - - std::shared_ptr tileProvider = TileProviderFactory::ref()->create(type, path, initData); + + auto tileProviderFactory = FactoryManager::ref().factory(); + TileProvider* tileProvider = tileProviderFactory->create(type, texDict); if (tileProvider == nullptr) { + LERROR("Unable to create TileProvider '" << name << "' of type '" << type << "'"); continue; } bool enabled = false; // defaults to false if unspecified texDict.getValue("Enabled", enabled); - dest.push_back({ name, tileProvider, enabled }); + dest.push_back({ name, std::shared_ptr(tileProvider), enabled }); } }