Remove superfluous absPath calls in Globe browsing (closes 384)

This commit is contained in:
Alexander Bock
2017-12-30 00:03:06 +01:00
parent 2d2bd4518f
commit 28e9383461
7 changed files with 29 additions and 41 deletions
@@ -63,16 +63,16 @@ std::ostream& operator<<(std::ostream& os, const PixelRegion& pr) {
}
GdalRawTileDataReader::GdalRawTileDataReader(const std::string& filePath,
const TileTextureInitData& initData,
const std::string& baseDirectory,
RawTileDataReader::PerformPreprocessing preprocess)
const TileTextureInitData& initData,
RawTileDataReader::PerformPreprocessing preprocess)
: RawTileDataReader(initData, preprocess)
, _dataset(nullptr)
{
_initDirectory = baseDirectory.empty() ? CPLGetCurrentDir() : baseDirectory;
// _initDirectory = baseDirectory.empty() ? CPLGetCurrentDir() : baseDirectory;
_datasetFilePath = filePath;
{ // Aquire lock
{
// Aquire lock
std::lock_guard<std::mutex> lockGuard(_datasetLock);
initialize();
}
@@ -224,14 +224,15 @@ RawTile::ReadError GdalRawTileDataReader::rasterRead(
GDALDataset* GdalRawTileDataReader::openGdalDataset(const std::string& filePath) {
GDALDataset* dataset = static_cast<GDALDataset*>(
GDALOpen(filePath.c_str(), GA_ReadOnly));
GDALOpen(filePath.c_str(), GA_ReadOnly)
);
if (!dataset) {
using namespace ghoul::filesystem;
std::string correctedPath = FileSystem::ref().pathByAppendingComponent(
_initDirectory, filePath
);
// std::string correctedPath = FileSystem::ref().pathByAppendingComponent(
// _initDirectory, filePath
// );
dataset = static_cast<GDALDataset*>(GDALOpen(correctedPath.c_str(), GA_ReadOnly));
dataset = static_cast<GDALDataset*>(GDALOpen(filePath.c_str(), GA_ReadOnly));
if (!dataset) {
throw ghoul::RuntimeError("Failed to load dataset:\n" + filePath);
}
@@ -63,10 +63,9 @@ public:
* \param baseDirectory, the base directory to use in future loading operations
*/
GdalRawTileDataReader(const std::string& filePath,
const TileTextureInitData& initData,
const std::string& baseDirectory = "",
RawTileDataReader::PerformPreprocessing preprocess =
RawTileDataReader::PerformPreprocessing::No);
const TileTextureInitData& initData,
RawTileDataReader::PerformPreprocessing preprocess =
RawTileDataReader::PerformPreprocessing::No);
virtual ~GdalRawTileDataReader() override;
@@ -107,8 +106,6 @@ private:
*/
int calculateTileLevelDifference(int minimumPixelSize) const;
// Member variables
std::string _initDirectory;
std::string _datasetFilePath;
GDALDataset* _dataset;
@@ -82,10 +82,7 @@ DefaultTileProvider::DefaultTileProvider(const ghoul::Dictionary& dictionary)
std::string _loggerCat = "DefaultTileProvider : " + _name;
// 1. Get required Keys
std::string filePath;
dictionary.getValue<std::string>(KeyFilePath, filePath);
//filePath = absPath(filePath);
_filePath.setValue(filePath);
_filePath = dictionary.value<std::string>(KeyFilePath);
if (!dictionary.getValue<layergroupid::GroupID>("LayerGroupID", _layerGroupID)) {
ghoul_assert(false, "Unknown layer group id");
@@ -117,8 +114,6 @@ DefaultTileProvider::DefaultTileProvider(const ghoul::Dictionary& dictionary)
_preCacheLevel = static_cast<int>(dictionary.value<double>(KeyPreCacheLevel));
}
dictionary.getValue(KeyBasePath, _basePath);
initAsyncTileDataReader(initData);
// Properties
@@ -230,7 +225,6 @@ void DefaultTileProvider::initAsyncTileDataReader(TileTextureInitData initData)
auto tileDataset = std::make_shared<GdalRawTileDataReader>(
_filePath,
initData,
_basePath,
preprocess
);
#else // GLOBEBROWSING_USE_GDAL
@@ -83,7 +83,6 @@ private:
properties::StringProperty _filePath;
properties::IntProperty _tilePixelSize;
layergroupid::GroupID _layerGroupID;
std::string _basePath;
int _preCacheLevel;
bool _performPreProcessing;
bool _padTiles;
@@ -29,7 +29,7 @@
#include <ghoul/opengl/texture.h>
namespace {
const char* KeyFilePath = "FilePath";
constexpr const char* KeyFilePath = "FilePath";
static const openspace::properties::Property::PropertyInfo FilePathInfo = {
"FilePath",
@@ -45,11 +45,7 @@ SingleImageProvider::SingleImageProvider(const ghoul::Dictionary& dictionary)
: _tile(nullptr, nullptr, Tile::Status::Unavailable)
, _filePath(FilePathInfo)
{
// Required input
std::string filePath;
dictionary.getValue<std::string>(KeyFilePath, filePath);
_filePath.setValue(filePath);
_filePath = dictionary.value<std::string>(KeyFilePath);
addProperty(_filePath);
reset();
@@ -66,16 +66,17 @@ TemporalTileProvider::TemporalTileProvider(const ghoul::Dictionary& dictionary)
, _filePath(FilePathInfo)
, _successfulInitialization(false)
{
std::string filePath;
dictionary.getValue<std::string>(KeyFilePath, filePath);
try {
filePath = absPath(filePath);
}
catch (const std::runtime_error&) {
// File path was not a path to a file but a GDAL config or empty
}
_filePath = dictionary.value<std::string>(KeyFilePath);
// std::string filePath;
// dictionary.getValue<std::string>(KeyFilePath, filePath);
// try {
// filePath = absPath(filePath);
// }
// catch (const std::runtime_error&) {
// // File path was not a path to a file but a GDAL config or empty
// }
_filePath.setValue(filePath);
// _filePath.setValue(filePath);
addProperty(_filePath);
if (readFilePath()) {
@@ -39,8 +39,8 @@ namespace openspace::globebrowsing::tileprovider {
unsigned int TileProvider::_numTileProviders = 0;
std::unique_ptr<TileProvider> TileProvider::createFromDictionary(
layergroupid::TypeID layerTypeID,
const ghoul::Dictionary& dictionary)
layergroupid::TypeID layerTypeID,
const ghoul::Dictionary& dictionary)
{
std::string type = layergroupid::LAYER_TYPE_NAMES[static_cast<int>(layerTypeID)];
auto factory = FactoryManager::ref().factory<TileProvider>();