From e0449c323c1c3c0dd63afa66b58a3a998ad3ec45 Mon Sep 17 00:00:00 2001
From: Julien Michel <julien.michel@orfeo-toolbox.org>
Date: Tue, 8 Jul 2014 13:48:18 +0200
Subject: [PATCH] BUG: Multiple errors in Pleiades sensor model (invalid cast
 to Int32 and inconsistency with OSSIM sensor model convention, which is that
 the coordinate of the UL pixel center is (0,0)

---
 .../ossim/ossimPleiadesDimapSupportData.cpp        | 14 ++++++++++----
 .../ossim/ossimPleiadesDimapSupportData.h          |  4 ++--
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/Utilities/otbossimplugins/ossim/ossimPleiadesDimapSupportData.cpp b/Utilities/otbossimplugins/ossim/ossimPleiadesDimapSupportData.cpp
index a1243c3ed0..c2eb6c336c 100644
--- a/Utilities/otbossimplugins/ossim/ossimPleiadesDimapSupportData.cpp
+++ b/Utilities/otbossimplugins/ossim/ossimPleiadesDimapSupportData.cpp
@@ -258,8 +258,8 @@ namespace ossimplugins
       theErrBiasX = 0.0;
       theErrBiasY = 0.0;
       theErrRand = 0.0;
-      theLineOffset = 0;
-      theSampOffset = 0;
+      theLineOffset = 0.0;
+      theSampOffset = 0.0;
       theLatOffset = 0.0;
       theLonOffset = 0.0;
       theHeightOffset = 0.0;
@@ -1797,7 +1797,10 @@ namespace ossimplugins
       {
          return false;
       }
-      theSampOffset = nodeValue.toInt32();
+      // Pleiades metadata assume that the coordinate of the center of
+      // the upper-left pixel is (1,1), so we remove 1 to get back to
+      // OSSIM convention.
+      theSampOffset = nodeValue.toDouble()-1;
 
       if (theDIMAPVersion == OSSIM_PLEIADES_DIMAPv1)
       {
@@ -1827,7 +1830,10 @@ namespace ossimplugins
       {
          return false;
       }
-      theLineOffset = nodeValue.toInt32();
+      // Pleiades metadata assume that the coordinate of the center of
+      // the upper-left pixel is (1,1), so we remove 1 to get back to
+      // OSSIM convention.
+      theLineOffset = nodeValue.toDouble()-1;
 
       return true;
    }
diff --git a/Utilities/otbossimplugins/ossim/ossimPleiadesDimapSupportData.h b/Utilities/otbossimplugins/ossim/ossimPleiadesDimapSupportData.h
index adf39aaf66..1af7fe9e7a 100644
--- a/Utilities/otbossimplugins/ossim/ossimPleiadesDimapSupportData.h
+++ b/Utilities/otbossimplugins/ossim/ossimPleiadesDimapSupportData.h
@@ -212,8 +212,8 @@ namespace ossimplugins
          double    theErrBiasX;
          double    theErrBiasY;
          double    theErrRand;
-         ossim_int32 theLineOffset;
-         ossim_int32 theSampOffset;
+         double    theLineOffset;
+         double    theSampOffset;
          double    theLatOffset;
          double    theLonOffset;
          double    theHeightOffset;
-- 
GitLab