From 641bc6e2efc059de2d4701d4f9b4621f1002765e Mon Sep 17 00:00:00 2001
From: Manuel Grizonnet <manuel.grizonnet@orfeo-toolbox.org>
Date: Mon, 25 Mar 2013 18:06:48 +0100
Subject: [PATCH] ENH: ImageFileWriter image region to write through extended
 filenames

---
 .../IO/otbExtendedFilenameToWriterOptions.cxx | 35 ++++++-
 Code/IO/otbExtendedFilenameToWriterOptions.h  |  5 +
 Code/IO/otbImageFileWriter.txx                | 55 ++++++++---
 Testing/Code/IO/CMakeLists.txt                | 95 ++++++++++---------
 4 files changed, 134 insertions(+), 56 deletions(-)

diff --git a/Code/IO/otbExtendedFilenameToWriterOptions.cxx b/Code/IO/otbExtendedFilenameToWriterOptions.cxx
index 7bad81cbee..2fcfd4bd2c 100644
--- a/Code/IO/otbExtendedFilenameToWriterOptions.cxx
+++ b/Code/IO/otbExtendedFilenameToWriterOptions.cxx
@@ -17,6 +17,7 @@
 =========================================================================*/
 #include "otbExtendedFilenameToWriterOptions.h"
 #include <boost/algorithm/string.hpp>
+#include <itksys/RegularExpression.hxx>
 
 namespace otb
 {
@@ -41,6 +42,7 @@ ExtendedFilenameToWriterOptions
   m_Options.optionList.push_back("streaming:type");
   m_Options.optionList.push_back("streaming:sizemode");
   m_Options.optionList.push_back("streaming:sizevalue");
+  m_Options.optionList.push_back("region");
 }
 
 void
@@ -81,7 +83,7 @@ ExtendedFilenameToWriterOptions
        m_Options.writeGEOMFile.second = false;
        }
      }
-  
+
   if(!map["streaming:type"].empty())
     {
     if(map["streaming:type"] == "auto"
@@ -119,6 +121,23 @@ ExtendedFilenameToWriterOptions
     m_Options.streamingSizeValue.second = atof(map["streaming:sizevalue"].c_str());
     }
 
+  //Manage region size to write in output image
+  if(!map["regionsize"].empty())
+    {
+    itksys::RegularExpression reg;
+    reg.compile("([^0-9\\.]\s[^0-9\\.]\s[^0-9\\.]\s[^0-9\\.])");
+
+    if(!reg.find(map["regionsize"]))
+      {
+      m_Options.regionSize.first=true;
+      m_Options.regionSize.second = map["regionsize"];
+      }
+    else
+      {
+      itkWarningMacro("Unkwown value "<<map["regionsize"]<<" for regionsize. Must be 'xmin ymin xmax ymax', with whitespace as separator");
+      }
+    }
+
   //Option Checking
   for ( it=map.begin(); it != map.end(); it++ )
     {
@@ -227,5 +246,19 @@ ExtendedFilenameToWriterOptions
   return m_Options.streamingSizeValue.second;
 }
 
+bool
+ExtendedFilenameToWriterOptions
+::RegionSizeIsSet() const
+{
+  return m_Options.regionSize.first;
+}
+
+std::string
+ExtendedFilenameToWriterOptions
+::GetRegionSize() const
+{
+  return m_Options.regionSize.second;
+}
+
 
 } // end namespace otb
diff --git a/Code/IO/otbExtendedFilenameToWriterOptions.h b/Code/IO/otbExtendedFilenameToWriterOptions.h
index 3c1134af3c..eadb3dd221 100644
--- a/Code/IO/otbExtendedFilenameToWriterOptions.h
+++ b/Code/IO/otbExtendedFilenameToWriterOptions.h
@@ -63,6 +63,7 @@ public:
     std::pair<bool,  std::string>                streamingType;
     std::pair<bool,  std::string>                streamingSizeMode;
     std::pair<bool,  double>                     streamingSizeValue;
