Add global timeout of 3 seconds to GDAL request

Remove duplicate opening of GDAL datasets on failure (closes #478)
This commit is contained in:
Alexander Bock
2018-02-06 11:03:35 -05:00
parent ccce1bcacb
commit 02bb5e68b6
2 changed files with 12 additions and 28 deletions

View File

@@ -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 {

View File

@@ -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);