Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use GDALDatasetUniquePtr over raw pointer #44

Merged
merged 1 commit into from
Jan 17, 2024
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
6 changes: 3 additions & 3 deletions src/grid_map_geo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ bool GridMapGeo::Load(const std::string &map_path, bool algin_terrain, const std

bool GridMapGeo::initializeFromGeotiff(const std::string &path, bool align_terrain) {
GDALAllRegister();
GDALDataset *dataset = (GDALDataset *)GDALOpen(path.c_str(), GA_ReadOnly);
const auto dataset = GDALDatasetUniquePtr(GDALDataset::FromHandle(GDALOpen(path.c_str(), GA_ReadOnly)));
if (!dataset) {
std::cout << "Failed to open" << std::endl;
return false;
Expand Down Expand Up @@ -149,7 +149,7 @@ bool GridMapGeo::initializeFromGeotiff(const std::string &path, bool align_terra

bool GridMapGeo::addColorFromGeotiff(const std::string &path) {
GDALAllRegister();
GDALDataset *dataset = (GDALDataset *)GDALOpen(path.c_str(), GA_ReadOnly);
const auto dataset = GDALDatasetUniquePtr(GDALDataset::FromHandle(GDALOpen(path.c_str(), GA_ReadOnly)));
if (!dataset) {
std::cout << "Failed to open" << std::endl;
return false;
Expand Down Expand Up @@ -210,7 +210,7 @@ bool GridMapGeo::addColorFromGeotiff(const std::string &path) {

bool GridMapGeo::addLayerFromGeotiff(const std::string &layer_name, const std::string &path) {
GDALAllRegister();
GDALDataset *dataset = (GDALDataset *)GDALOpen(path.c_str(), GA_ReadOnly);
const auto dataset = GDALDatasetUniquePtr(GDALDataset::FromHandle(GDALOpen(path.c_str(), GA_ReadOnly)));
if (!dataset) {
std::cout << "Failed to open" << std::endl;
return false;
Expand Down
Loading