+    std::pair<bool,  std::string>                regionSize;
     std::vector<std::string>                     optionList;
   };
 
@@ -82,6 +83,10 @@ public:
   bool StreamingSizeValueIsSet() const;
   double GetStreamingSizeValue() const;
 
+  bool RegionSizeIsSet() const;
+  std::string GetRegionSize() const;
+
+
 protected:
   ExtendedFilenameToWriterOptions();
   virtual ~ExtendedFilenameToWriterOptions() {}
diff --git a/Code/IO/otbImageFileWriter.txx b/Code/IO/otbImageFileWriter.txx
index 559286f79d..9d676e6090 100644
--- a/Code/IO/otbImageFileWriter.txx
+++ b/Code/IO/otbImageFileWriter.txx
@@ -252,7 +252,7 @@ ImageFileWriter<TInputImage>
     {
     return 0;
     }
-  
+
   return static_cast<const InputImageType*>(this->ProcessObject::GetInput(0));
 }
 
@@ -267,7 +267,7 @@ ImageFileWriter<TInputImage>
   // Update output information on input image
   InputImagePointer inputPtr =
     const_cast<InputImageType *>(this->GetInput());
-  
+
   // Make sure input is available
   if ( inputPtr.IsNull() )
     {
@@ -331,7 +331,7 @@ ImageFileWriter<TInputImage>
           {
           itkWarningMacro("Streaming sizemode is set to height but sizevalue is 0. This will result in upredicted behaviour. Please consider setting the sizevalue by using &streaming:sizevalue=x.");
           }
-        
+
         this->SetTileDimensionTiledStreaming(static_cast<unsigned int>(sizevalue));
         }
       }
@@ -470,7 +470,38 @@ ImageFileWriter<TInputImage>
    */
   inputPtr->UpdateOutputInformation();
   InputImageRegionType inputRegion = inputPtr->GetLargestPossibleRegion();
