diff --git a/modules/globebrowsing/other/tiledataset.cpp b/modules/globebrowsing/other/tiledataset.cpp index 62ae1f5828..f4bfd24224 100644 --- a/modules/globebrowsing/other/tiledataset.cpp +++ b/modules/globebrowsing/other/tiledataset.cpp @@ -31,6 +31,8 @@ #include #include + + namespace { const std::string _loggerCat = "TileDataset"; } @@ -42,17 +44,16 @@ namespace openspace { // INIT THIS TO FALSE AFTER REMOVED FROM TILEPROVIDER bool TileDataset::GdalHasBeenInitialized = false; - TileDataset::TileDataset(const std::string& fileName, int minimumPixelSize, GLuint dataType) + TileDataset::TileDataset(const std::string& gdalDatasetDesc, int minimumPixelSize, GLuint dataType) : _minimumPixelSize(minimumPixelSize) { - if (!GdalHasBeenInitialized) { GDALAllRegister(); GdalHasBeenInitialized = true; } - _dataset = (GDALDataset *)GDALOpen(absPath(fileName).c_str(), GA_ReadOnly); - ghoul_assert(_dataset != nullptr, "Failed to load dataset: " << fileName); + _dataset = (GDALDataset *)GDALOpen(gdalDatasetDesc.c_str(), GA_ReadOnly); + ghoul_assert(_dataset != nullptr, "Failed to load dataset:\n" << gdalDatasetDesc); _dataLayout = DataLayout(_dataset, dataType); _depthTransform = calculateTileDepthTransform(); diff --git a/modules/globebrowsing/other/tiledataset.h b/modules/globebrowsing/other/tiledataset.h index ab1e842666..741c4e2694 100644 --- a/modules/globebrowsing/other/tiledataset.h +++ b/modules/globebrowsing/other/tiledataset.h @@ -34,6 +34,7 @@ #include "gdal_priv.h" + #include #include #include @@ -88,12 +89,22 @@ namespace openspace { class TileDataset { public: - - // Default dataType = 0 means GDAL will use the same data type as the data - // is originally in - TileDataset(const std::string& fileName, int minimumPixelSize, GLuint dataType = 0); + + + /** + * Opens a GDALDataset in readonly mode and calculates meta data required for + * reading tile using a ChunkIndex. + * + * \param gdalDatasetDesc - A path to a specific file or raw XML describing the dataset + * \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, GLuint dataType = 0); + ~TileDataset(); + + std::shared_ptr readTileData(ChunkIndex chunkIndex); @@ -105,6 +116,7 @@ namespace openspace { private: + ////////////////////////////////////////////////////////////////////////////////// // HELPER STRUCTS // //////////////////////////////////////////////////////////////////////////////////