From 3ad682771ad89e8caab6b76410664b61ddaecdc9 Mon Sep 17 00:00:00 2001
From: Guillaume Pasero <guillaume.pasero@c-s.fr>
Date: Thu, 17 Nov 2016 16:55:29 +0100
Subject: [PATCH] ENH: remove code using JPEG2000ImageIO

---
 Modules/Core/ImageBase/test/CMakeLists.txt      | 17 -----------------
 .../IO/ImageIO/include/otbImageFileReader.txx   |  3 ---
 Modules/IO/ImageIO/otb-module.cmake             |  3 ---
 Modules/IO/ImageIO/src/CMakeLists.txt           |  1 -
 Modules/IO/ImageIO/src/otbImageIOFactory.cxx    |  7 -------
 5 files changed, 31 deletions(-)

diff --git a/Modules/Core/ImageBase/test/CMakeLists.txt b/Modules/Core/ImageBase/test/CMakeLists.txt
index 3d74d3d423..1c9c2b3054 100644
--- a/Modules/Core/ImageBase/test/CMakeLists.txt
+++ b/Modules/Core/ImageBase/test/CMakeLists.txt
@@ -650,23 +650,6 @@ otb_add_test(NAME   ioTvMultiChannelROI_p1_06_JPEG2000_2_TIF_res0 COMMAND otbIma
   ${TEMP}/ioExtractROI_JPEG2K_2_TIF_p1_06_OUT.tif
   )
 
-# Only do the following test if we are using the OTB Openjpeg driver,
-# because gdal does not report jpeg2000 overview with size < 128
-# pixel, and will therefore interpolate.
-if(OTB_USE_OPENJPEG)
-
-# Read an area inside one tile at resolution 4 (jpeg2000 conformance file with
-# specific tile size at different resolution).
-otb_add_test(NAME   ioTvMultiChannelROI_p1_06_JPEG2000_2_TIF_res4 COMMAND otbImageBaseTestDriver
-  --compare-image ${EPSILON_9}   ${BASELINE}/ioExtractROI_JPEG2K_2_TIF_p1_06_res4.tif
-  ${TEMP}/ioExtractROI_JPEG2K_2_TIF_p1_06_res4_OUT.tif
-  otbMultiChannelExtractROI
-  ${INPUTDATA}/jpeg2000_conf_p1_06.j2k?&resol=4
-  ${TEMP}/ioExtractROI_JPEG2K_2_TIF_p1_06_res4_OUT.tif
-  )
-
-endif()
-
 # Read an area inside one tile at resolution 0 (quite similar coding parameter with pleiade
 # except it a lossless image with no quatization style).
 otb_add_test(NAME   ioTvMultiChannelROI_lena_JPEG2000_2_TIF_res0 COMMAND otbImageBaseTestDriver
diff --git a/Modules/IO/ImageIO/include/otbImageFileReader.txx b/Modules/IO/ImageIO/include/otbImageFileReader.txx
index 141f5f7f7d..e3db0c8507 100644
--- a/Modules/IO/ImageIO/include/otbImageFileReader.txx
+++ b/Modules/IO/ImageIO/include/otbImageFileReader.txx
@@ -342,9 +342,6 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
     itk::EncapsulateMetaData<unsigned int>(dict, MetaDataKey::ResolutionFactor, m_AdditionalNumber);
     }
 
-  // This value is used by JPEG2000ImageIO and not by the others ImageIO
-  itk::EncapsulateMetaData<unsigned int>(dict, MetaDataKey::CacheSizeInBytes, 135000000);
-
   // Got to allocate space for the image. Determine the characteristics of
   // the image.
   //
diff --git a/Modules/IO/ImageIO/otb-module.cmake b/Modules/IO/ImageIO/otb-module.cmake
index 8c0a036c83..70df4300da 100644
--- a/Modules/IO/ImageIO/otb-module.cmake
+++ b/Modules/IO/ImageIO/otb-module.cmake
@@ -20,9 +20,6 @@ otb_module(OTBImageIO
     OTBObjectList
     OTBStreaming
 
-  OPTIONAL_DEPENDS
-    OTBIOJPEG2000
-
   TEST_DEPENDS
     OTBStatistics
     OTBTestKernel
diff --git a/Modules/IO/ImageIO/src/CMakeLists.txt b/Modules/IO/ImageIO/src/CMakeLists.txt
index 96b6e61df9..6c3889d4e4 100644
--- a/Modules/IO/ImageIO/src/CMakeLists.txt
+++ b/Modules/IO/ImageIO/src/CMakeLists.txt
@@ -6,7 +6,6 @@ add_library(OTBImageIO ${OTBImageIO_SRC})
 target_link_libraries(OTBImageIO 
   ${OTBIORAD_LIBRARIES}
   ${OTBIOONERA_LIBRARIES}
-  ${OTBIOJPEG2000_LIBRARIES}
   ${OTBIOLUM_LIBRARIES}
   ${OTBImageBase_LIBRARIES}
   ${OTBIOMW_LIBRARIES}
diff --git a/Modules/IO/ImageIO/src/otbImageIOFactory.cxx b/Modules/IO/ImageIO/src/otbImageIOFactory.cxx
index ab57012270..721e47228a 100644
--- a/Modules/IO/ImageIO/src/otbImageIOFactory.cxx
+++ b/Modules/IO/ImageIO/src/otbImageIOFactory.cxx
@@ -31,10 +31,6 @@
 #include "otbRADImageIOFactory.h"
 #include "otbMWImageIOFactory.h"
 
-#ifdef OTB_USE_OPENJPEG
-#include "otbJPEG2000ImageIOFactory.h"
-#endif
-
 #include "otbTileMapImageIOFactory.h"
 
 namespace otb
@@ -100,9 +96,6 @@ ImageIOFactory::RegisterBuiltInFactories()
       itk::ObjectFactoryBase::RegisterFactory(RADImageIOFactory::New());
       itk::ObjectFactoryBase::RegisterFactory(BSQImageIOFactory::New());
       itk::ObjectFactoryBase::RegisterFactory(LUMImageIOFactory::New());
-#ifdef OTB_USE_OPENJPEG
-      itk::ObjectFactoryBase::RegisterFactory(JPEG2000ImageIOFactory::New());
-#endif
       itk::ObjectFactoryBase::RegisterFactory(TileMapImageIOFactory::New());
       itk::ObjectFactoryBase::RegisterFactory(GDALImageIOFactory::New());
       itk::ObjectFactoryBase::RegisterFactory(MWImageIOFactory::New());
-- 
GitLab