-  
+
+  /** Parse region size modes */
+  if(m_FilenameHelper->RegionSizeIsSet())
+    {
+    std::cout << "need to set image io" << std::endl;
+
+    std::string buf; // Have a buffer string
+    std::stringstream ss(m_FilenameHelper->GetRegionSize()); // Insert the string into a stream
+
+    std::vector<unsigned int> tokens; // Create vector to hold our words
+
+    while (ss >> buf)
+      {
+      tokens.push_back(atoi(buf.c_str()));
+      }
+
+    typename InputImageType::IndexType start;
+    typename InputImageType::SizeType  size;
+
+    size[0]  = tokens[2];  // size along X
+    size[1]  = tokens[3];  // size along Y
+
+    start[0] = tokens[0];  // first index on X
+    start[1] = tokens[2];  // first index on Y
+
+    inputRegion.SetSize(size);
+    inputRegion.SetIndex(start);
+    }
+
+
+
+
   /**
    * Determine of number of pieces to divide the input.  This will be the
    * minimum of what the user specified via SetNumberOfDivisionsStrippedStreaming()
@@ -654,18 +685,18 @@ ImageFileWriter<TInputImage>
   //
   //okay, now extract the data as a raw buffer pointer
   const void* dataPtr = (const void*) input->GetBufferPointer();
-  
+
   // check that the image's buffered region is the same as
   // ImageIO is expecting and we requested
   InputImageRegionType ioRegion;
-  
+
   // No shift of the ioRegion from the buffered region is expected
   typename InputImageRegionType::IndexType tmpIndex;
   tmpIndex.Fill(0);
   itk::ImageIORegionAdaptor<TInputImage::ImageDimension>::
     Convert(m_ImageIO->GetIORegion(), ioRegion, tmpIndex);
   InputImageRegionType bufferedRegion = input->GetBufferedRegion();
-  
+
   // before this test, bad stuff would happend when they don't match
   if (bufferedRegion != ioRegion)
     {
@@ -673,7 +704,7 @@ ImageFileWriter<TInputImage>
       {
       itkDebugMacro("Requested stream region does not match generated output");
       itkDebugMacro("input filter may not support streaming well");
-      
+
       cacheImage = InputImageType::New();
       cacheImage->CopyInformation(input);
       cacheImage->SetBufferedRegion(ioRegion);
@@ -681,18 +712,18 @@ ImageFileWriter<TInputImage>
 
       typedef itk::ImageRegionConstIterator<TInputImage> ConstIteratorType;
       typedef itk::ImageRegionIterator<TInputImage>      IteratorType;
-      
+
       ConstIteratorType in(input, ioRegion);
       IteratorType out(cacheImage, ioRegion);
-     
+
       // copy the data into a buffer to match the ioregion
       for (in.GoToBegin(), out.GoToBegin(); !in.IsAtEnd(); ++in, ++out)
         {
         out.Set(in.Get());
         }
-      
+
       dataPtr = (const void*) cacheImage->GetBufferPointer();
-      
+
       }
     else
       {
diff --git a/Testing/Code/IO/CMakeLists.txt b/Testing/Code/IO/CMakeLists.txt
index 98b11e19ce..2404da3c65 100644
--- a/Testing/Code/IO/CMakeLists.txt
+++ b/Testing/Code/IO/CMakeLists.txt
@@ -54,7 +54,7 @@ SET(IO_TESTS23    ${CXX_TEST_PATH}/otbIOTests23)
 SET(IO_TESTS24    ${CXX_TEST_PATH}/otbIOTests24)
 
 # --------------------------------------------------------------------------------
-# Manage PHR data input   
+# Manage PHR data input
 IF(OTB_DATA_USE_LARGEINPUT)
    SET(GenericTestPHR_DATA_INPUTS
       ${GenericTestPHR_DATA_INPUTS}
@@ -65,7 +65,7 @@ IF(OTB_DATA_USE_LARGEINPUT)
       ${LARGEINPUT}/PLEIADES/LASVEGAS_JP2_DIMAPv1_PRIMARY_PMS_lossless_12bits/IMGPHR_PHR1A_SENSOR_20120217_IPU_20120217_5374-001_V1/IMG_R1C1.JP2
       ${LARGEINPUT}/PLEIADES/PARIS_JP2_DIMAPv1_ORTHO_PMS_lossless_12bits/IMGPHR_PHR1A_ORTHO_20120502_IPU_20120430_6347-003_V1/IMG_R1C1.JP2
    )
-   
+
    SET(GenericTestPHR_DATA_TYPES
       ${GenericTestPHR_DATA_TYPES}
       SIMUL_PHR_JP2_ORTHO_DIMAPv2_PMS-N_lossy_12bits
@@ -74,8 +74,8 @@ IF(OTB_DATA_USE_LARGEINPUT)
       PHR_JP2_DIMAPv2_PRIMARY_PMS_lossless_12bits
       PHR_JP2_DIMAPv1_PRIMARY_PMS_lossless_12bits
       PHR_JP2_DIMAPv1_ORTHO_PMS_lossless_12bits
-   )      
-ENDIF(OTB_DATA_USE_LARGEINPUT)   
+   )
+ENDIF(OTB_DATA_USE_LARGEINPUT)
 
 IF(OTB_DATA_USE_SPOTPHRINPUT)
   SET(GenericTestPHR_SPOT_DATA_INPUTS
@@ -95,9 +95,9 @@ IF(OTB_DATA_USE_SPOTPHRINPUT)
 	  SPOT_PHR_PRIMARY_MS
 	  SPOT_PHR_PRIMARY_P
 	 )
-	 
-   SET(GenericTestPHR_DATA_INPUTS ${GenericTestPHR_DATA_INPUTS} ${GenericTestPHR_SPOT_DATA_INPUTS})	  
-   SET(GenericTestPHR_DATA_TYPES ${GenericTestPHR_DATA_TYPES} ${GenericTestPHR_SPOT_DATA_TYPES})   
+
+   SET(GenericTestPHR_DATA_INPUTS ${GenericTestPHR_DATA_INPUTS} ${GenericTestPHR_SPOT_DATA_INPUTS})
+   SET(GenericTestPHR_DATA_TYPES ${GenericTestPHR_DATA_TYPES} ${GenericTestPHR_SPOT_DATA_TYPES})
 ENDIF(OTB_DATA_USE_SPOTPHRINPUT)
 
 IF(OTB_DATA_USE_CNESPHRINPUT)
@@ -112,17 +112,17 @@ IF(OTB_DATA_USE_CNESPHRINPUT)
 	  CNES_PHR_PRIMARY_PMS_R1C1_2012-02-22
 	  CNES_PHR_PRIMARY_PMS_R3C1_2012-02-22
 	 )
-  
-  SET(GenericTestPHR_DATA_INPUTS ${GenericTestPHR_DATA_INPUTS} ${GenericTestPHR_CNES_DATA_INPUTS})	 
-  SET(GenericTestPHR_DATA_TYPES ${GenericTestPHR_DATA_TYPES} ${GenericTestPHR_CNES_DATA_TYPES})    	 	 
+
+  SET(GenericTestPHR_DATA_INPUTS ${GenericTestPHR_DATA_INPUTS} ${GenericTestPHR_CNES_DATA_INPUTS})
+  SET(GenericTestPHR_DATA_TYPES ${GenericTestPHR_DATA_TYPES} ${GenericTestPHR_CNES_DATA_TYPES})
 ENDIF(OTB_DATA_USE_CNESPHRINPUT)
 
 # Use in debug to show the variables
-#SET( GenericTestPHR_TESTNB 0)  
+#SET( GenericTestPHR_TESTNB 0)
 #FOREACH( current_file ${GenericTestPHR_DATA_INPUTS} )
 #  LIST(GET GenericTestPHR_DATA_TYPES  ${GenericTestPHR_TESTNB} current_type   )
 #  MATH(EXPR GenericTestPHR_TESTNB "${GenericTestPHR_TESTNB} + 1")
-#  
+#
 #  MESSAGE(STATUS ${current_file})
 #  MESSAGE(STATUS ${current_type})
 #
@@ -628,16 +628,16 @@ ADD_TEST(ioTvGDALImageIO_JPEG_99 ${IO_TESTS2}
 
 ADD_TEST(ioTuGDALOverviewsBuilder ${IO_TESTS2}
          otbGDALOverviewsBuilderNew)
-         
+
 ADD_TEST(ioTvGDALOverviewsBuilder_TIFF ${IO_TESTS2}
          otbGDALOverviewsBuilder
          ${TEMP}/ioTvGDALImageIO_Tiff_NoOption.tif
          4
          )
 SET_TESTS_PROPERTIES(ioTvGDALOverviewsBuilder_TIFF PROPERTIES DEPENDS ioTvGDALImageIO_Tiff_NoOption)
-         
-                  
-         
+
+
+
 
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ otbIOTests3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -955,14 +955,14 @@ ENDIF(OTB_DATA_USE_LARGEINPUT)
 
 
 IF(OTB_DATA_USE_LARGEINPUT OR OTB_DATA_USE_SPOTPHRINPUT OR OTB_DATA_USE_CNESPHRINPUT)
-  
+
   SET( GenericTestPHR_TESTNB 0)
-  
+
   FOREACH( current_file ${GenericTestPHR_DATA_INPUTS} )
     LIST(GET GenericTestPHR_DATA_TYPES   ${GenericTestPHR_TESTNB} current_type )
     MATH(EXPR GenericTestPHR_TESTNB "${GenericTestPHR_TESTNB} + 1")
-    
-      # Get and manipulate ImageKeywordlist 
+
+      # Get and manipulate ImageKeywordlist
       ADD_TEST(ioTvImageKeywordlist_${current_type} ${IO_TESTS4}
                --ignore-order --compare-n-ascii ${NOTOL} 2
                  ${BASELINE_FILES}/ioTvImageKeywordlist_${current_type}.txt
@@ -2079,7 +2079,7 @@ ADD_TEST(ioTvMultiResolutionReading0 ${IO_TESTS13}
       ${INPUTDATA}/bretagne.j2k?&resol=0
       ${TEMP}/ioTvMultiResolutionReading0.txt
       )
-     
+
 ADD_TEST(ioTvMultiResolutionReading3 ${IO_TESTS13}
   --compare-ascii ${NOTOL}  ${BASELINE_FILES}/ioTvMultiResolutionReading3.txt
                              ${TEMP}/ioTvMultiResolutionReading3.txt
@@ -2097,14 +2097,14 @@ ADD_TEST(ioTvMultiResolutionReadingInfo ${IO_TESTS13}
       ${INPUTDATA}/bretagne.j2k
       ${TEMP}/ioTvMultiResolutionReadingInfoOut.txt
       )
-      
+
 ADD_TEST(ioTvMultiResolutionReadingInfo_TIFF ${IO_TESTS13}
   --compare-ascii ${NOTOL}  ${BASELINE_FILES}/ioTvMultiResolutionReadingInfoOut_tiff.txt
                             ${TEMP}/ioTvMultiResolutionReadingInfoOut_tiff.txt
       otbMultiResolutionReadingInfo
       ${INPUTDATA}/maur_rgb.tif
       ${TEMP}/ioTvMultiResolutionReadingInfoOut_tiff.txt
-      )   
+      )
 
 IF(OTB_DATA_USE_LARGEINPUT)
     ADD_TEST(ioTvMultiResolutionReadingInfo_TIFF2 ${IO_TESTS13}
@@ -2113,7 +2113,7 @@ IF(OTB_DATA_USE_LARGEINPUT)
           otbMultiResolutionReadingInfo
           ${LARGEINPUT}/QUICKBIRD/TOULOUSE/000000128955_01_P001_MUL/02APR01105228-M1BS-000000128955_01_P001.TIF
           ${TEMP}/ioTvMultiResolutionReadingInfoOut_tiff2.txt
-          ) 
+          )
 ENDIF(OTB_DATA_USE_LARGEINPUT)
 
 # Tests which read data in JPEG2000 files.
@@ -2290,7 +2290,7 @@ FOREACH( current_file ${GenericTestPHR_DATA_INPUTS} )
   LIST(GET GenericTestPHR_DATA_TYPES   ${GenericTestPHR_TESTNB} current_type   )
   MATH(EXPR GenericTestPHR_TESTNB "${GenericTestPHR_TESTNB} + 1")
   STRING(REGEX MATCH "TIFF" PHR_TIFF_FILE ${current_type})
-  
+
   IF (NOT PHR_TIFF_FILE)
     # CanRead
     ADD_TEST(ioTuJ2KImageIOCanRead_${current_type} ${IO_TESTS13}
@@ -2298,7 +2298,7 @@ FOREACH( current_file ${GenericTestPHR_DATA_INPUTS} )
                 ${current_file}
             )
   ENDIF (NOT PHR_TIFF_FILE)
-    
+
     # Read info from the input file
     ADD_TEST(ioTvVectorImageReadingInfo_${current_type} ${IO_TESTS13}
              --compare-ascii ${NOTOL}  ${BASELINE_FILES}/ioTvMultiResolutionReading_${current_type}.txt
@@ -2318,9 +2318,9 @@ FOREACH( current_file ${GenericTestPHR_DATA_INPUTS} )
                 ${TEMP}/ioTvMultiResolutionReading_${current_type}_res5_OUT.txt
              )
   ENDIF (NOT PHR_TIFF_FILE)
-            
-  IF (NOT PHR_TIFF_FILE)          
-    # Extract resolution of input file        
+
+  IF (NOT PHR_TIFF_FILE)
+    # Extract resolution of input file
     ADD_TEST(ioTvMultiResolutionReadingInfo_${current_type} ${IO_TESTS13}
              --compare-ascii ${NOTOL}  ${BASELINE_FILES}/ioTvMultiResolutionReadingInfo_${current_type}.txt
                                        ${TEMP}/ioTvMultiResolutionReadingInfo_${current_type}_OUT.txt
@@ -2329,7 +2329,7 @@ FOREACH( current_file ${GenericTestPHR_DATA_INPUTS} )
                 ${TEMP}/ioTvMultiResolutionReadingInfo_${current_type}_OUT.txt
             )
 
-  
+
     # Decode an area inside one tile
     ADD_TEST(ioTvReaderWriterJP22TIF_${current_type}_1 ${COMMON_TESTS2}
 	         --compare-image ${EPSILON_9}  ${BASELINE}/ioTvJP22TIF_Extract_${current_type}_1.tif
@@ -2340,7 +2340,7 @@ FOREACH( current_file ${GenericTestPHR_DATA_INPUTS} )
                 -startX 256 -startY 512 -sizeX 256 -sizeY 128
                 -time
             )
-            
+
     # Decode an area which need 4 tiles
     ADD_TEST(ioTvReaderWriterJP22TIF_${current_type}_2 ${COMMON_TESTS2}
              --compare-image ${EPSILON_9}  ${BASELINE}/ioTvJP22TIF_Extract_${current_type}_2.tif
@@ -2351,8 +2351,8 @@ FOREACH( current_file ${GenericTestPHR_DATA_INPUTS} )
                 -startX 2000 -startY 2000 -sizeX 256 -sizeY 128
                 -time
             )
-            
-    # Decode the whole image with the lowest resolution (res=5) 
+
+    # Decode the whole image with the lowest resolution (res=5)
     # (take only one channel to put the file in baseline repository)
     ADD_TEST(ioTvReaderWriterJP22TIF_${current_type}_res5 ${COMMON_TESTS2}
              --compare-image ${EPSILON_9}  ${BASELINE}/ioTvJP22TIF_Extract_${current_type}_res5.tif
@@ -2364,7 +2364,7 @@ FOREACH( current_file ${GenericTestPHR_DATA_INPUTS} )
                 -time
          )
   ENDIF (NOT PHR_TIFF_FILE)
-                           
+
 ENDFOREACH()
 
 ENDIF(OTB_DATA_USE_LARGEINPUT OR OTB_DATA_USE_SPOTPHRINPUT OR OTB_DATA_USE_CNESPHRINPUT)
@@ -2837,7 +2837,7 @@ SET( GenericTestPHR_TESTNB 0)
 FOREACH( current_file ${GenericTestPHR_DATA_INPUTS} )
   LIST(GET GenericTestPHR_DATA_TYPES   ${GenericTestPHR_TESTNB} current_type   )
   MATH(EXPR GenericTestPHR_TESTNB "${GenericTestPHR_TESTNB} + 1")
-   
+
   ADD_TEST(ioTvImageMetadataInterfaceBaseTest_${current_type} ${IO_TESTS18}
            --compare-ascii ${NOTOL} ${BASELINE_FILES}/ioTvImageMetadataInterfaceBase_${current_type}.txt
                                     ${TEMP}/ioTvImageMetadataInterfaceBase_${current_type}_OUT.txt
@@ -3302,7 +3302,7 @@ ADD_TEST(ioTvMultiDatasetReading2 ${IO_TESTS22}
       ${INPUTDATA}/MOD09Q1G_EVI.A2006233.h07v03.005.2008338190308.hdf?&sdataidx=5
       ${TEMP}/ioTvMultiDatasetReading2.txt
       )
-      
+
 # Test to check behavior of function readerGDAL->GetSubDatasetInfo() which return info about subdataset.
 ADD_TEST(ioTvMultiDatasetReadingInfo ${IO_TESTS22}
   --compare-ascii ${NOTOL}  ${BASELINE_FILES}/ioTvMultiDatasetReadingInfo.txt
@@ -3686,7 +3686,7 @@ ADD_TEST(ioTvExtendedFilenameToReaderOptions_FullOptions ${IO_TESTS24}
         /home/data/filename.tif?&geom=/home/dev/custom.geom&sdataidx=2&resol=4&skipcarto=On
         ${TEMP}/ioTvExtendedFilenameToReaderOptions_FullOptions.txt
         )
-        
+
 ADD_TEST(ioTvExtendedFilenameToWriterOptions_NoOptions ${IO_TESTS24}
 --compare-ascii ${NOTOL}
          ${BASELINE}/ioTvExtendedFilenameToWriterOptions_NoOptions.txt
@@ -3704,7 +3704,7 @@ ADD_TEST(ioTvExtendedFilenameToWriterOptions_FullOptions ${IO_TESTS24}
         /home/data/filename.tif?&writegeom=ON&gdal:co:QUALITY=75&gdal:co:TILED=YES&gdal:co:BLOCKYSIZE=1024
         ${TEMP}/ioTvExtendedFilenameToWriterOptions_FullOptions.txt
         )
-        
+
 ADD_TEST(ioTvImageFileReaderExtendedFileName_GEOM ${IO_TESTS24}
 --compare-ascii ${NOTOL}
          ${BASELINE}/ioImageFileReaderWithExternalGEOMFile.txt
@@ -3712,7 +3712,7 @@ ADD_TEST(ioTvImageFileReaderExtendedFileName_GEOM ${IO_TESTS24}
 	otbImageFileReaderWithExtendedFilename
         ${INPUTDATA}/ToulouseExtract_WithGeom.tif?&geom=${INPUTDATA}/ToulouseExtract_ModifiedGeom.geom
         ${TEMP}/ioImageFileReaderWithExternalGEOMFile.txt
-        ${TEMP}/ioImageFileReaderWithExternalGEOMFile_pr.txt        
+        ${TEMP}/ioImageFileReaderWithExternalGEOMFile_pr.txt
         )
 
 ADD_TEST(ioTvImageFileReaderExtendedFileName_SkipPR ${IO_TESTS24}
@@ -3747,17 +3747,17 @@ ADD_TEST(ioTvImageFileReaderExtendedFileName_mix1 ${IO_TESTS24}
 
 ADD_TEST(ioTvImageFileWriterExtendedFileName_GEOM ${IO_TESTS24}
 --ignore-order --compare-ascii ${NOTOL}
-         ${INPUTDATA}/ToulouseExtract_WithGeom.geom         
+         ${INPUTDATA}/ToulouseExtract_WithGeom.geom
          ${TEMP}/ioImageFileWriterExtendedFileName_GEOM.geom
 --ignore-lines-with 2 ce90_absolute ce90_relative
 	otbImageFileWriterWithExtendedFilename
         ${INPUTDATA}/ToulouseExtract_WithGeom.tif
         ${TEMP}/ioImageFileWriterExtendedFileName_GEOM.tif?&writegeom=ON
         )
-        
+
 ADD_TEST(ioTvImageFileWriterExtendedFileName_gdalco ${IO_TESTS24}
 --compare-image ${NOTOL}
-         ${BASELINE}/ioTvGDALImageIO_JPEG_20.jpg      
+         ${BASELINE}/ioTvGDALImageIO_JPEG_20.jpg
          ${TEMP}/ioImageFileWriterExtendedFileName_gdalco.jpg
 	otbImageFileWriterWithExtendedFilename
         ${INPUTDATA}/maur_rgb_24bpp.tif
@@ -3810,8 +3810,17 @@ ENDFOREACH(streaming_sizemode)
 ENDFOREACH(streaming_type)
 
 
+#region size options test
+
+ADD_TEST(ioTvImageFileWriterExtendedFileName_RegionSize ${IO_TESTS24}
+#--compare-image ${NOTOL}
+ #        ${INPUTDATA}/maur_rgb_24bpp.tif
+  #       ${TEMP}/ioImageFileWriterExtendedFileName_streamingAuto.tif
+  otbImageFileWriterWithExtendedFilename
+        ${INPUTDATA}/maur_rgb_24bpp.tif
+        "${TEMP}/ioImageFileWriterExtendedFileName_regionSize.tif?&regionsize=0 0 10 10"
+        )
 
-        
 #----------------------------------------------------------------------------------
 SET(BasicIO_SRCS1
 otbIOTests1.cxx
-- 
GitLab