Skip to content

Commit f6599d1

Browse files
committed
Use const auto for dataset pointer
* It's read-only operations Signed-off-by: Ryan Friedman <[email protected]>
1 parent 9bc305b commit f6599d1

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/grid_map_geo.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ bool GridMapGeo::Load(const std::string &map_path, bool algin_terrain, const std
8585

8686
bool GridMapGeo::initializeFromGdalDataset(const std::string &path, bool align_terrain) {
8787
GDALAllRegister();
88-
GDALDatasetUniquePtr dataset;
89-
dataset = GDALDatasetUniquePtr(GDALDataset::FromHandle(GDALOpen( path.c_str(), GA_ReadOnly )));
88+
const auto dataset = GDALDatasetUniquePtr(GDALDataset::FromHandle(GDALOpen( path.c_str(), GA_ReadOnly )));
9089
if (!dataset) {
9190
std::cout << __func__ << "Failed to open '" << path << "'" << std::endl;
9291
return false;
@@ -221,7 +220,7 @@ bool GridMapGeo::initializeFromGdalDataset(const std::string &path, bool align_t
221220

222221
bool GridMapGeo::addColorFromGeotiff(const std::string &path) {
223222
GDALAllRegister();
224-
GDALDataset *dataset = (GDALDataset *)GDALOpen(path.c_str(), GA_ReadOnly);
223+
const auto dataset = GDALDatasetUniquePtr(GDALDataset::FromHandle(GDALOpen( path.c_str(), GA_ReadOnly )));
225224
if (!dataset) {
226225
std::cout << __func__ << "Failed to open '" << path << "'" << std::endl;
227226
return false;
@@ -280,7 +279,7 @@ bool GridMapGeo::addColorFromGeotiff(const std::string &path) {
280279

281280
bool GridMapGeo::addLayerFromGeotiff(const std::string &layer_name, const std::string &path) {
282281
GDALAllRegister();
283-
GDALDataset *dataset = (GDALDataset *)GDALOpen(path.c_str(), GA_ReadOnly);
282+
const auto dataset = GDALDatasetUniquePtr(GDALDataset::FromHandle(GDALOpen( path.c_str(), GA_ReadOnly )));
284283
if (!dataset) {
285284
std::cout << __func__ << "Failed to open '" << path << "'" << std::endl;
286285
return false;

0 commit comments

Comments
 (0)