From 0ff2f4b9649c974ac955b460ba35363f4c7c64f7 Mon Sep 17 00:00:00 2001
From: Otmane Lahlou <otmane.lahlou@c-s.fr>
Date: Wed, 18 May 2011 16:25:48 +0200
Subject: [PATCH] ENH : handle type OFTString in methods GetFieldAs{Int,Double}

---
 Code/IO/otbVectorDataKeywordlist.cxx | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/Code/IO/otbVectorDataKeywordlist.cxx b/Code/IO/otbVectorDataKeywordlist.cxx
index eba5dfada2..6ce43cf885 100644
--- a/Code/IO/otbVectorDataKeywordlist.cxx
+++ b/Code/IO/otbVectorDataKeywordlist.cxx
@@ -15,9 +15,10 @@
      PURPOSE.  See the above copyright notices for more information.
 
 =========================================================================*/
+#include <iostream>
+#include <iomanip>
 
 #include "otbVectorDataKeywordlist.h"
-#include <iomanip>
 
 namespace otb
 {
@@ -127,6 +128,13 @@ VectorDataKeywordlist
           {
           return (double)(m_FieldList[i].second.Real);
           }
+        if (m_FieldList[i].first->GetType() == OFTString)
+          {
+          std::istringstream is(m_FieldList[i].second.String);
+          double value;
+          is >> value;
+          return value;
+          }
         itkExceptionMacro(
           << "This type (" << m_FieldList[i].first->GetType() <<
           ") is not handled (yet) by GetFieldAsDouble(), please request for it");
@@ -151,6 +159,13 @@ VectorDataKeywordlist
           {
           return (int)(m_FieldList[i].second.Real);
           }
+        if (m_FieldList[i].first->GetType() == OFTString)
+          {
+          std::istringstream is(m_FieldList[i].second.String);
+          int value;
+          is >> value;
+          return value;
+          }
         itkExceptionMacro(
           << "This type (" << m_FieldList[i].first->GetType() <<
           ") is not handled (yet) by GetFieldAsInt(), please request for it");
-- 
GitLab