diff --git a/CMakeLists.txt b/CMakeLists.txt index d3955b02f9de0198e2ffc1023c152099cf87a936..966040d342cbe72e267ad1cbdb446a37b8ef9a4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -324,6 +324,13 @@ IF(OTB_DATA_USE_LARGEINPUT) MARK_AS_ADVANCED(OTB_DATA_LARGEINPUT_ROOT) ENDIF(OTB_DATA_USE_LARGEINPUT) +OPTION(OTB_DATA_USE_SPOTPHRINPUT "Use PHR data provided by SPOT." OFF) +MARK_AS_ADVANCED(OTB_DATA_USE_SPOTPHRINPUT) +IF(OTB_DATA_USE_SPOTPHRINPUT) + FIND_PATH(OTB_DATA_SPOTPHRINPUT_ROOT OTB_PHR_Data.readme $ENV{OTB_DATA_SPOTPHRINPUT_ROOT}) + MARK_AS_ADVANCED(OTB_DATA_SPOTPHRINPUT_ROOT) +ENDIF(OTB_DATA_USE_SPOTPHRINPUT) + #----------------------------------------------------------------------------- # Configure files with settings for use by the build diff --git a/Testing/CMakeLists.txt b/Testing/CMakeLists.txt index 62df7c35140f62c4a1c442960f9f7de4619557b5..d360ab7f90195cf03cacde3030a6b45a3ac3a011 100644 --- a/Testing/CMakeLists.txt +++ b/Testing/CMakeLists.txt @@ -49,6 +49,13 @@ ELSE(OTB_BINARY_DIR) FIND_PATH(OTB_DATA_LARGEINPUT_ROOT OTBData.readme $ENV{OTB_DATA_LARGEINPUT_ROOT}) MARK_AS_ADVANCED(OTB_DATA_LARGEINPUT_ROOT) ENDIF(OTB_DATA_USE_LARGEINPUT) + + OPTION(OTB_DATA_USE_SPOTPHRINPUT "Use PHR data provided by SPOT." OFF) + MARK_AS_ADVANCED(OTB_DATA_USE_SPOTPHRINPUT) + IF(OTB_DATA_USE_SPOTPHRINPUT) + FIND_PATH(OTB_DATA_SPOTPHRINPUT_ROOT OTB_PHR_Data.readme $ENV{OTB_DATA_SPOTPHRINPUT_ROOT}) + MARK_AS_ADVANCED(OTB_DATA_SPOTPHRINPUT_ROOT) + ENDIF(OTB_DATA_USE_SPOTPHRINPUT) INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/TestingHelper.cmake) diff --git a/Testing/Code/IO/CMakeLists.txt b/Testing/Code/IO/CMakeLists.txt index c912c7c24ae692baac2e94ad4a8f91ad5a3fa058..8fea7a7554dd3bd4df12fc48f49ca1b5da4f364e 100644 --- a/Testing/Code/IO/CMakeLists.txt +++ b/Testing/Code/IO/CMakeLists.txt @@ -2,6 +2,10 @@ IF( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING ) +IF(OTB_DATA_USE_SPOTPHRINPUT) + SET(SPOTPHRINPUT ${OTB_DATA_SPOTPHRINPUT_ROOT} ) +ENDIF(OTB_DATA_USE_SPOTPHRINPUT) + SET(COMMON_TESTS2 ${CXX_TEST_PATH}/otbCommonTests2) SET(COMMON_TESTS3 ${CXX_TEST_PATH}/otbCommonTests3) SET(IO_TESTS1 ${CXX_TEST_PATH}/otbIOTests1) @@ -43,6 +47,30 @@ IF(CHECK_GDAL_BUILDED_WITH_HDF) ENDIF(CHECK_GDAL_BUILDED_WITH_HDF) SET(IO_TESTS23 ${CXX_TEST_PATH}/otbIOTests23) + + +IF(OTB_DATA_USE_SPOTPHRINPUT) + + SET(GenericTestPHR_SPOT_DATA_INPUTS + ${SPOTPHRINPUT}/ORTHO_UTM_BUNDLE/IMG_PHR1A_P_001/IMG_PHR1A_P_201006181052297_ORT_IPU_20120221_8798-001_R1C1.JP2 + ${SPOTPHRINPUT}/ORTHO_UTM_BUNDLE/IMG_PHR1A_MS_002/IMG_PHR1A_MS_201006181052297_ORT_IPU_20120221_8798-002_R1C1.JP2 + ${SPOTPHRINPUT}/PRIMARY_BUNDLE/IMG_PHR1A_P_001/IMG_PHR1A_P_201006181052297_SEN_IPU_20120221_8686-001_R1C1.JP2 + ${SPOTPHRINPUT}/PRIMARY_BUNDLE/IMG_PHR1A_MS_002/IMG_PHR1A_MS_201006181052297_SEN_IPU_20120221_8686-002_R1C1.JP2 + ${SPOTPHRINPUT}/ORTHO_GEOGRAPHIC_BUNDLE/IMG_PHR1A_P_001/IMG_PHR1A_P_201006181052297_ORT_IPU_20120221_8718-001_R1C1.JP2 + ${SPOTPHRINPUT}/ORTHO_GEOGRAPHIC_BUNDLE/IMG_PHR1A_MS_002/IMG_PHR1A_MS_201006181052297_ORT_IPU_20120221_8718-002_R1C1.JP2 + ) + + SET(GenericTestPHR_SPOT_DATA_TYPES + ORTHO_UTM_P + ORTHO_UTM_MS + ORTHO_GEO_P + ORTHO_GEO_MS + PRIMARY_MS + PRIMARY_P + ) + +ENDIF(OTB_DATA_USE_SPOTPHRINPUT) + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ COMMON_TESTS3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -605,6 +633,32 @@ ADD_TEST(ioTvImageKeywordlistPleiades ${IO_TESTS4} ${TEMP}/ioTvImageKeywordlistPleiades_saveState_loadState.txt ) +IF(OTB_DATA_USE_SPOTPHRINPUT) + + SET( GenericTestPHR_TESTNB 0) + + FOREACH( current_file ${GenericTestPHR_SPOT_DATA_INPUTS} ) + LIST(GET GenericTestPHR_SPOT_DATA_TYPES ${GenericTestPHR_TESTNB} current_type ) + MATH(EXPR GenericTestPHR_TESTNB "${GenericTestPHR_TESTNB} + 1") + + # Get and manipulate ImageKeywordlist + ADD_TEST(ioTvImageKeywordlist_SPOT_PHR_${current_type} ${IO_TESTS4} + --ignore-order --compare-n-ascii ${NOTOL} 2 + ${BASELINE_FILES}/ioTvImageKeywordlist_SPOT_PHR_${current_type}.txt + ${TEMP}/ioTvImageKeywordlist_SPOT_PHR_${current_type}_OUT.txt + ${BASELINE_FILES}/ioTvImageKeywordlist_SPOT_PHR_${current_type}.txt + ${TEMP}/ioTvImageKeywordlist_SPOT_PHR_${current_type}_saveState_loadState_OUT.txt + --ignore-lines-with 2 meters_per_pixel_x meters_per_pixel_y + otbImageKeywordlist + ${current_file} + ${TEMP}/ioTvImageKeywordlist_SPOT_PHR_${current_type}_OUT.txt + ${TEMP}/ioTvImageKeywordlist_SPOT_PHR_${current_type}_saveState_loadState_OUT.txt + ) + + ENDFOREACH() + +ENDIF(OTB_DATA_USE_SPOTPHRINPUT) + ADD_TEST(ioTvImageKeywordlistIkonos ${IO_TESTS4} --ignore-order --compare-n-ascii ${NOTOL} 2 ${BASELINE_FILES}/ioTvImageKeywordlistIkonos.txt @@ -1930,16 +1984,6 @@ ADD_TEST(ioTvImageFileReaderWriterJP22TIF ${IO_TESTS2} ) ENDIF(OTB_DATA_USE_LARGEINPUT) - - -# --- JPEG2000 can write --- -# FIXME Desactivated until http://bugs.orfeo-toolbox.org/view.php?id=104 -# is solved -# ADD_TEST(ioTuJPEG2000ImageIOCanWrite ${IO_TESTS13} -# otbJPEG2000ImageIOTestCanWrite -# ${TEMP}/toto.j2k -# ) - # New test suite: IF(OTB_DATA_USE_LARGEINPUT) # Decode an area inside one tile @@ -2255,6 +2299,84 @@ ADD_TEST(ioTvJPEG2000ImageIO_CacheSize_25000 ${IO_TESTS13} ${INPUTDATA}/bretagne.j2k ${TEMP}/ioClassicalQLJPEG2K_bretagne_OUT.tif) + +IF(OTB_DATA_USE_SPOTPHRINPUT) + SET( GenericTestPHR_TESTNB 0) + +FOREACH( current_file ${GenericTestPHR_SPOT_DATA_INPUTS} ) + LIST(GET GenericTestPHR_SPOT_DATA_TYPES ${GenericTestPHR_TESTNB} current_type ) + MATH(EXPR GenericTestPHR_TESTNB "${GenericTestPHR_TESTNB} + 1") + # CanRead + ADD_TEST(ioTuJ2KImageIOCanRead_SPOT_PHR_${current_type} ${IO_TESTS13} + otbJPEG2000ImageIOTestCanRead + ${current_file} + ) + + # Read info from the input file + ADD_TEST(ioTvVectorImageReadingInfo_SPOT_PHR_${current_type} ${IO_TESTS13} + --compare-ascii ${NOTOL} ${BASELINE_FILES}/ioTvMultiResolutionReading_${current_type}.txt + ${TEMP}/ioTvMultiResolutionReading_${current_type}_OUT.txt + otbVectorImageLegacyTest + ${current_file} + ${TEMP}/ioTvMultiResolutionReading_${current_type}_OUT.txt + 0 + ) + + # Read info from the input file (res=5) + ADD_TEST(ioTvVectorImageReadingInfo_SPOT_PHR_${current_type}_res5 ${IO_TESTS13} + --compare-ascii ${NOTOL} ${BASELINE_FILES}/ioTvMultiResolutionReading_${current_type}_res5.txt + ${TEMP}/ioTvMultiResolutionReading_${current_type}_res5_OUT.txt + otbVectorImageLegacyTest + ${current_file} + ${TEMP}/ioTvMultiResolutionReading_${current_type}_res5_OUT.txt + 5 + ) + + # Extract resolution of input file + ADD_TEST(ioTvMultiResolutionReadingInfo_SPOT_PHR_${current_type} ${IO_TESTS13} + --compare-ascii ${NOTOL} ${BASELINE_FILES}/ioTvMultiResolutionReadingInfo_${current_type}.txt + ${TEMP}/ioTvMultiResolutionReadingInfo_${current_type}_OUT.txt + otbMultiResolutionReadingInfo + ${current_file} + ${TEMP}/ioTvMultiResolutionReadingInfo_OUT.txt + ) + + # Decode an area inside one tile + ADD_TEST(ioTvReaderWriterJP22TIF_SPOT_PHR_${current_type}_1 ${COMMON_TESTS2} + --compare-image ${EPSILON_9} ${BASELINE}/ioTvJP22TIF_Extract_SPOT_PHR_${current_type}_1.tif + ${TEMP}/ioTvJP22TIF_Extract_SPOT_PHR_${current_type}_1_OUT.tif + otbMultiChannelExtractROI + ${current_file} + ${TEMP}/ioTvJP22TIF_Extract_SPOT_PHR_${current_type}_1_OUT.tif + -startX 512 -startY 1024 -sizeX 256 -sizeY 128 + -time + ) + + # Decode an area which need 4 tiles + ADD_TEST(ioTvReaderWriterJP22TIF_SPOT_PHR_${current_type}_2 ${COMMON_TESTS2} + --compare-image ${EPSILON_9} ${BASELINE}/ioTvJP22TIF_Extract_SPOT_PHR_${current_type}_2.tif + ${TEMP}/ioTvJP22TIF_Extract_SPOT_PHR_${current_type}_2_OUT.tif + otbMultiChannelExtractROI + ${current_file} + ${TEMP}/ioTvJP22TIF_Extract_SPOT_PHR_${current_type}_2_OUT.tif + -startX 2000 -startY 2000 -sizeX 256 -sizeY 128 + -time + ) + + # Decode the whole image with the lowest resolution (res=5) + ADD_TEST(ioTvReaderWriterJP22TIF_SPOT_PHR_${current_type}_res5 ${COMMON_TESTS2} + --compare-image ${EPSILON_9} ${BASELINE}/ioTvJP22TIF_Extract_SPOT_PHR_${current_type}_res5.tif + ${TEMP}/ioTvJP22TIF_Extract_SPOT_PHR_${current_type}_res5_OUT.tif + otbMultiChannelExtractROI + ${current_file}:5 + ${TEMP}/ioTvJP22TIF_Extract_SPOT_PHR_${current_type}_res5_OUT.tif + -time + ) + +ENDFOREACH() + +ENDIF(OTB_DATA_USE_SPOTPHRINPUT) + ENDIF(OTB_USE_JPEG2000) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/Testing/Code/IO/otbIOTests13.cxx b/Testing/Code/IO/otbIOTests13.cxx index eb2d57286b1f3319b1cfcc0471ed7a8c84edfbae..85e6958853ed01cb87d30ee176cbbd4394962acf 100644 --- a/Testing/Code/IO/otbIOTests13.cxx +++ b/Testing/Code/IO/otbIOTests13.cxx @@ -28,5 +28,6 @@ void RegisterTests() REGISTER_TEST(otbJPEG2000ImageIOTestCanWrite); REGISTER_TEST(otbMultiResolutionReadingInfo); REGISTER_TEST(otbVectorImageTest); + REGISTER_TEST(otbVectorImageLegacyTest); REGISTER_TEST(otbGenerateClassicalQLWithJPEG2000); } diff --git a/Testing/Code/IO/otbVectorImageTest.cxx b/Testing/Code/IO/otbVectorImageTest.cxx index 188be9db87bc54fb809bdfdc266f073825294dc0..1ecf33df20811bdc64c98181f42827272e634f45 100644 --- a/Testing/Code/IO/otbVectorImageTest.cxx +++ b/Testing/Code/IO/otbVectorImageTest.cxx @@ -30,30 +30,40 @@ int otbVectorImageLegacyTest(int argc, char* argv[]) { // Verify the number of parameters in the command line + if (argc < 3) + { + std::cout << argv[0] << "<image> <output information> [dataset number]" << std::endl; + return EXIT_FAILURE; + } + const char * inputFilename = argv[1]; const char * outputAsciiFilename = argv[2]; - // unsigned int GCPnum((unsigned int)::atoi(argv[2])); + int addNumber = -1; + if (argc > 3) + { + addNumber = atoi(argv[3]); + } typedef unsigned char InputPixelType; const unsigned int Dimension = 2; - - std::ofstream file; - - file.open(outputAsciiFilename); - typedef otb::VectorImage<InputPixelType, Dimension> InputImageType; - InputImageType::Pointer image = InputImageType::New(); - typedef otb::ImageFileReader<InputImageType> ReaderType; - ReaderType::Pointer reader = ReaderType::New(); reader->SetFileName(inputFilename); + if (addNumber != -1) + { + reader->SetAdditionalNumber(addNumber); + } reader->UpdateOutputInformation(); + InputImageType::Pointer image = InputImageType::New(); image = reader->GetOutput(); + std::ofstream file; + file.open(outputAsciiFilename); + std::cout << "------ IMAGE --------" << std::endl; std::cout << image << std::endl; std::cout << "---------------------" << std::endl;