From 54026d06573e0ffb923807a0e4f108ffdc13c6e8 Mon Sep 17 00:00:00 2001
From: Julien Michel <julien.michel@orfeo-toolbox.org>
Date: Mon, 30 Jul 2012 15:44:28 +0200
Subject: [PATCH] BUG: dynamic_cast fails when image is not of type
 OutputImageType. Replacing the GetProjectionRef() call since it is the only
 one requiring the dynamic cast

---
 Code/BasicFilters/otbVectorDataToLabelImageFilter.txx | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/Code/BasicFilters/otbVectorDataToLabelImageFilter.txx b/Code/BasicFilters/otbVectorDataToLabelImageFilter.txx
index 5a40a16235..3e80162561 100644
--- a/Code/BasicFilters/otbVectorDataToLabelImageFilter.txx
+++ b/Code/BasicFilters/otbVectorDataToLabelImageFilter.txx
@@ -118,16 +118,13 @@ VectorDataToLabelImageFilter<TVectorData, TOutputImage>
 template <class TVectorData, class TOutputImage>
 void
 VectorDataToLabelImageFilter<TVectorData, TOutputImage>
-::SetOutputParametersFromImage(const ImageBaseType * image)
-{
-  const OutputImageType * src = dynamic_cast<const OutputImageType*>(image);
-  
+::SetOutputParametersFromImage(const ImageBaseType * src)
+{ 
   this->SetOutputOrigin ( src->GetOrigin() );
   this->SetOutputSpacing ( src->GetSpacing() );
-  //this->SetOutputStartIndex ( src->GetLargestPossibleRegion().GetIndex() );
   this->SetOutputSize ( src->GetLargestPossibleRegion().GetSize() );
-  this->SetOutputProjectionRef(src->GetProjectionRef());
-  //this->SetOutputKeywordList(src->GetImageKeywordlist());
+  typename ImageMetadataInterfaceBase::Pointer imi = ImageMetadataInterfaceFactory::CreateIMI(src->GetMetaDataDictionary());
+  this->SetOutputProjectionRef(imi->GetProjectionRef());
 }
 
 template<class TVectorData, class TOutputImage>
-- 
GitLab