mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-11 05:59:57 -06:00
Add global timeout of 3 seconds to GDAL request
Remove duplicate opening of GDAL datasets on failure (closes #478)
This commit is contained in:
@@ -133,6 +133,9 @@ void GdalRawTileDataReader::initialize() {
|
||||
throw ghoul::RuntimeError("File path must not be empty");
|
||||
}
|
||||
_dataset = openGdalDataset(_datasetFilePath);
|
||||
if (!_dataset) {
|
||||
throw ghoul::RuntimeError("Failed to load dataset: " + _datasetFilePath);
|
||||
}
|
||||
|
||||
// Assume all raster bands have the same data type
|
||||
_gdalDatasetMetaDataCached.rasterCount = _dataset->GetRasterCount();
|
||||
@@ -223,21 +226,7 @@ RawTile::ReadError GdalRawTileDataReader::rasterRead(
|
||||
}
|
||||
|
||||
GDALDataset* GdalRawTileDataReader::openGdalDataset(const std::string& filePath) {
|
||||
GDALDataset* dataset = static_cast<GDALDataset*>(
|
||||
GDALOpen(filePath.c_str(), GA_ReadOnly)
|
||||
);
|
||||
if (!dataset) {
|
||||
using namespace ghoul::filesystem;
|
||||
// std::string correctedPath = FileSystem::ref().pathByAppendingComponent(
|
||||
// _initDirectory, filePath
|
||||
// );
|
||||
|
||||
dataset = static_cast<GDALDataset*>(GDALOpen(filePath.c_str(), GA_ReadOnly));
|
||||
if (!dataset) {
|
||||
throw ghoul::RuntimeError("Failed to load dataset:\n" + filePath);
|
||||
}
|
||||
}
|
||||
return dataset;
|
||||
return static_cast<GDALDataset*>(GDALOpen(filePath.c_str(), GA_ReadOnly));
|
||||
}
|
||||
|
||||
int GdalRawTileDataReader::calculateTileLevelDifference(int minimumPixelSize) const {
|
||||
|
||||
@@ -117,23 +117,18 @@ GdalWrapper::GdalWrapper(size_t maximumCacheSize, size_t maximumMaximumCacheSize
|
||||
0, // Minimum: No caching
|
||||
static_cast<int>(maximumMaximumCacheSize / (1024ULL * 1024ULL)), // Maximum
|
||||
1 // Step: One MB
|
||||
) {
|
||||
)
|
||||
{
|
||||
addProperty(_logGdalErrors);
|
||||
addProperty(_gdalMaximumCacheSize);
|
||||
|
||||
GDALAllRegister();
|
||||
CPLSetConfigOption(
|
||||
"GDAL_DATA",
|
||||
absPath("${MODULE_GLOBEBROWSING}/gdal_data").c_str()
|
||||
);
|
||||
CPLSetConfigOption(
|
||||
"CPL_TMPDIR",
|
||||
absPath("${BASE}").c_str()
|
||||
);
|
||||
CPLSetConfigOption(
|
||||
"GDAL_HTTP_UNSAFESSL",
|
||||
"YES"
|
||||
);
|
||||
CPLSetConfigOption("GDAL_DATA", absPath("${MODULE_GLOBEBROWSING}/gdal_data").c_str());
|
||||
CPLSetConfigOption("CPL_TMPDIR", absPath("${BASE}").c_str());
|
||||
CPLSetConfigOption("GDAL_HTTP_UNSAFESSL", "YES");
|
||||
|
||||
CPLSetConfigOption("GDAL_HTTP_TIMEOUT", "3"); // 3 seconds
|
||||
|
||||
setGdalProxyConfiguration();
|
||||
CPLSetErrorHandler(gdalErrorHandler);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user