From aef1745fd4a0ab9042a54885cc2145dc8baa7601 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Mon, 2 Nov 2015 17:50:54 +0100 Subject: [PATCH] COMP: Adding a new method in the version proxy to wrap the GetDriver()->GetName() code, and use it in Segmentation application --- Modules/Adapters/GdalAdapters/include/otbOGRVersionProxy.h | 3 +++ Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy1x.cxx | 5 +++++ Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy2x.cxx | 5 +++++ Modules/Applications/AppSegmentation/app/otbSegmentation.cxx | 2 +- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRVersionProxy.h b/Modules/Adapters/GdalAdapters/include/otbOGRVersionProxy.h index 1c4ac63e4b..6db10d56d4 100644 --- a/Modules/Adapters/GdalAdapters/include/otbOGRVersionProxy.h +++ b/Modules/Adapters/GdalAdapters/include/otbOGRVersionProxy.h @@ -126,6 +126,9 @@ namespace version_proxy */ GDALDriverType * GetDriverByName(const char * name); + + std::string GetDriverNameFromDataSource(const GDALDatasetType * ds); + /** * Sync dataset to disk. * diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy1x.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy1x.cxx index f92ee6e1df..1645bfe152 100644 --- a/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy1x.cxx +++ b/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy1x.cxx @@ -119,6 +119,11 @@ std::vector<std::string> GetAvailableDriversAsStringVector() return ret; } +std::string GetDriverNameFromDataSource(const GDALDatasetType * ds) +{ + return std::string(const_cast<GDALDatasetType *>(ds)->GetDriver()->GetName()); +} + } } } // end namespace diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy2x.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy2x.cxx index 725486f4b7..ebd3ecb8bd 100644 --- a/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy2x.cxx +++ b/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy2x.cxx @@ -152,6 +152,11 @@ std::vector<std::string> GetAvailableDriversAsStringVector() return ret; } +std::string GetDriverNameFromDataSource(const GDALDatasetType * ds) +{ + return std::string(const_cast<GDALDatasetType *>(ds)->GetDriverName()); +} + } } } // end namespace diff --git a/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx b/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx index bce82fc34a..00515af1a6 100644 --- a/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx +++ b/Modules/Applications/AppSegmentation/app/otbSegmentation.cxx @@ -677,7 +677,7 @@ private: //Note : the GetDriver() Method has not been encapsulated in otb::ogr::DataSource, //so we must access the OGR pointer by using .ogr() - std::string driverName(ogrDS->ogr().GetDriver()->GetName()); + std::string driverName(otb::ogr::version_proxy::GetDriverNameFromDataSource(&ogrDS->ogr())); if ( driverName.find("ESRI Shapefile") != std::string::npos) { otbAppLogINFO(<<"REPACK the Shapefile ..."<<std::endl); -- GitLab