From ae8ccf9c0da5bb2fb7e15a936c1556ea99cbb9a4 Mon Sep 17 00:00:00 2001
From: Julien Osman <julien.osman@c-s.fr>
Date: Wed, 8 Apr 2020 10:09:14 +0200
Subject: [PATCH] FIX: Remove dependency to GDAL3 methods. Add my email to
 .mailmap file.

---
 .mailmap                                                    | 1 +
 Modules/Adapters/GdalAdapters/include/otbSpatialReference.h | 5 -----
 Modules/Adapters/GdalAdapters/src/otbSpatialReference.cxx   | 5 -----
 Modules/IO/IOGDAL/src/otbGDALImageIO.cxx                    | 2 +-
 4 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/.mailmap b/.mailmap
index 4f5b296731..40ef95e52d 100644
--- a/.mailmap
+++ b/.mailmap
@@ -54,6 +54,7 @@ Julien Malik <julien.malik@c-s.fr>                        Julien Malik <julien.m
 Julien Michel <julien.michel@cnes.fr>
 Julien Michel <julien.michel@cnes.fr>                     Julien Michel <julien.michel@c-s.fr>
 Julien Michel <julien.michel@cnes.fr>                     Julien Michel <julien.michel@orfeo-toolbox.org>
+Julien Osman <julien.osman@c-s.fr>
 Laurențiu Nicola <lnicola@dend.ro>                        Laurentiu Nicola <lnicola@dend.ro>
 Laurențiu Nicola <lnicola@dend.ro>                        Laurențiu Nicola <grayshade@gmail.com>
 Luc Hermitte <luc.hermitte@c-s.fr>                        Luc Hermitte <luc.hermitte@cnes.fr>
diff --git a/Modules/Adapters/GdalAdapters/include/otbSpatialReference.h b/Modules/Adapters/GdalAdapters/include/otbSpatialReference.h
index ca2059fd57..37611309fd 100644
--- a/Modules/Adapters/GdalAdapters/include/otbSpatialReference.h
+++ b/Modules/Adapters/GdalAdapters/include/otbSpatialReference.h
@@ -176,11 +176,6 @@ public:
    */
   static void UTMFromGeoPoint(double lon, double lat, unsigned int& zone, hemisphere& hem);
 
-  /**
-   * Returns the internal OGRSpatialReference
-   */
-  OGRSpatialReference* getOGRSpatialReference();
-
 private:
   /// Constructor from wrapped type. ref will be cloned.
   SpatialReference(const OGRSpatialReference* ref);
diff --git a/Modules/Adapters/GdalAdapters/src/otbSpatialReference.cxx b/Modules/Adapters/GdalAdapters/src/otbSpatialReference.cxx
index 1e3f4b8c8f..120f8d0ae2 100644
--- a/Modules/Adapters/GdalAdapters/src/otbSpatialReference.cxx
+++ b/Modules/Adapters/GdalAdapters/src/otbSpatialReference.cxx
@@ -294,11 +294,6 @@ void SpatialReference::UTMFromGeoPoint(double lon, double lat, unsigned int& zon
   assert(zone <= 60);
 }
 
-OGRSpatialReference* SpatialReference::getOGRSpatialReference()
-{
-  return m_SR.get();
-}
-
 #if GDAL_VERSION_NUM >= 3000000
 void SpatialReference::SetAxisMappingStrategy(OSRAxisMappingStrategy strategy)
 {
diff --git a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx
index 86e0d2ded1..1cbbea7e22 100644
--- a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx
+++ b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx
@@ -1176,7 +1176,7 @@ void GDALImageIO::Write(const void* buffer)
   if (m_epsgCode != 0)
   {
     auto spatialReference = SpatialReference::FromEPSG(m_epsgCode);
-    m_Dataset->GetDataSet()->SetSpatialRef(spatialReference.getOGRSpatialReference());
+    m_Dataset->GetDataSet()->SetProjection(spatialReference.ToWkt().c_str());
   }
 
   // Convert buffer from void * to unsigned char *
-- 
GitLab