From eeb74b051834068deaf10c136f2442b7dfc7094a Mon Sep 17 00:00:00 2001
From: Guillaume Pasero <guillaume.pasero@c-s.fr>
Date: Wed, 4 Jun 2014 19:09:56 +0200
Subject: [PATCH] DOC: Mantis-942: explain the origin of the problem

---
 Code/IO/otbGDALImageIO.cxx     | 6 +++++-
 Code/IO/otbJPEG2000ImageIO.cxx | 2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/Code/IO/otbGDALImageIO.cxx b/Code/IO/otbGDALImageIO.cxx
index 966bb071e7..dff5e861b7 100644
--- a/Code/IO/otbGDALImageIO.cxx
+++ b/Code/IO/otbGDALImageIO.cxx
@@ -138,7 +138,7 @@ GDALImageIO::GDALImageIO()
   // Set default spacing to one
   m_Spacing[0] = 1.0;
   m_Spacing[1] = 1.0;
-  // Set default origin to zero
+  // Set default origin to half a pixel (centered pixel convention)
   m_Origin[0] = 0.5;
   m_Origin[1] = 0.5;
 
@@ -1035,6 +1035,8 @@ void GDALImageIO::InternalReadImageInformation()
           }
         }
       // Geotransforms with a non-null rotation are not supported
+      // Beware : GDAL origin is at the corner of the top-left pixel
+      // whereas OTB/ITK origin is at the centre of the top-left pixel
       m_Origin[0] = VadfGeoTransform[0] + 0.5*m_Spacing[0];
       m_Origin[1] = VadfGeoTransform[3] + 0.5*m_Spacing[1];
       }
@@ -1678,6 +1680,8 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer)
   /* -------------------------------------------------------------------- */
   itk::VariableLengthVector<double> geoTransform(6);
   /// Reporting origin and spacing
+  // Beware : GDAL origin is at the corner of the top-left pixel
+  // whereas OTB/ITK origin is at the centre of the top-left pixel
   geoTransform[0] = m_Origin[0] - 0.5*m_Spacing[0];
   geoTransform[3] = m_Origin[1] - 0.5*m_Spacing[1];
   geoTransform[1] = m_Spacing[0];
diff --git a/Code/IO/otbJPEG2000ImageIO.cxx b/Code/IO/otbJPEG2000ImageIO.cxx
index 0542a9c7d2..c6de7808a3 100644
--- a/Code/IO/otbJPEG2000ImageIO.cxx
+++ b/Code/IO/otbJPEG2000ImageIO.cxx
@@ -1274,6 +1274,8 @@ void JPEG2000ImageIO::ReadImageInformation()
           }
         }
       // Geotransforms with a non-null rotation are not supported
+      // Beware : GDAL origin is at the corner of the top-left pixel
+      // whereas OTB/ITK origin is at the centre of the top-left pixel
       m_Origin[0] = geoTransform[0] + 0.5*m_Spacing[0];
       m_Origin[1] = geoTransform[3] + 0.5*m_Spacing[1];
       }
-- 
GitLab