Skip to content

Commit 3e1f0aa

Browse files
committed
Merge branch 'master' into develop
2 parents dea6005 + f4d7860 commit 3e1f0aa

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

api/bag_dataset.cpp

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,29 @@ std::tuple<double, double> Dataset::gridToGeo(
10671067
return {x, y};
10681068
}
10691069

1070+
1071+
hid_t DopenProtector2(hid_t loc_id, const char *name, hid_t dapl_id) {
1072+
hid_t id = -1;
1073+
try {
1074+
id = H5Dopen2(loc_id, name, dapl_id);
1075+
} catch (std::exception& e) {
1076+
std::cerr << e.what();
1077+
id = -1;
1078+
}
1079+
return id;
1080+
}
1081+
1082+
hid_t GopenProtector2(hid_t loc_id, const char *name, hid_t dapl_id) {
1083+
hid_t id = -1;
1084+
try {
1085+
id = H5Gopen2(loc_id, name, dapl_id);
1086+
} catch (std::exception& e) {
1087+
std::cerr << e.what();
1088+
id = -1;
1089+
}
1090+
return id;
1091+
}
1092+
10701093
void handleAbrt(int signum) {
10711094
std::cerr << "\nUnrecoverable HDF5 Error \n";
10721095
exit(signum);
@@ -1106,8 +1129,7 @@ void Dataset::readDataset(
11061129
const std::string internalPath = Layer::getInternalPath(layerType);
11071130
if (internalPath.empty())
11081131
continue;
1109-
1110-
const hid_t id = H5Dopen2(bagGroup.getLocId(), internalPath.c_str(),
1132+
hid_t id = DopenProtector2(bagGroup.getLocId(), internalPath.c_str(),
11111133
H5P_DEFAULT);
11121134
if (id < 0)
11131135
continue;
@@ -1123,7 +1145,7 @@ void Dataset::readDataset(
11231145
// If the BAG is version 1.5+ ...
11241146
if (bagVersion >= 1'005'000)
11251147
{
1126-
hid_t id = H5Dopen2(bagGroup.getLocId(), NODE_GROUP_PATH, H5P_DEFAULT);
1148+
hid_t id = DopenProtector2(bagGroup.getLocId(), NODE_GROUP_PATH, H5P_DEFAULT);
11271149
if (id >= 0)
11281150
{
11291151
H5Dclose(id);
@@ -1138,8 +1160,7 @@ void Dataset::readDataset(
11381160
NODE);
11391161
this->addLayer(InterleavedLegacyLayer::open(*this, *layerDesc));
11401162
}
1141-
1142-
id = H5Dopen2(bagGroup.getLocId(), ELEVATION_SOLUTION_GROUP_PATH,
1163+
id = DopenProtector2(bagGroup.getLocId(), ELEVATION_SOLUTION_GROUP_PATH,
11431164
H5P_DEFAULT);
11441165
if (id >= 0)
11451166
{
@@ -1164,7 +1185,7 @@ void Dataset::readDataset(
11641185
}
11651186

11661187
// Read optional VR
1167-
hid_t id = H5Dopen2(bagGroup.getLocId(), VR_TRACKING_LIST_PATH, H5P_DEFAULT);
1188+
hid_t id = DopenProtector2(bagGroup.getLocId(), VR_TRACKING_LIST_PATH, H5P_DEFAULT);
11681189
if (id >= 0)
11691190
{
11701191
H5Dclose(id);
@@ -1182,7 +1203,7 @@ void Dataset::readDataset(
11821203
}
11831204

11841205
// optional VRNodeLayer
1185-
id = H5Dopen2(bagGroup.getLocId(), VR_NODE_PATH, H5P_DEFAULT);
1206+
id = DopenProtector2(bagGroup.getLocId(), VR_NODE_PATH, H5P_DEFAULT);
11861207
if (id >= 0)
11871208
{
11881209
H5Dclose(id);
@@ -1195,7 +1216,7 @@ void Dataset::readDataset(
11951216
m_pTrackingList = std::unique_ptr<TrackingList>(new TrackingList{*this});
11961217

11971218
// Read optional Surface Corrections
1198-
id = H5Dopen2(bagGroup.getLocId(), VERT_DATUM_CORR_PATH, H5P_DEFAULT);
1219+
id = DopenProtector2(bagGroup.getLocId(), VERT_DATUM_CORR_PATH, H5P_DEFAULT);
11991220
if (id >= 0)
12001221
{
12011222
H5Dclose(id);
@@ -1208,7 +1229,7 @@ void Dataset::readDataset(
12081229
if (bagVersion >= 2'000'000)
12091230
{
12101231
// Add all existing GeorefMetadataLayers
1211-
id = H5Gopen2(bagGroup.getLocId(), GEOREF_METADATA_PATH, H5P_DEFAULT);
1232+
id = GopenProtector2(bagGroup.getLocId(), GEOREF_METADATA_PATH, H5P_DEFAULT);
12121233
if (id >= 0)
12131234
{
12141235
H5Gclose(id);

0 commit comments

Comments
 (0)