Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.

Commit 1651e1c

Browse files
authored
Merge pull request #42 from umr-dbs/no-raster-for-given-time-un-confidential
make NoRasterForGivenTimeException visible to the user
2 parents ffdef62 + 5bef6bd commit 1651e1c

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

src/rasterdb/backend_local.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,12 @@ RasterDBBackend::RasterDescription LocalRasterDBBackend::getClosestRaster(int ch
344344
stmt.bind(1, channelid);
345345
stmt.bind(2, t1);
346346
stmt.bind(3, t2);
347-
if (!stmt.next())
348-
throw NoRasterForGivenTimeException( concat("No raster found for the given time (source=", sourcename, ", channel=", channelid, ", time=", t1, "-", t2, ")"));
347+
if (!stmt.next()) {
348+
throw NoRasterForGivenTimeException(
349+
concat("No raster found for the given time (source=", sourcename, ", channel=", channelid, ", time=", t1, "-", t2, ")"),
350+
MappingExceptionType::PERMANENT
351+
);
352+
}
349353

350354
auto rasterid = stmt.getInt64(0);
351355
double time_start = stmt.getDouble(1);

src/util/gdal_timesnap.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ ptime GDALTimesnap::snapToInterval(TimeUnit snapUnit, int intervalValue, ptime s
105105

106106

107107

108-
// calculates the filename for queried time by snapping the wanted time to the
108+
// calculates the filename for queried time by snapping the wanted time to the
109109
// nearest smaller timestamp that exists for the dataset
110110
// TODO: move general parameter parsing to a more appropriate function
111111
GDALTimesnap::GDALDataLoadingInfo GDALTimesnap::getDataLoadingInfo(Json::Value datasetJson, int channel, const TemporalReference &tref)
112112
{
113113
// get parameters
114114
Json::Value channelJson = datasetJson["channels"][channel];
115-
115+
116116
// get parameters
117117
std::string time_format = channelJson.get("time_format", datasetJson.get("time_format", "")).asString();
118118
std::string time_start = channelJson.get("time_start", datasetJson.get("time_start", "")).asString();
@@ -129,7 +129,7 @@ GDALTimesnap::GDALDataLoadingInfo GDALTimesnap::getDataLoadingInfo(Json::Value d
129129
", fileName: ", fileName
130130
)
131131
);
132-
132+
133133
channel = channelJson.get("channel", channel).asInt();
134134

135135
// resolve time
@@ -154,8 +154,12 @@ GDALTimesnap::GDALDataLoadingInfo GDALTimesnap::getDataLoadingInfo(Json::Value d
154154

155155
//check if requested time is in range of dataset timestamps
156156
//a dataset only has start not end time. if wantedtime is past the last file of dataset, it can simply not be loaded.
157-
if(wantedTimeUnix < time_start_mapping || wantedTimeUnix > time_end_mapping)
158-
throw NoRasterForGivenTimeException("Requested time is not in range of dataset");
157+
if(wantedTimeUnix < time_start_mapping || wantedTimeUnix > time_end_mapping) {
158+
throw NoRasterForGivenTimeException(
159+
"Requested time is not in range of dataset",
160+
MappingExceptionType::PERMANENT
161+
);
162+
}
159163

160164
if(datasetJson.isMember("time_interval") || channelJson.isMember("time_interval")) {
161165
Json::Value timeInterval = channelJson.get("time_interval", datasetJson.get("time_interval", Json::Value(Json::objectValue)));
@@ -231,11 +235,14 @@ GDALTimesnap::GDALDataLoadingInfo GDALTimesnap::getDataLoadingInfo(Json::Value d
231235
break;
232236
}
233237
}
234-
238+
235239
if (time_channel <= 0) {
236-
throw NoRasterForGivenTimeException("No channel corresponds to the requested time");
240+
throw NoRasterForGivenTimeException(
241+
"No channel corresponds to the requested time",
242+
MappingExceptionType::PERMANENT
243+
);
237244
}
238-
245+
239246
Log::debug(concat("getDataLoadingInfo: setting channel to: ", time_channel, " (was: ", channel,") for time: ", wantedTimeUnix));
240247
channel = time_channel;
241248
}
@@ -259,7 +266,7 @@ GDALTimesnap::GDALDataLoadingInfo GDALTimesnap::getDataLoadingInfo(Json::Value d
259266
boost::filesystem::path file_path(path);
260267
file_path /= fileName;
261268
std::string dataset_file_path = file_path.string();
262-
Log::debug(concat("getDataLoadingInfo: file_path: ", file_path));
269+
Log::debug(concat("getDataLoadingInfo: file_path: ", file_path));
263270

264271
// Handle NetCDF subdatasets
265272
if (channelJson.isMember("netcdf_subdataset") || datasetJson.isMember("netcdf_subdataset")) {

0 commit comments

Comments
 (0)