From 1739bfc591ad81e88810630e4b1b692915fab82d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20Cresson?= <remi.cresson@irstea.fr>
Date: Sat, 25 Jul 2020 23:18:28 +0200
Subject: [PATCH] FIX: StreamingMosaicFilter childs can have a different number
 of components per pixel at output

---
 .mailmap                                          |  1 +
 .../include/otbStreamingMosaicFilterBase.hxx      | 15 +++++++++------
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/.mailmap b/.mailmap
index 2886fdab76..646d37da89 100644
--- a/.mailmap
+++ b/.mailmap
@@ -84,6 +84,7 @@ Rémi Cresson <remi.cresson@irstea.fr>                     Rémi <remi.cresson@t
 Rémi Cresson <remi.cresson@irstea.fr>                     remi <remi.cresson@irstea.fr>
 Rémi Cresson <remi.cresson@irstea.fr>                     remi cresson <remi.cresson@teledetection.fr>
 Rémi Cresson <remi.cresson@irstea.fr>                     remicres <remi.cresson@teledetection.fr>
+Rémi Cresson <remi.cresson@irstea.fr>                     remi cresson <remi.cresson@inrae.fr>
 Sebastien Harasse <sebastien.harasse@c-s.fr>
 Stephane Albert <stephane.albert@c-s.fr>
 Stephane Albert <stephane.albert@c-s.fr>                  Stephane ALBERT <stephane.albert@c-s.fr>
diff --git a/Modules/Filtering/Mosaic/include/otbStreamingMosaicFilterBase.hxx b/Modules/Filtering/Mosaic/include/otbStreamingMosaicFilterBase.hxx
index 2f53952bab..06d141e7c3 100644
--- a/Modules/Filtering/Mosaic/include/otbStreamingMosaicFilterBase.hxx
+++ b/Modules/Filtering/Mosaic/include/otbStreamingMosaicFilterBase.hxx
@@ -321,18 +321,21 @@ void StreamingMosaicFilterBase<TInputImage, TOutputImage, TInternalValueType>::G
   itk::EncapsulateMetaData<std::string>(mosaicMetaData, static_cast<std::string>(otb::MetaDataKey::ProjectionRefKey), projectionRef);
 
   // check no data pixels
-  if (m_NoDataOutputPixel.GetSize() != nbOfBands || m_NoDataInputPixel.GetSize() != nbOfBands)
+  if (m_NoDataInputPixel.GetSize() != nbOfBands)
   {
-    if (m_NoDataOutputPixel.GetSize() != 0)
-      itkWarningMacro(<< "Specified NoDataOutputPixel has not " << nbOfBands << " components. Using default (zeros)");
     if (m_NoDataInputPixel.GetSize() != 0)
       itkWarningMacro(<< "Specified NoDataInputPixel has not " << nbOfBands << " components. Using default (zeros)");
 
-    m_NoDataOutputPixel.SetSize(nbOfBands);
     m_NoDataInputPixel.SetSize(nbOfBands);
-    m_NoDataOutputPixel.Fill(itk::NumericTraits<OutputImageInternalPixelType>::Zero);
     m_NoDataInputPixel.Fill(itk::NumericTraits<InputImageInternalPixelType>::Zero);
   }
+  if (m_NoDataOutputPixel.GetSize() == 0)
+  {
+    itkWarningMacro(<< "NoDataOutputPixel not set. Using zeros");
+    m_NoDataOutputPixel.SetSize(nbOfBands);
+    m_NoDataOutputPixel.Fill(itk::NumericTraits<InputImageInternalPixelType>::Zero);
+  }
+
 
   // Write no data flags
   std::vector<bool>   noDataValueAvailable;
@@ -444,4 +447,4 @@ void StreamingMosaicFilterBase<TInputImage, TOutputImage, TInternalValueType>::P
 
 } // end namespace otb
 
-#endif
+#endif
\ No newline at end of file
-- 
GitLab