11#include " gdal_timesnap.h"
22#include < boost/filesystem.hpp>
3+ #include " util/concat.h"
4+ #include " util/log.h"
35
46constexpr int MAX_FILE_NAME_LENGTH = 255 ;
57
@@ -110,13 +112,19 @@ GDALTimesnap::GDALDataLoadingInfo GDALTimesnap::getDataLoadingInfo(Json::Value d
110112{
111113 // get parameters
112114 Json::Value channelJson = datasetJson[" channels" ][channel];
113-
115+
116+ // get parameters
114117 std::string time_format = channelJson.get (" time_format" , datasetJson.get (" time_format" , " " )).asString ();
118+ Log::debug (concat (" getDataLoadingInfo: time_format: " , time_format));
115119 std::string time_start = channelJson.get (" time_start" , datasetJson.get (" time_start" , " " )).asString ();
120+ Log::debug (concat (" getDataLoadingInfo: time_start: " , time_start));
116121 std::string time_end = channelJson.get (" time_end" , datasetJson.get (" time_end" , " " )).asString ();
122+ Log::debug (concat (" getDataLoadingInfo: time_end: " , time_end));
117123
118124 std::string path = channelJson.get (" path" , datasetJson.get (" path" , " " )).asString ();
125+ Log::debug (concat (" getDataLoadingInfo: path: " , path));
119126 std::string fileName = channelJson.get (" file_name" , datasetJson.get (" file_name" , " " )).asString ();
127+ Log::debug (concat (" getDataLoadingInfo: fileName: " , fileName));
120128
121129 channel = channelJson.get (" channel" , channel).asInt ();
122130
@@ -200,6 +208,8 @@ GDALTimesnap::GDALDataLoadingInfo GDALTimesnap::getDataLoadingInfo(Json::Value d
200208 size_t placeholderPos = fileName.find (placeholder);
201209
202210 fileName = fileName.replace (placeholderPos, placeholder.length (), snappedTimeString);
211+ Log::debug (concat (" getDataLoadingInfo: resulting time fileName: " , fileName.c_str ()));
212+
203213 }
204214
205215
@@ -220,7 +230,17 @@ GDALTimesnap::GDALDataLoadingInfo GDALTimesnap::getDataLoadingInfo(Json::Value d
220230
221231 boost::filesystem::path file_path (path);
222232 file_path /= fileName;
223- return GDALDataLoadingInfo (file_path.string (), channel,
233+ std::string dataset_file_path = file_path.string ();
234+ Log::debug (concat (" getDataLoadingInfo: file_path: " , file_path));
235+
236+ // Handle NetCDF subdatasets
237+ if (channelJson.isMember (" netcdf_subdataset" ) || datasetJson.isMember (" netcdf_subdataset" )) {
238+ std::string netcdf_subdataset = channelJson.get (" netcdf_subdataset" , datasetJson.get (" netcdf_subdataset" , " " )).asString ();
239+ dataset_file_path = concat (" NETCDF:" , dataset_file_path, " :" , netcdf_subdataset);
240+ Log::debug (concat (" getDataLoadingInfo: found NETCDF subdataset: " , netcdf_subdataset, " . Resulting path: " , dataset_file_path));
241+ }
242+
243+ return GDALDataLoadingInfo (dataset_file_path, channel,
224244 TemporalReference (TIMETYPE_UNIX, time_start_mapping, time_end_mapping),
225245 crsId, nodata, unit);
226246}
0 commit comments