Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/util/gdal_timesnap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,30 @@ GDALTimesnap::GDALDataLoadingInfo GDALTimesnap::getDataLoadingInfo(Json::Value d
fileName = fileName.replace(placeholderPos, placeholder.length(), snappedTimeString);
Log::debug(concat("getDataLoadingInfo: resulting time fileName: ", fileName.c_str()));

} else if (
datasetJson.isMember("channel_start_time_list")
&& datasetJson["channel_start_time_list"].isArray()
) {

Log::debug(concat("getDataLoadingInfo: using channels as time"));

auto time_channel = 0;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if time is too small and channel stays zero?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have added a NoRasterForGivenTimeException

const auto channel_time_strings = datasetJson.get("channel_start_time_list", Json::Value(Json::ValueType::arrayValue));
for (const auto &time_string : channel_time_strings) {
auto const channel_time = timeParser->parse(time_string.asString());
if (wantedTimeUnix >= channel_time) {
time_channel += 1;
} else {
break;
}
}

if (time_channel <= 0) {
throw NoRasterForGivenTimeException("No channel corresponds to the requested time");
}

Log::debug(concat("getDataLoadingInfo: setting channel to: ", time_channel, " (was: ", channel,") for time: ", wantedTimeUnix));
channel = time_channel;
}


Expand Down