mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-16 08:51:26 -06:00
TileDatasets are created with a const Configuration
This commit is contained in:
@@ -117,37 +117,6 @@ namespace openspace {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<TileProvider> TileProviderManager::initProvider(const std::string& file,
|
||||
const TileProviderInitData& initData)
|
||||
{
|
||||
std::shared_ptr<TileProvider> tileProvider;
|
||||
|
||||
try
|
||||
{ // First try reading normally
|
||||
auto tileDataset = std::make_shared<TileDataset>(file, initData.minimumPixelSize, initData.preprocessTiles);
|
||||
auto threadPool = std::make_shared<ThreadPool>(1);
|
||||
auto tileReader = std::make_shared<AsyncTileDataProvider>(tileDataset, threadPool);
|
||||
auto tileCache = std::make_shared<TileCache>(initData.cacheSize);
|
||||
tileProvider = std::make_shared<CachingTileProvider>(tileReader, tileCache, initData.framesUntilRequestQueueFlush);
|
||||
|
||||
return tileProvider;
|
||||
}
|
||||
catch (const ghoul::RuntimeError& e)
|
||||
{ // Then try to see if it is a temporal dataset.
|
||||
CPLXMLNode * node = CPLParseXMLFile(file.c_str());
|
||||
if (!node) {
|
||||
throw ghoul::RuntimeError("Unable to parse file:\n" + file);
|
||||
}
|
||||
if (std::string(node->pszValue) == "OpenSpaceTemporalGDALDataset") {
|
||||
tileProvider = std::make_shared<TemporalTileProvider>(file, initData);
|
||||
return tileProvider;
|
||||
}
|
||||
// If still not able to read, throw the error.
|
||||
throw ghoul::RuntimeError(e.message);
|
||||
}
|
||||
}
|
||||
|
||||
TileProviderManager::LayerCategory& TileProviderManager::getLayerCategory(LayeredTextures::TextureCategory category)
|
||||
{
|
||||
return _layerCategories[category];
|
||||
|
||||
@@ -73,9 +73,6 @@ namespace openspace {
|
||||
static void initTexures(std::vector<TileProviderWithName>& destination,
|
||||
const ghoul::Dictionary& dict, const TileProviderInitData& initData);
|
||||
|
||||
static std::shared_ptr<TileProvider> initProvider(const std::string& file,
|
||||
const TileProviderInitData& initData);
|
||||
|
||||
std::array<LayerCategory, LayeredTextures::NUM_TEXTURE_CATEGORIES> _layerCategories;
|
||||
};
|
||||
|
||||
|
||||
@@ -113,12 +113,11 @@ namespace openspace {
|
||||
|
||||
bool TileDataset::GdalHasBeenInitialized = false;
|
||||
|
||||
TileDataset::TileDataset(const std::string& gdalDatasetDesc, int minimumPixelSize,
|
||||
bool doPreprocessing, GLuint dataType)
|
||||
: _doPreprocessing(doPreprocessing)
|
||||
TileDataset::TileDataset(const std::string& gdalDatasetDesc, const Configuration& config)
|
||||
: _config(config)
|
||||
, hasBeenInitialized(false)
|
||||
{
|
||||
_initData = { gdalDatasetDesc, minimumPixelSize, dataType };
|
||||
_initData = { gdalDatasetDesc, config.minimumTilePixelSize, config.dataType };
|
||||
ensureInitialized();
|
||||
}
|
||||
|
||||
|
||||
@@ -81,6 +81,13 @@ namespace openspace {
|
||||
|
||||
class TileDataset {
|
||||
public:
|
||||
|
||||
struct Configuration {
|
||||
bool doPreProcessing;
|
||||
int minimumTilePixelSize;
|
||||
GLuint dataType = 0; // default = no datatype reinterpretation
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Opens a GDALDataset in readonly mode and calculates meta data required for
|
||||
@@ -90,8 +97,7 @@ namespace openspace {
|
||||
* \param minimumPixelSize - minimum number of pixels per side per tile requested
|
||||
* \param datatype - datatype for storing pixel data in requested tile
|
||||
*/
|
||||
TileDataset(const std::string& gdalDatasetDesc, int minimumPixelSize,
|
||||
bool doPreprocessing, GLuint dataType = 0);
|
||||
TileDataset(const std::string& gdalDatasetDesc, const Configuration& config);
|
||||
|
||||
~TileDataset();
|
||||
|
||||
@@ -110,6 +116,7 @@ namespace openspace {
|
||||
const static PixelRegion padding; // same as the two above
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -167,6 +174,9 @@ namespace openspace {
|
||||
double _tileLevelDifference;
|
||||
} _cached;
|
||||
|
||||
const Configuration _config;
|
||||
|
||||
|
||||
GDALDataset* _dataset;
|
||||
TileDepthTransform _depthTransform;
|
||||
TileDataLayout _dataLayout;
|
||||
|
||||
@@ -67,7 +67,11 @@ namespace openspace {
|
||||
|
||||
void TileProviderFactory::initialize() {
|
||||
_factoryMap.insert({"LRUCaching", [](const std::string& desc, const TileProviderInitData& initData) {
|
||||
auto tileDataset = std::make_shared<TileDataset>(desc, initData.minimumPixelSize, initData.preprocessTiles);
|
||||
TileDataset::Configuration config;
|
||||
config.doPreProcessing = initData.preprocessTiles;
|
||||
config.minimumTilePixelSize = initData.minimumPixelSize;
|
||||
|
||||
auto tileDataset = std::make_shared<TileDataset>(desc, config);
|
||||
auto threadPool = std::make_shared<ThreadPool>(1);
|
||||
auto tileReader = std::make_shared<AsyncTileDataProvider>(tileDataset, threadPool);
|
||||
auto tileCache = std::make_shared<TileCache>(initData.cacheSize);
|
||||
|
||||
Reference in New Issue
Block a user