diff --git a/Examples/Projections/test/CMakeLists.txt b/Examples/Projections/test/CMakeLists.txt index fad74a593fa3d4bde04cde96b541e4be13827c86..7964d8655050eabe8f3b030ed237203666fa915a 100644 --- a/Examples/Projections/test/CMakeLists.txt +++ b/Examples/Projections/test/CMakeLists.txt @@ -68,7 +68,7 @@ otb_add_test(NAME prTeEstimateRPCSensorModelExampleTest COMMAND ${OTB_TEST_DRIVE --compare-ascii ${EPSILON_4} ${BASELINE}/otbGCPsToRPCSensorModelImageFilterWithoutDEMOutput.txt ${TEMP}/otbGCPsToRPCSensorModelImageFilterWithoutDEMOutput.txt - --ignore-lines-with 5 PipelineMTime ImportImageContaine Source: Image Time: + --ignore-lines-with 6 PipelineMTime ImportImageContaine Source: Image Time: Pointer: Execute $<TARGET_FILE:EstimateRPCSensorModelExample> LARGEINPUT{SPOT4/RIO_DE_JANEIRO/IMAG_01.DAT} ${TEMP}/otbGCPsToRPCSensorModelImageFilterWithoutDEMOutput.txt diff --git a/Modules/Applications/AppSARDecompositions/CMakeLists.txt b/Modules/Applications/AppSARDecompositions/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..aa7832f8f44840a95e5ac6bfdbcddee53ade5a7c --- /dev/null +++ b/Modules/Applications/AppSARDecompositions/CMakeLists.txt @@ -0,0 +1,2 @@ +project(OTBAppSARDecompositions) +otb_module_impl() diff --git a/Modules/Applications/AppSARDecompositions/app/CMakeLists.txt b/Modules/Applications/AppSARDecompositions/app/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..d311a3c7e5755cf7de35c79e054dd6c0164c5316 --- /dev/null +++ b/Modules/Applications/AppSARDecompositions/app/CMakeLists.txt @@ -0,0 +1,12 @@ +set(OTBAppFiltering_LINK_LIBS + ${OTBPolarimetry_LIBRARIES} + ${OTBImageManipulation_LIBRARIES} + ${OTBApplicationEngine_LIBRARIES} + ${OTBImageBase_LIBRARIES} +) + +otb_create_application( + NAME SARDecompositions + SOURCES otbSARDecompositions.cxx + LINK_LIBRARIES ${${otb-module}_LIBRARIES}) + diff --git a/Modules/Applications/AppSARDecompositions/app/otbSARDecompositions.cxx b/Modules/Applications/AppSARDecompositions/app/otbSARDecompositions.cxx new file mode 100644 index 0000000000000000000000000000000000000000..a159356f4a076b53fb2923877b050aab9ff11276 --- /dev/null +++ b/Modules/Applications/AppSARDecompositions/app/otbSARDecompositions.cxx @@ -0,0 +1,189 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ +#include "otbWrapperApplication.h" +#include "otbWrapperApplicationFactory.h" + + +#include "otbReciprocalHAlphaImageFilter.h" +#include "otbSinclairReciprocalImageFilter.h" +#include "otbSinclairToReciprocalCoherencyMatrixFunctor.h" +#include "otbPerBandVectorImageFilter.h" +#include "itkMeanImageFilter.h" + + +namespace otb +{ +namespace Wrapper +{ + +class SARDecompositions : public Application +{ +public: + /** Standard class typedefs. */ + typedef SARDecompositions Self; + typedef Application Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + + + typedef otb::Functor::SinclairToReciprocalCoherencyMatrixFunctor<ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleVectorImageType::PixelType> FunctorType; + + + typedef SinclairReciprocalImageFilter<ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleVectorImageType, + FunctorType > SRFilterType; + + + typedef otb::ReciprocalHAlphaImageFilter<ComplexDoubleVectorImageType, DoubleVectorImageType> HAFilterType; + + + typedef itk::MeanImageFilter<ComplexDoubleImageType, ComplexDoubleImageType> MeanFilterType; + typedef otb::PerBandVectorImageFilter<ComplexDoubleVectorImageType, ComplexDoubleVectorImageType, MeanFilterType> PerBandMeanFilterType; + //FloatImageType + + /** Standard macro */ + itkNewMacro(Self); + + itkTypeMacro(SARDecompositions, otb::Application); + +private: + void DoInit() + { + SetName("SARDecompositions"); + SetDescription("From one-band complex images (each one related to an element of the Sinclair matrix), returns the selected decomposition."); + + // Documentation + SetDocName("SARDecompositions"); + SetDocLongDescription("From one-band complex images (HH, HV, VH, VV), returns the selected decomposition.\n \n" + "The H-alpha-A decomposition is currently the only one available; it is implemented for the monostatic case (transmitter and receiver are co-located).\n" + "User must provide three one-band complex images HH, HV or VH, and VV (monostatic case <=> HV = VH).\n" + "The H-alpha-A decomposition consists in averaging 3x3 complex coherency matrices (incoherent analysis); the user must provide the size of the averaging window, thanks to the parameter inco.kernelsize.\n " + "The applications returns a float vector image, made up of three channels : H (entropy), Alpha, A (Anisotropy)." ); + + + + SetDocLimitations("None"); + SetDocAuthors("OTB-Team"); + SetDocSeeAlso("SARPolarMatrixConvert, SARPolarSynth"); + + AddDocTag(Tags::SAR); + + AddParameter(ParameterType_ComplexInputImage, "inhh", "Input Image"); + SetParameterDescription("inhh", "Input image (HH)"); + + AddParameter(ParameterType_ComplexInputImage, "inhv", "Input Image"); + SetParameterDescription("inhv", "Input image (HV)"); + MandatoryOff("inhv"); + + AddParameter(ParameterType_ComplexInputImage, "invh", "Input Image"); + SetParameterDescription("invh", "Input image (VH)"); + MandatoryOff("invh"); + + AddParameter(ParameterType_ComplexInputImage, "invv", "Input Image"); + SetParameterDescription("invv", "Input image (VV)"); + + AddParameter(ParameterType_OutputImage, "out", "Output Image"); + SetParameterDescription("out", "Output image"); + + AddParameter(ParameterType_Choice, "decomp", "Decompositions"); + AddChoice("decomp.haa","H-alpha-A decomposition"); + SetParameterDescription("decomp.haa","H-alpha-A decomposition"); + + AddParameter(ParameterType_Group,"inco","Incoherent decompositions"); + SetParameterDescription("inco","This group allows to set parameters related to the incoherent decompositions."); + + AddParameter(ParameterType_Int, "inco.kernelsize", "Kernel size for spatial incoherent averaging."); + SetParameterDescription("inco.kernelsize", "Minute (0-59)"); + SetMinimumParameterIntValue("inco.kernelsize", 1); + SetDefaultParameterInt("inco.kernelsize", 3); + MandatoryOff("inco.kernelsize"); + + AddRAMParameter(); + + // Default values + SetDefaultParameterInt("decomp", 0); // H-alpha-A + + // Doc example parameter settings + SetDocExampleParameterValue("inhh", "HH.tif"); + SetDocExampleParameterValue("invh", "VH.tif"); + SetDocExampleParameterValue("invv", "VV.tif"); + SetDocExampleParameterValue("decomp", "haa"); + SetDocExampleParameterValue("out", "HaA.tif"); + } + + void DoUpdateParameters() + { + // Nothing to do here : all parameters are independent + } + + void DoExecute() + { + + bool inhv = HasUserValue("inhv"); + bool invh = HasUserValue("invh"); + + if ( (!inhv) && (!invh) ) + otbAppLogFATAL( << "Parameter inhv or invh not set. Please provide a HV or a VH complex image."); + + switch (GetParameterInt("decomp")) + { + case 0: // H-alpha-A + + m_SRFilter = SRFilterType::New(); + m_HAFilter = HAFilterType::New(); + m_MeanFilter = PerBandMeanFilterType::New(); + + if (inhv) + m_SRFilter->SetInputHV_VH(GetParameterComplexDoubleImage("inhv")); + else if (invh) + m_SRFilter->SetInputHV_VH(GetParameterComplexDoubleImage("invh")); + + m_SRFilter->SetInputHH(GetParameterComplexDoubleImage("inhh")); + m_SRFilter->SetInputVV(GetParameterComplexDoubleImage("invv")); + + MeanFilterType::InputSizeType radius; + radius.Fill( GetParameterInt("inco.kernelsize") ); + m_MeanFilter->GetFilter()->SetRadius(radius); + + + m_MeanFilter->SetInput(m_SRFilter->GetOutput()); + m_HAFilter->SetInput(m_MeanFilter->GetOutput()); + SetParameterOutputImage("out", m_HAFilter->GetOutput() ); + + break; + } + + } + + //MCPSFilterType::Pointer m_MCPSFilter; + SRFilterType::Pointer m_SRFilter; + HAFilterType::Pointer m_HAFilter; + PerBandMeanFilterType::Pointer m_MeanFilter; + +}; + +} //end namespace Wrapper +} //end namespace otb + +OTB_APPLICATION_EXPORT(otb::Wrapper::SARDecompositions) diff --git a/Modules/Applications/AppSARDecompositions/otb-module.cmake b/Modules/Applications/AppSARDecompositions/otb-module.cmake new file mode 100644 index 0000000000000000000000000000000000000000..71303c803d5d707c9918ec8b578e89a204cc53b6 --- /dev/null +++ b/Modules/Applications/AppSARDecompositions/otb-module.cmake @@ -0,0 +1,17 @@ +set(DOCUMENTATION "Basic filters application.") + +otb_module(OTBAppSARDecompositions + DEPENDS + OTBPolarimetry + OTBImageManipulation + OTBITK + OTBApplicationEngine + OTBImageBase + + TEST_DEPENDS + OTBTestKernel + OTBCommandLine + + DESCRIPTION + "${DOCUMENTATION}" +) diff --git a/Modules/Applications/AppSARDecompositions/test/CMakeLists.txt b/Modules/Applications/AppSARDecompositions/test/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..b99fa48fe8d6b2fea3afa6ab5a63b21228496094 --- /dev/null +++ b/Modules/Applications/AppSARDecompositions/test/CMakeLists.txt @@ -0,0 +1,14 @@ +otb_module_test() +#----------- SARDecompositions TESTS ---------------- + +otb_test_application(NAME apTvSARDecompositions + APP SARDecompositions + OPTIONS + -inhh ${INPUTDATA}/RSAT_imageryC_HH.tif + -inhv ${INPUTDATA}/RSAT_imageryC_HV.tif + -invv ${INPUTDATA}/RSAT_imageryC_VV.tif + -decomp haa + -out ${TEMP}/apTvReciprocalHAlpha.tif + + ) + diff --git a/Modules/Applications/AppSARPolarMatrixConvert/CMakeLists.txt b/Modules/Applications/AppSARPolarMatrixConvert/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..b20d3ebc6c81733b0ce1f5738dca23a6ff522139 --- /dev/null +++ b/Modules/Applications/AppSARPolarMatrixConvert/CMakeLists.txt @@ -0,0 +1,2 @@ +project(OTBAppSARPolarMatrixConvert) +otb_module_impl() diff --git a/Modules/Applications/AppSARPolarMatrixConvert/app/CMakeLists.txt b/Modules/Applications/AppSARPolarMatrixConvert/app/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..81426caca5d49ecef97df614ebc0214cd79bd008 --- /dev/null +++ b/Modules/Applications/AppSARPolarMatrixConvert/app/CMakeLists.txt @@ -0,0 +1,12 @@ +set(OTBAppFiltering_LINK_LIBS + ${OTBPolarimetry_LIBRARIES} + ${OTBImageManipulation_LIBRARIES} + ${OTBApplicationEngine_LIBRARIES} + ${OTBImageBase_LIBRARIES} +) + +otb_create_application( + NAME SARPolarMatrixConvert + SOURCES otbSARPolarMatrixConvert.cxx + LINK_LIBRARIES ${${otb-module}_LIBRARIES}) + diff --git a/Modules/Applications/AppSARPolarMatrixConvert/app/otbSARPolarMatrixConvert.cxx b/Modules/Applications/AppSARPolarMatrixConvert/app/otbSARPolarMatrixConvert.cxx new file mode 100644 index 0000000000000000000000000000000000000000..c670aabb0e2c2273daf5749368cd419142079b81 --- /dev/null +++ b/Modules/Applications/AppSARPolarMatrixConvert/app/otbSARPolarMatrixConvert.cxx @@ -0,0 +1,709 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ +#include "otbWrapperApplication.h" +#include "otbWrapperApplicationFactory.h" + + + + + +//monostatic case +#include "otbSinclairReciprocalImageFilter.h" +#include "otbSinclairToReciprocalCoherencyMatrixFunctor.h" +#include "otbSinclairToReciprocalCovarianceMatrixFunctor.h" +#include "otbSinclairToReciprocalCircularCovarianceMatrixFunctor.h" + +#include "otbReciprocalCoherencyToReciprocalMuellerImageFilter.h" +#include "otbReciprocalCovarianceToCoherencyDegreeImageFilter.h" +#include "otbReciprocalCovarianceToReciprocalCoherencyImageFilter.h" +#include "otbReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter.h" + + +//bistatic case +#include "otbSinclairImageFilter.h" +#include "otbSinclairToCoherencyMatrixFunctor.h" +#include "otbSinclairToCovarianceMatrixFunctor.h" +#include "otbSinclairToCircularCovarianceMatrixFunctor.h" +#include "otbSinclairToMuellerMatrixFunctor.h" + +#include "otbMuellerToReciprocalCovarianceImageFilter.h" +#include "otbMuellerToPolarisationDegreeAndPowerImageFilter.h" + + + + + + +namespace otb +{ +namespace Wrapper +{ + +class SARPolarMatrixConvert : public Application +{ +public: + /** Standard class typedefs. */ + typedef SARPolarMatrixConvert Self; + typedef Application Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + + //Monostatic case + typedef otb::Functor::SinclairToReciprocalCoherencyMatrixFunctor<ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleVectorImageType::PixelType> RCoherencyFunctorType; + + typedef otb::Functor::SinclairToReciprocalCovarianceMatrixFunctor<ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleVectorImageType::PixelType> RCovarianceFunctorType; + + typedef otb::Functor::SinclairToReciprocalCircularCovarianceMatrixFunctor<ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleVectorImageType::PixelType> RCircularCovarianceFunctorType; + + + typedef SinclairReciprocalImageFilter<ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleVectorImageType, + RCoherencyFunctorType > RCohSRFilterType; + + + typedef SinclairReciprocalImageFilter<ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleVectorImageType, + RCovarianceFunctorType > RCovSRFilterType; + + typedef SinclairReciprocalImageFilter<ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleVectorImageType, + RCircularCovarianceFunctorType > RCCSRFilterType; + + + typedef otb::ReciprocalCoherencyToReciprocalMuellerImageFilter<ComplexDoubleVectorImageType, DoubleVectorImageType> RCRMFilterType; + + typedef otb::ReciprocalCovarianceToCoherencyDegreeImageFilter<ComplexDoubleVectorImageType, ComplexDoubleVectorImageType> RCCDFilterType; + + typedef otb::ReciprocalCovarianceToReciprocalCoherencyImageFilter<ComplexDoubleVectorImageType, ComplexDoubleVectorImageType> RCRCFilterType; + + typedef otb::ReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter<ComplexDoubleVectorImageType, ComplexDoubleVectorImageType> RLCRCCFilterType; + + + //Bistatic case + typedef otb::Functor::SinclairToCoherencyMatrixFunctor<ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleVectorImageType::PixelType> CoherencyFunctorType; + + + typedef otb::Functor::SinclairToCovarianceMatrixFunctor<ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleVectorImageType::PixelType> CovarianceFunctorType; + + + typedef otb::Functor::SinclairToCircularCovarianceMatrixFunctor<ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleVectorImageType::PixelType> CircularCovarianceFunctorType; + + + typedef otb::Functor::SinclairToMuellerMatrixFunctor<ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + ComplexDoubleImageType::PixelType, + DoubleVectorImageType::PixelType> MuellerFunctorType; + + + typedef SinclairImageFilter<ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleVectorImageType, + CoherencyFunctorType > CohSRFilterType; + + + typedef SinclairImageFilter<ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleVectorImageType, + CovarianceFunctorType > CovSRFilterType; + + typedef SinclairImageFilter<ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleVectorImageType, + CircularCovarianceFunctorType > CCSRFilterType; + + typedef SinclairImageFilter<ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleImageType, + ComplexDoubleImageType, + DoubleVectorImageType, + MuellerFunctorType > MSRFilterType; + + + typedef otb::MuellerToReciprocalCovarianceImageFilter<DoubleVectorImageType, ComplexDoubleVectorImageType> MRCFilterType; + + typedef otb::MuellerToPolarisationDegreeAndPowerImageFilter<DoubleVectorImageType, DoubleVectorImageType> MPDPFilterType; + + + + /** Standard macro */ + itkNewMacro(Self); + + itkTypeMacro(SARPolarMatrixConvert, otb::Application); + +private: + void DoInit() + { + SetName("SARPolarMatrixConvert"); + SetDescription("This applications allows converting classical polarimetric matrices to each other."); + + // Documentation + SetDocName("SARPolarMatrixConvert"); + SetDocLongDescription( + + "This application allows converting classical polarimetric matrices to each other.\n" + "For instance, it is possible to get the coherency matrix from the Sinclar one, or the Mueller matrix from the coherency one.\n" + "The filters used in this application never handle matrices, but images where each band is related to their elements.\n" + "As most of the time SAR polarimetry handles symetric/hermitian matrices, only the relevant elements are stored, so that the images representing them have a minimal number of bands.\n" + "For instance, the coherency matrix size is 3x3 in the monostatic case, and 4x4 in the bistatic case : it will thus be stored in a 6-band or a 10-band complex image (the diagonal and the upper elements of the matrix).\n" + "\n" + "The Sinclair matrix is a special case : it is always represented as 3 or 4 one-band complex images (for mono- or bistatic case).\n" + "The available conversions are listed below:\n" + + "\n--- Monostatic case ---\n" + + "1 msinclairtocoherency --> Sinclair matrix to coherency matrix (input : 3 x 1 complex channel (HH, HV or VH, VV) | output : 6 complex channels)\n" + "2 msinclairtocovariance --> Sinclair matrix to covariance matrix (input : 3 x 1 complex channel (HH, HV or VH, VV) | output : 6 complex channels)\n" + "3 msinclairtocircovariance --> Sinclair matrix to circular covariance matrix (input : 3 x 1 complex channel (HH, HV or VH, VV) | output : 6 complex channels)\n" + "4 mcoherencytomueller --> Coherency matrix to Mueller matrix (input : 6 complex channels | 16 real channels)\n" + "5 mcovariancetocoherencydegree --> Covariance matrix to coherency degree (input : 6 complex channels | 3 complex channels)\n" + "6 mcovariancetocoherency --> Covariance matrix to coherency matrix (input : 6 complex channels | 6 complex channels)\n" + "7 mlinearcovariancetocircularcovariance --> Covariance matrix to circular covariance matrix (input : 6 complex channels | output : 6 complex channels)\n" + + "\n--- Bistatic case ---\n" + + "8 bsinclairtocoherency --> Sinclair matrix to coherency matrix (input : 4 x 1 complex channel (HH, HV, VH, VV) | 10 complex channels)\n" + "9 bsinclairtocovariance --> Sinclair matrix to covariance matrix (input : 4 x 1 complex channel (HH, HV, VH, VV) | output : 10 complex channels)\n" + "10 bsinclairtocircovariance --> Sinclair matrix to circular covariance matrix (input : 4 x 1 complex channel (HH, HV, VH, VV) | output : 10 complex channels)\n" + + "\n--- Both cases ---\n" + + "11 sinclairtomueller --> Sinclair matrix to Mueller matrix (input : 4 x 1 complex channel (HH, HV, VH, VV) | output : 16 real channels)\n" + "12 muellertomcovariance --> Mueller matrix to covariance matrix (input : 16 real channels | output : 6 complex channels)\n" + "13 muellertopoldegandpower --> Mueller matrix to polarization degree and power (input : 16 real channels | output : 4 real channels)\n" + + ); + + SetDocLimitations("None"); + SetDocAuthors("OTB-Team"); + SetDocSeeAlso("SARPolarSynth, SARDecompositions"); + + AddDocTag(Tags::SAR); + + AddParameter(ParameterType_ComplexInputImage, "inc", "Input : multi-band complex image"); + SetParameterDescription("inc", "Input : multi-band complex image"); + MandatoryOff("inc"); + + AddParameter(ParameterType_InputImage, "inf", "Input : multi-band real image"); + SetParameterDescription("inf", "Input : multi-band real image"); + MandatoryOff("inf"); + + + AddParameter(ParameterType_ComplexInputImage, "inhh", "Input : one-band complex image (HH)"); + SetParameterDescription("inhh", "Input : one-band complex image (HH)"); + MandatoryOff("inhh"); + + AddParameter(ParameterType_ComplexInputImage, "inhv", "Input : one-band complex image (HV)"); + SetParameterDescription("inhv", "Input : one-band complex image (HV)"); + MandatoryOff("inhv"); + + AddParameter(ParameterType_ComplexInputImage, "invh", "Input : one-band complex image (VH)"); + SetParameterDescription("invh", "Input : one-band complex image (VH)"); + MandatoryOff("invh"); + + AddParameter(ParameterType_ComplexInputImage, "invv", "Input : one-band complex image (VV)"); + SetParameterDescription("invv", "Input : one-band complex image (VV)"); + MandatoryOff("invv"); + + AddParameter(ParameterType_ComplexOutputImage, "outc", "Output Complex Image"); + SetParameterDescription("outc", "Output Complex image."); + MandatoryOff("outc"); + + AddParameter(ParameterType_OutputImage, "outf", "Output Real Image"); + SetParameterDescription("outf", "Output Real image."); + MandatoryOff("outf"); + + + + AddParameter(ParameterType_Choice, "conv", "Convertion"); + + //Monostatic case + + // #1 + // SinclairToReciprocalCoherency + AddChoice("conv.msinclairtocoherency","1 Monostatic : Sinclair matrix to coherency matrix (complex output)"); + SetParameterDescription("conv.msinclairtocoherency","1 Monostatic :Sinclair matrix to coherency matrix (complex output)"); + + // #2 + // SinclairToReciprocalCovariance + AddChoice("conv.msinclairtocovariance","2 Monostatic : Sinclair matrix to covariance matrix (complex output)"); + SetParameterDescription("conv.msinclairtocovariance","2 Monostatic : Sinclair matrix to covariance matrix (complex output)"); + + // #3 + // SinclairToReciprocalCircularCovariance + AddChoice("conv.msinclairtocircovariance","3 Monostatic : Sinclair matrix to circular covariance matrix (complex output)"); + SetParameterDescription("conv.msinclairtocircovariance","3 Monostatic : Sinclair matrix to circular covariance matrix (complex output)"); + + // #4 + // ReciprocalCoherencyToReciprocalMuellerImageFilter + AddChoice("conv.mcoherencytomueller","4 Monostatic : Coherency matrix to Mueller matrix"); + SetParameterDescription("conv.mcoherencytomueller","4 Monostatic : Coherency matrix to Mueller matrix"); + + // #5 + // ReciprocalCovarianceToCoherencyDegreeImageFilter + AddChoice("conv.mcovariancetocoherencydegree","5 Monostatic : Covariance matrix to coherency degree "); + SetParameterDescription("conv.mcovariancetocoherencydegree","5 Monostatic : Covariance matrix to coherency degree "); + + // #6 + // ReciprocalCovarianceToReciprocalCoherencyImageFilter + AddChoice("conv.mcovariancetocoherency","6 Monostatic : Covariance matrix to coherency matrix (complex output)"); + SetParameterDescription("conv.mcovariancetocoherency","6 Monostatic : Covariance matrix to coherency matrix (complex output)"); + + // #7 + // ReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter + AddChoice("conv.mlinearcovariancetocircularcovariance","7 Monostatic : Covariance matrix to circular covariance matrix (complex output)"); + SetParameterDescription("conv.mlinearcovariancetocircularcovariance","7 Monostatic : Covariance matrix to circular covariance matrix (complex output)"); + + // #8 + // MuellerToReciprocalCovarianceImageFilter + AddChoice("conv.muellertomcovariance","8 Bi/mono : Mueller matrix to monostatic covariance matrix"); + SetParameterDescription("conv.muellertomcovariance","8 Bi/mono : Mueller matrix to monostatic covariance matrix"); + + //Bistatic case + + // #9 + // SinclairToCoherency + AddChoice("conv.bsinclairtocoherency","9 Bistatic : Sinclair matrix to coherency matrix (complex output)"); + SetParameterDescription("conv.bsinclairtocoherency","9 Bistatic : Sinclair matrix to coherency matrix (complex output)"); + + // #10 + // SinclairToCovariance + AddChoice("conv.bsinclairtocovariance","10 Bistatic : Sinclair matrix to covariance matrix (complex output)"); + SetParameterDescription("conv.bsinclairtocovariance","10 Bistatic : Sinclair matrix to covariance matrix (complex output)"); + + // #11 + // SinclairToCircularCovariance + AddChoice("conv.bsinclairtocircovariance","11 Bistatic : Sinclair matrix to circular covariance matrix (complex output)"); + SetParameterDescription("conv.bsinclairtocircovariance","11 Bistatic : Sinclair matrix to circular covariance matrix (complex output)"); + + //Both case + + // #12 + // SinclairToMueller + AddChoice("conv.sinclairtomueller","12 Bi/mono : Sinclair matrix to Mueller matrix"); + SetParameterDescription("conv.sinclairtomueller","12 Bi/mono : Sinclair matrix to Mueller matrix"); + + + // #13 + // MuellerToPolarisationDegreeAndPowerImageFilter + AddChoice("conv.muellertopoldegandpower","13 Bi/mono : Mueller matrix to polarisation degree and power"); + SetParameterDescription("conv.muellertopoldegandpower","13 Bi/mono : Mueller matrix to polarisation degree and power"); + + AddRAMParameter(); + + // Default values + SetDefaultParameterInt("conv", 0); // SinclairToReciprocalCoherency + + // Doc example parameter settings + SetDocExampleParameterValue("inhh", "HH.tif"); + SetDocExampleParameterValue("invh", "VH.tif"); + SetDocExampleParameterValue("invv", "VV.tif"); + SetDocExampleParameterValue("conv", "msinclairtocoherency"); + SetDocExampleParameterValue("outc", "mcoherency.tif"); + } + + void DoUpdateParameters() + { + + int convType = GetParameterInt("conv"); + + if ( (convType>=0) && (convType<=2)) //msinclairtocoherency msinclairtocovariance msinclairtocircovariance + { + GetParameterByKey("inc")->SetActive(false); + GetParameterByKey("inf")->SetActive(false); + GetParameterByKey("inhh")->SetActive(true); + GetParameterByKey("inhv")->SetActive(true); + GetParameterByKey("invh")->SetActive(true); + GetParameterByKey("invv")->SetActive(true); + GetParameterByKey("outc")->SetActive(true); + GetParameterByKey("outf")->SetActive(false); + } + else if ( (convType>=3) && (convType<=6)) // mcoherencytomueller mcovariancetocoherencydegree mcovariancetocoherency mlinearcovariancetocircularcovariance + { + GetParameterByKey("inc")->SetActive(true); + GetParameterByKey("inf")->SetActive(false); + GetParameterByKey("inhh")->SetActive(false); + GetParameterByKey("inhv")->SetActive(false); + GetParameterByKey("invh")->SetActive(false); + GetParameterByKey("invv")->SetActive(false); + + if (convType == 3) + { + GetParameterByKey("outc")->SetActive(false); + GetParameterByKey("outf")->SetActive(true); + } + else + { + GetParameterByKey("outc")->SetActive(true); + GetParameterByKey("outf")->SetActive(false); + } + } + else if ( convType==7) // muellertomcovariance + { + GetParameterByKey("inc")->SetActive(false); + GetParameterByKey("inf")->SetActive(true); + GetParameterByKey("inhh")->SetActive(false); + GetParameterByKey("inhv")->SetActive(false); + GetParameterByKey("invh")->SetActive(false); + GetParameterByKey("invv")->SetActive(false); + GetParameterByKey("outc")->SetActive(true); + GetParameterByKey("outf")->SetActive(false); + } + else if ( (convType>=8) && (convType<=11)) // bsinclairtocoherency bsinclairtocovariance bsinclairtocircovariance sinclairtomueller + { + GetParameterByKey("inc")->SetActive(false); + GetParameterByKey("inf")->SetActive(false); + GetParameterByKey("inhh")->SetActive(true); + GetParameterByKey("inhv")->SetActive(true); + GetParameterByKey("invh")->SetActive(true); + GetParameterByKey("invv")->SetActive(true); + + if (convType == 11) + { + GetParameterByKey("outc")->SetActive(false); + GetParameterByKey("outf")->SetActive(true); + } + else + { + GetParameterByKey("outc")->SetActive(true); + GetParameterByKey("outf")->SetActive(false); + } + + } + else if ( convType==12 ) // muellertopoldegandpower + { + GetParameterByKey("inc")->SetActive(false); + GetParameterByKey("inf")->SetActive(true); + GetParameterByKey("inhh")->SetActive(false); + GetParameterByKey("inhv")->SetActive(false); + GetParameterByKey("invh")->SetActive(false); + GetParameterByKey("invv")->SetActive(false); + GetParameterByKey("outc")->SetActive(false); + GetParameterByKey("outf")->SetActive(true); + } + + + + } + + void DoExecute() + { + + //**************************************** + //* Check inputs and outputs consistency * + //**************************************** + + bool inc = HasUserValue("inc"); + bool inf = HasUserValue("inf"); + bool inhh = HasUserValue("inhh"); + bool inhv = HasUserValue("inhv"); + bool invh = HasUserValue("invh"); + bool invv = HasUserValue("invv"); + bool outc = HasUserValue("outc"); + bool outf = HasUserValue("outf"); + + int convType = GetParameterInt("conv"); + + + if ( (!outc) && (!outf) ) + otbAppLogFATAL( << "No output image provided; please, set the parameter 'outc' or 'outf'."); + + + if ( (convType>=0) && (convType<=2)) //msinclairtocoherency msinclairtocovariance msinclairtocircovariance + { + if ( (!inhv) && (!invh) ) + otbAppLogFATAL( << "Parameter 'inhv' or 'invh' not set."); + if ( !inhh ) + otbAppLogFATAL( << "Parameter 'inhh' not set."); + if ( !invv ) + otbAppLogFATAL( << "Parameter 'invv' not set."); + + } + + else if ( (convType>=3) && (convType<=6)) // mcoherencytomueller mcovariancetocoherencydegree mcovariancetocoherency mlinearcovariancetocircularcovariance + { + if ( !inc ) + otbAppLogFATAL( << "Parameter 'inc' not set."); + } + else if ( (convType>=8) && (convType<=11)) // bsinclairtocoherency bsinclairtocovariance bsinclairtocircovariance sinclairtomueller + { + if ( (!inhh) || (!inhv) || (!invh) || (!invv) ) + otbAppLogFATAL( << "Please, ensure that HH, HV, VH and VV complex images have been provided (paramaters inhh, inhv, invh, invv)."); + } + else if ( (convType==7) || (convType==12) ) // muellertomcovariance muellertopoldegandpower + { + if ( !inf ) + otbAppLogFATAL( << "Parameter 'inf' not set."); + } + + + switch (GetParameterInt("conv")) + { + + //*************************************** + //* MONOSTATIC * + //*************************************** + + case 0: // SinclairToReciprocalCoherency + m_RCohSRFilter = RCohSRFilterType::New(); + + if (inhv) + m_RCohSRFilter->SetInputHV_VH(GetParameterComplexDoubleImage("inhv")); + else if (invh) + m_RCohSRFilter->SetInputHV_VH(GetParameterComplexDoubleImage("invh")); + + m_RCohSRFilter->SetInputHH(GetParameterComplexDoubleImage("inhh")); + m_RCohSRFilter->SetInputVV(GetParameterComplexDoubleImage("invv")); + + SetParameterComplexOutputImage("outc", m_RCohSRFilter->GetOutput() ); // input : 3 x 1 complex channel | output : 6 complex channels + + break; + + + case 1: // SinclairToReciprocalCovariance + + m_RCovSRFilter = RCovSRFilterType::New(); + + if (inhv) + m_RCovSRFilter->SetInputHV_VH(GetParameterComplexDoubleImage("inhv")); + else if (invh) + m_RCovSRFilter->SetInputHV_VH(GetParameterComplexDoubleImage("invh")); + + m_RCovSRFilter->SetInputHH(GetParameterComplexDoubleImage("inhh")); + m_RCovSRFilter->SetInputVV(GetParameterComplexDoubleImage("invv")); + + SetParameterComplexOutputImage("outc", m_RCovSRFilter->GetOutput() ); // input : 3 x 1 complex channel | output : 6 complex channels + + break; + + + + case 2: // SinclairToReciprocalCircularCovariance + + m_RCCSRFilter = RCCSRFilterType::New(); + + if (inhv) + m_RCCSRFilter->SetInputHV_VH(GetParameterComplexDoubleImage("inhv")); + else if (invh) + m_RCCSRFilter->SetInputHV_VH(GetParameterComplexDoubleImage("invh")); + + m_RCCSRFilter->SetInputHH(GetParameterComplexDoubleImage("inhh")); + m_RCCSRFilter->SetInputVV(GetParameterComplexDoubleImage("invv")); + + SetParameterComplexOutputImage("outc", m_RCCSRFilter->GetOutput() ); // input : 3 x 1 complex channel | output : 6 complex channels + + break; + + + case 3: // ReciprocalCoherencyToReciprocalMuellerImageFilter + + m_RCRMFilter = RCRMFilterType::New(); + m_RCRMFilter->SetInput(GetParameterComplexDoubleVectorImage("inc")); + + SetParameterOutputImage("outf", m_RCRMFilter->GetOutput() ); // input : 6 complex channels | 16 real channels + + break; + + + + case 4: // ReciprocalCovarianceToCoherencyDegreeImageFilter + + m_RCCDFilter = RCCDFilterType::New(); + m_RCCDFilter->SetInput(GetParameterComplexDoubleVectorImage("inc")); + + SetParameterComplexOutputImage("outc", m_RCCDFilter->GetOutput() ); // input : 6 complex channels | 3 complex channels + + break; + + + case 5: // ReciprocalCovarianceToReciprocalCoherencyImageFilter + + m_RCRCFilter = RCRCFilterType::New(); + m_RCRCFilter->SetInput(GetParameterComplexDoubleVectorImage("inc")); + + SetParameterComplexOutputImage("outc", m_RCRCFilter->GetOutput() ); // input : 6 complex channels | 6 complex channels + + break; + + + + case 6: // ReciprocalLinearCovarianceToReciprocalCircularCovarianceImageFilter + + m_RLCRCCFilter = RLCRCCFilterType::New(); + m_RLCRCCFilter->SetInput(GetParameterComplexDoubleVectorImage("inc")); + + SetParameterComplexOutputImage("outc", m_RLCRCCFilter->GetOutput() ); // input : 6 complex channels | output : 6 complex channels + + break; + + + case 7: // MuellerToReciprocalCovarianceImageFilter + + m_MRCFilter = MRCFilterType::New(); + + m_MRCFilter->SetInput(GetParameterDoubleVectorImage("inf")); + + SetParameterComplexOutputImage("outc", m_MRCFilter->GetOutput() ); // input : 16 real channels | output : 6 complex channels + + break; + + + //*************************************** + //* BISTATIC * + //*************************************** + + case 8: // SinclairToCoherency + + m_CohSRFilter = CohSRFilterType::New(); + + m_CohSRFilter->SetInputHH(GetParameterComplexDoubleImage("inhh")); + m_CohSRFilter->SetInputHV(GetParameterComplexDoubleImage("inhv")); + m_CohSRFilter->SetInputVH(GetParameterComplexDoubleImage("invh")); + m_CohSRFilter->SetInputVV(GetParameterComplexDoubleImage("invv")); + + SetParameterComplexOutputImage("outc", m_CohSRFilter->GetOutput() ); // input : 4 x 1 complex channel | 10 complex channels + + break; + + + + case 9: // SinclairToCovariance + + m_CovSRFilter = CovSRFilterType::New(); + + m_CovSRFilter->SetInputHH(GetParameterComplexDoubleImage("inhh")); + m_CovSRFilter->SetInputHV(GetParameterComplexDoubleImage("inhv")); + m_CovSRFilter->SetInputVH(GetParameterComplexDoubleImage("invh")); + m_CovSRFilter->SetInputVV(GetParameterComplexDoubleImage("invv")); + + SetParameterComplexOutputImage("outc", m_CovSRFilter->GetOutput() ); // input : 4 x 1 complex channel | output : 10 complex channels + + break; + + + case 10: // SinclairToCircularCovariance + + m_CCSRFilter = CCSRFilterType::New(); + + m_CCSRFilter->SetInputHH(GetParameterComplexDoubleImage("inhh")); + m_CCSRFilter->SetInputHV(GetParameterComplexDoubleImage("inhv")); + m_CCSRFilter->SetInputVH(GetParameterComplexDoubleImage("invh")); + m_CCSRFilter->SetInputVV(GetParameterComplexDoubleImage("invv")); + + SetParameterComplexOutputImage("outc", m_CCSRFilter->GetOutput() ); // input : 4 x 1 complex channel | output : 10 complex channels + + break; + + + //*************************************** + //* BOTH CASES * + //*************************************** + + + case 11: // SinclairToMueller + std::cout << "taloula 1" << std::endl; + m_MSRFilter = MSRFilterType::New(); + + m_MSRFilter->SetInputHH(GetParameterComplexDoubleImage("inhh")); + m_MSRFilter->SetInputHV(GetParameterComplexDoubleImage("inhv")); + m_MSRFilter->SetInputVH(GetParameterComplexDoubleImage("invh")); + m_MSRFilter->SetInputVV(GetParameterComplexDoubleImage("invv")); + + SetParameterOutputImage("outf", m_MSRFilter->GetOutput() ); // input : 4 x 1 complex channel | output : 16 real channels + + break; + + + case 12: // MuellerToPolarisationDegreeAndPowerImageFilter + m_MPDPFilter = MPDPFilterType::New(); + + m_MPDPFilter->SetInput(GetParameterDoubleVectorImage("inf")); + + SetParameterOutputImage("outf", m_MPDPFilter->GetOutput() ); // input : 16 real channels | output : 4 real channels + + break; + + } + + + + } + + //Monostatic + RCohSRFilterType::Pointer m_RCohSRFilter; + RCovSRFilterType::Pointer m_RCovSRFilter; + RCCSRFilterType::Pointer m_RCCSRFilter; + RCRMFilterType::Pointer m_RCRMFilter; + RCCDFilterType::Pointer m_RCCDFilter; + RCRCFilterType::Pointer m_RCRCFilter; + RLCRCCFilterType::Pointer m_RLCRCCFilter; + + //Bistatic + CohSRFilterType::Pointer m_CohSRFilter; + CovSRFilterType::Pointer m_CovSRFilter; + CCSRFilterType::Pointer m_CCSRFilter; + MSRFilterType::Pointer m_MSRFilter; + + //Both cases + MRCFilterType::Pointer m_MRCFilter; + MPDPFilterType::Pointer m_MPDPFilter; + + + + + +}; + +} //end namespace Wrapper +} //end namespace otb + +OTB_APPLICATION_EXPORT(otb::Wrapper::SARPolarMatrixConvert) diff --git a/Modules/Applications/AppSARPolarMatrixConvert/otb-module.cmake b/Modules/Applications/AppSARPolarMatrixConvert/otb-module.cmake new file mode 100644 index 0000000000000000000000000000000000000000..759161f8b45b6a0e22916b9838c78f29c36b75ba --- /dev/null +++ b/Modules/Applications/AppSARPolarMatrixConvert/otb-module.cmake @@ -0,0 +1,17 @@ +set(DOCUMENTATION "Basic filters application.") + +otb_module(OTBAppSARPolarMatrixConvert + DEPENDS + OTBPolarimetry + OTBImageManipulation + OTBITK + OTBApplicationEngine + OTBImageBase + + TEST_DEPENDS + OTBTestKernel + OTBCommandLine + + DESCRIPTION + "${DOCUMENTATION}" +) diff --git a/Modules/Applications/AppSARPolarMatrixConvert/test/CMakeLists.txt b/Modules/Applications/AppSARPolarMatrixConvert/test/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..a7c518f53999ce2c19ca2c74db8ce4eea95d486b --- /dev/null +++ b/Modules/Applications/AppSARPolarMatrixConvert/test/CMakeLists.txt @@ -0,0 +1,157 @@ +otb_module_test() +#----------- SARPolarMatrixConvert TESTS ---------------- + +#1 +otb_test_application(NAME apTvSARPolarMatrixConvertRecCoherency + APP SARPolarMatrixConvert + OPTIONS + -inhh ${INPUTDATA}/RSAT_imageryC_HH.tif + -inhv ${INPUTDATA}/RSAT_imageryC_HV.tif + -invv ${INPUTDATA}/RSAT_imageryC_VV.tif + -conv msinclairtocoherency + -outc ${TEMP}/apTvSARPolarMatrixConvertRecCoherency.tif + + ) + +#2 +otb_test_application(NAME apTvSARPolarMatrixConvertRecCovariance + APP SARPolarMatrixConvert + OPTIONS + -inhh ${INPUTDATA}/RSAT_imageryC_HH.tif + -inhv ${INPUTDATA}/RSAT_imageryC_HV.tif + -invv ${INPUTDATA}/RSAT_imageryC_VV.tif + -conv msinclairtocovariance + -outc ${TEMP}/apTvSARPolarMatrixConvertRecCovariance.tif + + ) + +#3 +otb_test_application(NAME apTvSARPolarMatrixConvertRecCirCovariance + APP SARPolarMatrixConvert + OPTIONS + -inhh ${INPUTDATA}/RSAT_imageryC_HH.tif + -inhv ${INPUTDATA}/RSAT_imageryC_HV.tif + -invv ${INPUTDATA}/RSAT_imageryC_VV.tif + -conv msinclairtocircovariance + -outc ${TEMP}/apTvSARPolarMatrixConvertRecCirCovariance.tif + + ) + +#4 +otb_test_application(NAME apTvSARPolarMatrixConvertRecCohToMueller + APP SARPolarMatrixConvert + OPTIONS + -inc ${BASELINE}/saTvSinclairImageFilter_SinclairToReciprocalCovariance.tif + -conv mcoherencytomueller + -outf ${TEMP}/apTvSARPolarMatrixConvertRecCohToMueller.tif + + ) + + +#5 +otb_test_application(NAME apTvSARPolarMatrixConvertRecCovToCohDeg + APP SARPolarMatrixConvert + OPTIONS + -inc ${BASELINE}/saTvSinclairImageFilter_SinclairToReciprocalCovariance.tif + -conv mcovariancetocoherencydegree + -outc ${TEMP}/apTvSARPolarMatrixConvertRecCovToCohDeg.tif + + ) + + +#6 +otb_test_application(NAME apTvSARPolarMatrixConvertRecCovToRecCoh + APP SARPolarMatrixConvert + OPTIONS + -inc ${BASELINE}/saTvSinclairImageFilter_SinclairToReciprocalCovariance.tif + -conv mcovariancetocoherency + -outc ${TEMP}/apTvSARPolarMatrixConvertRecCovToRecCoh.tif + + ) + +#7 +otb_test_application(NAME apTvSARPolarMatrixConvertRecLinCovToRecCirCov + APP SARPolarMatrixConvert + OPTIONS + -inc ${BASELINE}/saTvSinclairImageFilter_SinclairToReciprocalCovariance.tif + -conv mlinearcovariancetocircularcovariance + -outc ${TEMP}/apTvSARPolarMatrixConvertRecCovToRecCoh.tif + + ) + + +#8 +otb_test_application(NAME apTvSARPolarMatrixConvertMuellerToRecCov + APP SARPolarMatrixConvert + OPTIONS + -inf ${BASELINE}/saTvSinclairImageFilter_SinclairToMueller.tif + -conv muellertomcovariance + -outc ${TEMP}/apTvSARPolarMatrixConvertMuellerToRecCov.tif + + ) + + +#9 +otb_test_application(NAME apTvSARPolarMatrixConvertBiSincToCoherency + APP SARPolarMatrixConvert + OPTIONS + -inhh ${INPUTDATA}/RSAT_imageryC_HH.tif + -inhv ${INPUTDATA}/RSAT_imageryC_HV.tif + -invh ${INPUTDATA}/RSAT_imageryC_VH.tif + -invv ${INPUTDATA}/RSAT_imageryC_VV.tif + -conv bsinclairtocoherency + -outc ${TEMP}/apTvSARPolarMatrixConvertBiSincToCoherency.tif + + ) + + +#10 +otb_test_application(NAME apTvSARPolarMatrixConvertBiSincToCovariance + APP SARPolarMatrixConvert + OPTIONS + -inhh ${INPUTDATA}/RSAT_imageryC_HH.tif + -inhv ${INPUTDATA}/RSAT_imageryC_HV.tif + -invh ${INPUTDATA}/RSAT_imageryC_VH.tif + -invv ${INPUTDATA}/RSAT_imageryC_VV.tif + -conv bsinclairtocovariance + -outc ${TEMP}/apTvSARPolarMatrixConvertBiSincToCovariance.tif + + ) + +#11 +otb_test_application(NAME apTvSARPolarMatrixConvertBiSincToCirCovariance + APP SARPolarMatrixConvert + OPTIONS + -inhh ${INPUTDATA}/RSAT_imageryC_HH.tif + -inhv ${INPUTDATA}/RSAT_imageryC_HV.tif + -invh ${INPUTDATA}/RSAT_imageryC_VH.tif + -invv ${INPUTDATA}/RSAT_imageryC_VV.tif + -conv bsinclairtocircovariance + -outc ${TEMP}/apTvSARPolarMatrixConvertBiSincToCirCovariance.tif + + ) + + +#12 +otb_test_application(NAME apTvSARPolarMatrixConvertSincToMueller + APP SARPolarMatrixConvert + OPTIONS + -inhh ${INPUTDATA}/RSAT_imageryC_HH.tif + -inhv ${INPUTDATA}/RSAT_imageryC_HV.tif + -invh ${INPUTDATA}/RSAT_imageryC_HV.tif #monostatic + -invv ${INPUTDATA}/RSAT_imageryC_VV.tif + -conv sinclairtomueller + -outf ${TEMP}/apTvSARPolarMatrixConvertSincToMueller.tif + + ) + + +#13 +otb_test_application(NAME apTvSARPolarMatrixConvertMuellerToPolDeGPow + APP SARPolarMatrixConvert + OPTIONS + -inf ${BASELINE}/saTvSinclairImageFilter_SinclairToMueller.tif + -conv muellertopoldegandpower + -outf ${TEMP}/apTvSARPolarMatrixConvertMuellerToPolDeGPow.tif + + ) diff --git a/Modules/Applications/AppSARPolarSynth/CMakeLists.txt b/Modules/Applications/AppSARPolarSynth/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..f6c2324b5b9053c0a5f0f3818560e586c30ba62c --- /dev/null +++ b/Modules/Applications/AppSARPolarSynth/CMakeLists.txt @@ -0,0 +1,2 @@ +project(OTBAppSARPolarSynth) +otb_module_impl() diff --git a/Modules/Applications/AppSARPolarSynth/app/CMakeLists.txt b/Modules/Applications/AppSARPolarSynth/app/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..ea87ee870ad0182cd2338fc42e915c81279f6495 --- /dev/null +++ b/Modules/Applications/AppSARPolarSynth/app/CMakeLists.txt @@ -0,0 +1,12 @@ +set(OTBAppFiltering_LINK_LIBS + ${OTBPolarimetry_LIBRARIES} + ${OTBImageManipulation_LIBRARIES} + ${OTBApplicationEngine_LIBRARIES} + ${OTBImageBase_LIBRARIES} +) + +otb_create_application( + NAME SARPolarSynth + SOURCES otbSARPolarSynth.cxx + LINK_LIBRARIES ${${otb-module}_LIBRARIES}) + diff --git a/Modules/Applications/AppSARPolarSynth/app/otbSARPolarSynth.cxx b/Modules/Applications/AppSARPolarSynth/app/otbSARPolarSynth.cxx new file mode 100644 index 0000000000000000000000000000000000000000..4963306b34a459f87283d7bf17cc98b0ad4060d9 --- /dev/null +++ b/Modules/Applications/AppSARPolarSynth/app/otbSARPolarSynth.cxx @@ -0,0 +1,185 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + + =========================================================================*/ +#include "otbWrapperApplication.h" +#include "otbWrapperApplicationFactory.h" + +#include "otbMultiChannelsPolarimetricSynthesisFilter.h" + +namespace otb +{ +namespace Wrapper +{ + +class SARPolarSynth : public Application +{ +public: + /** Standard class typedefs. */ + typedef SARPolarSynth Self; + typedef Application Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + typedef MultiChannelsPolarimetricSynthesisFilter<ComplexDoubleVectorImageType, FloatImageType> MCPSFilterType; + /** Standard macro */ + itkNewMacro(Self); + + itkTypeMacro(SARPolarSynth, otb::Application); + +private: + void DoInit() + { + SetName("SARPolarSynth"); + SetDescription("Gives, for each pixel, the power that would have been received by a SAR system with a basis different from the classical (H,V) one (polarimetric synthetis)."); + + // Documentation + SetDocName("SARPolarSynth"); + SetDocLongDescription("This application gives, for each pixel, the power that would have been received by a SAR system with a basis different from the classical (H,V) one (polarimetric synthetis).\n" + "The new basis A and B are indicated through two Jones vectors, defined by the user thanks to orientation (psi) and ellipticity (khi) parameters.\n" + "These parameters are namely psii, khii, psir and khir. The suffixes (i) and (r) refer to the transmiting antenna and the receiving antenna respectively.\n" + "Orientations and ellipticities are given in degrees, and are between -90°/90° and -45°/45° respectively.\n " + "\n" + "Four polarization architectures can be processed : \n" + "1) HH_HV_VH_VV : full polarization, general bistatic case.\n" + "2) HH_HV_VV or HH_VH_VV : full polarization, monostatic case (transmitter and receiver are co-located).\n" + "3) HH_HV : dual polarization.\n" + "4) VH_VV : dual polarization.\n" + "The application takes a complex vector image as input, where each band correspond to a particular emission/reception polarization scheme.\n" + "User must comply with the band order given above, since the bands are used to build the Sinclair matrix.\n" + "\n" + "In order to determine the architecture, the application first relies on the number of bands of the input image.\n" + "1) Architecture HH_HV_VH_VV is the only one with four bands, there is no possible confusion.\n" + "2) Concerning HH_HV_VV and HH_VH_VV architectures, both correspond to a three channels image. But they are processed in the same way, as the Sinclair matrix is symetric in the monostatic case.\n" + "3) Finally, the two last architectures (dual polarizations), can't be distinguished only by the number of bands of the input image.\n" + " User must then use the parameters emissionh and emissionv to indicate the architecture of the system : emissionh=1 and emissionv=0 --> HH_HV, emissionh=0 and emissionv=1 --> VH_VV.\n" + "Note : if the architecture is HH_HV, khii and psii are automatically set to 0°/0°; if the architecture is VH_VV, khii and psii are automatically set to 0°/90°.\n" + "\n" + "It is also possible to force the calculation to co-polar or cross-polar modes.\n" + "In the co-polar case, values for psir and khir will be ignored and forced to psii and khii; same as the cross-polar mode, where khir and psir will be forced to psii+90° and -khii.\n" + "\n" + "Finally, the result of the polarimetric synthetis is expressed in the power domain, through a one-band scalar image.\n" + "Note: this application doesn't take into account the terms which do not depend on the polarization of the antennas. \n" + "The parameter gain can be used for this purpose.\n" + "\n" + "The final formula is thus : P = | B^T . [S] . A |², where A ans B are two Jones vectors and S is a Sinclair matrix."); + + SetDocLimitations("None"); + SetDocAuthors("OTB-Team"); + SetDocSeeAlso("SARDecompositions, SARPolarMatrixConvert"); + + AddDocTag(Tags::SAR); + + AddParameter(ParameterType_ComplexInputImage, "in", "Input Image"); + SetParameterDescription("in", "Input image."); + AddParameter(ParameterType_OutputImage, "out", "Output Image"); + SetParameterDescription("out", "Output image."); + + AddParameter(ParameterType_Float,"psii","psii"); + SetParameterDescription("psii","Orientation (transmitting antenna)"); + SetMinimumParameterFloatValue("psii",-90.0); + SetMaximumParameterFloatValue("psii",90.0); + + AddParameter(ParameterType_Float,"khii","khii"); + SetParameterDescription("khii","Ellipticity (transmitting antenna)"); + SetMinimumParameterFloatValue("khii",-45.0); + SetMaximumParameterFloatValue("khii",45.0); + + AddParameter(ParameterType_Float,"psir","psir"); + SetParameterDescription("psir","Orientation (receiving antenna)"); + SetMinimumParameterFloatValue("psir",-90.0); + SetMaximumParameterFloatValue("psir",90.0); + + AddParameter(ParameterType_Float,"khir","khir"); + SetParameterDescription("khir","Ellipticity (receiving antenna)"); + SetMinimumParameterFloatValue("khir",-45.0); + SetMaximumParameterFloatValue("khir",45.0); + + AddParameter(ParameterType_Int,"emissionh","Emission H"); + SetParameterDescription("emissionh","This parameter is useful in determining the polarization architecture (dual polarization case)."); + SetMinimumParameterIntValue("emissionh",0); + SetMaximumParameterIntValue("emissionh",1); + MandatoryOff("emissionh"); + + AddParameter(ParameterType_Int,"emissionv","Emission V"); + SetParameterDescription("emissionv","This parameter is useful in determining the polarization architecture (dual polarization case)."); + SetMinimumParameterIntValue("emissionv",0); + SetMaximumParameterIntValue("emissionv",1); + MandatoryOff("emissionv"); + + AddParameter(ParameterType_Choice, "mode", "Forced mode"); + AddChoice("mode.none","None"); + SetParameterDescription("mode.none","None"); + AddChoice("mode.co","Copolarization"); + SetParameterDescription("mode.none","Copolarization"); + AddChoice("mode.cross","Crosspolarization"); + SetParameterDescription("mode.cross","Crosspolarization"); + + + AddRAMParameter(); + + // Default values + SetDefaultParameterFloat("psii", 0.); + SetDefaultParameterFloat("khii", 0.); + SetDefaultParameterFloat("psir", 0.); + SetDefaultParameterFloat("khir", 0.); + SetDefaultParameterInt("emissionh", 0); + SetDefaultParameterInt("emissionv", 0); + SetDefaultParameterFloat("mode", 0); + + // Doc example parameter settings + SetDocExampleParameterValue("in", "sar.tif"); + SetDocExampleParameterValue("psii","15."); + SetDocExampleParameterValue("khii", "5."); + SetDocExampleParameterValue("psir","-25."); + SetDocExampleParameterValue("khir", "10."); + SetDocExampleParameterValue("out", "newbasis.tif"); + } + + void DoUpdateParameters() + { + // Nothing to do here : all parameters are independent + } + + void DoExecute() + { + + m_MCPSFilter = MCPSFilterType::New(); + m_MCPSFilter->SetPsiI(GetParameterFloat("psii")); + m_MCPSFilter->SetKhiI(GetParameterFloat("khii")); + m_MCPSFilter->SetPsiR(GetParameterFloat("psir")); + m_MCPSFilter->SetKhiR(GetParameterFloat("khir")); + m_MCPSFilter->SetEmissionH(GetParameterInt("emissionh")); + m_MCPSFilter->SetEmissionV(GetParameterInt("emissionv")); + m_MCPSFilter->SetMode(GetParameterInt("mode")); + + ComplexDoubleVectorImageType* inVImage = GetParameterComplexDoubleVectorImage("in"); + inVImage->UpdateOutputInformation(); + int nbBands = inVImage->GetNumberOfComponentsPerPixel(); + otbAppLogINFO( << "nbBands = " << nbBands); + + m_MCPSFilter->SetInput(inVImage); + + SetParameterOutputImage("out", m_MCPSFilter->GetOutput()); + } + //std::vector<itk::ProcessObject::Pointer> m_Ref; + MCPSFilterType::Pointer m_MCPSFilter; +}; + +} //end namespace Wrapper +} //end namespace otb + +OTB_APPLICATION_EXPORT(otb::Wrapper::SARPolarSynth) diff --git a/Modules/Applications/AppSARPolarSynth/otb-module.cmake b/Modules/Applications/AppSARPolarSynth/otb-module.cmake new file mode 100644 index 0000000000000000000000000000000000000000..16d19e0a98d9dde0b29258a43063e6d2696e563e --- /dev/null +++ b/Modules/Applications/AppSARPolarSynth/otb-module.cmake @@ -0,0 +1,17 @@ +set(DOCUMENTATION "Basic filters application.") + +otb_module(OTBAppSARPolarSynth + DEPENDS + OTBPolarimetry + OTBImageManipulation + OTBITK + OTBApplicationEngine + OTBImageBase + + TEST_DEPENDS + OTBTestKernel + OTBCommandLine + + DESCRIPTION + "${DOCUMENTATION}" +) diff --git a/Modules/Applications/AppSARPolarSynth/test/CMakeLists.txt b/Modules/Applications/AppSARPolarSynth/test/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..1adeb2028634a4d0cb63774dd91a7d07cfb44110 --- /dev/null +++ b/Modules/Applications/AppSARPolarSynth/test/CMakeLists.txt @@ -0,0 +1,13 @@ +otb_module_test() +#----------- PolarSynth TESTS ---------------- + +otb_test_application(NAME apTvSARPolarSynth + APP SARPolarSynth + OPTIONS -in ${INPUTDATA}/RSAT2_AltonaExtract_1000_1000_100_100.hdr + -out ${TEMP}/resApMultiPolarimetricSynthesis1.tif + -psii 10.0 + -khii 0.0 + -psir 0.0 + -khir 0.0 + ) + diff --git a/Modules/Core/Metadata/include/otbImageMetadataInterfaceBase.h b/Modules/Core/Metadata/include/otbImageMetadataInterfaceBase.h index 8340cedac73674309f124cc4c8b24499dc3c34b3..2a685790333b2959489715b8cf4450ceee3ba58c 100644 --- a/Modules/Core/Metadata/include/otbImageMetadataInterfaceBase.h +++ b/Modules/Core/Metadata/include/otbImageMetadataInterfaceBase.h @@ -53,6 +53,8 @@ public: typedef MetaDataKey::VariableLengthVectorType VariableLengthVectorType; typedef ImageKeywordlist ImageKeywordlistType; typedef unsigned int UnsignedIntType; + typedef std::vector<std::string> StringVectorType; + typedef std::vector<unsigned int> UIntVectorType; /** Set the image used to get the metadata */ @@ -80,7 +82,7 @@ public: std::string GetGCPProjection() const; // otbMetadataGetMacro(GCPProjection, std::string); - unsigned int GetGCPCount() const; + UnsignedIntType GetGCPCount() const; // otbMetadataGetMacro(GCPCount, unsigned int); OTB_GCP& GetGCPs(unsigned int GCPnum); @@ -107,7 +109,7 @@ public: double GetGCPZ(unsigned int GCPnum) const; // otbMetadataGetGCPnumMacro(GCPZ, double, GCPnum, unsigned int); - /** + /** * Get The no data flags if existing * return False otherwise */ @@ -141,11 +143,11 @@ public: //otbMetadataGetMacro(SensorID, std::string); /** Get the number of bands from the ossim metadata */ - unsigned int GetNumberOfBands() const; + UnsignedIntType GetNumberOfBands() const; //otbMetadataGetMacro(NumberOfBands, unsigned int); /** Get the band name from the ossim metadata */ - std::vector<std::string> GetBandName() const; + StringVectorType GetBandName() const; //otbMetadataGetMacro(BandName, std::vector<std::string>); /** Get the x pixel spacing*/ @@ -156,7 +158,6 @@ public: double GetYPixelSpacing() const; //otbMetadataGetMacro(YPixelSpacing, double); - /** Get the imaging acquisition day from the ossim metadata */ virtual int GetDay() const = 0; // otbMetadataGetMacro(Day, int); @@ -190,11 +191,11 @@ public: //otbMetadataGetMacro(ProductionYear, int); /** Convert the band names provided by ossim to the official band names */ - virtual std::vector<std::string> GetEnhancedBandNames () const = 0; + virtual StringVectorType GetEnhancedBandNames () const = 0; /** Get the 3 spectral band numbers corresponding to the default display for visualization, * in the order R, G, B */ - virtual std::vector<unsigned int> GetDefaultDisplay() const = 0; + virtual UIntVectorType GetDefaultDisplay() const = 0; virtual bool CanRead() const = 0; diff --git a/Modules/Core/Metadata/include/otbSarCalibrationLookupData.h b/Modules/Core/Metadata/include/otbSarCalibrationLookupData.h new file mode 100644 index 0000000000000000000000000000000000000000..ef95f2b687f54ac5b3f4e9d9239d64a96a7c5fc6 --- /dev/null +++ b/Modules/Core/Metadata/include/otbSarCalibrationLookupData.h @@ -0,0 +1,72 @@ +#ifndef SarCalibrationLookupData_H +#define SarCalibrationLookupData_H 1 +#include <string> +#include <itkLightObject.h> +#include <itkNumericTraits.h> +#include <itkObjectFactory.h> + +namespace otb { + +class ITK_EXPORT SarCalibrationLookupData : public itk::LightObject { + + public: + + /** Standard typedefs */ + typedef SarCalibrationLookupData Self; + typedef itk::LightObject Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Creation through the object factory */ + itkNewMacro(Self); + + /** RTTI */ + itkTypeMacro(SarCalibrationLookupData, itk::LightObject); + + typedef itk::IndexValueType IndexValueType; + + enum { + SIGMA = 0, + BETA, + GAMMA, + DN + }; + + SarCalibrationLookupData() + :m_Type(0) + { + + } + + virtual ~SarCalibrationLookupData() + { + } + + virtual double GetValue(const IndexValueType itkNotUsed(x), const IndexValueType itkNotUsed(y)) + { + return 1.0; + } + + void SetType(short t) + { + m_Type = t; + } + + itkGetMacro(Type, short); + + void PrintSelf(std::ostream & os, itk::Indent indent) const + { + os << indent << " lookup table type:'" << m_Type << "'" << std::endl; + Superclass::PrintSelf(os, indent); + } + +private: + + SarCalibrationLookupData(const Self&); //purposely not implemented + void operator =(const Self&); //purposely not implemented + short m_Type; + +}; + +} +#endif diff --git a/Modules/Core/Metadata/include/otbSarDefaultImageMetadataInterface.h b/Modules/Core/Metadata/include/otbSarDefaultImageMetadataInterface.h index f78fa3e87cabf9cd888cad5900c3636c2120795d..dd6529ab2454abc3274b3e5d7645cec4b06d4106 100644 --- a/Modules/Core/Metadata/include/otbSarDefaultImageMetadataInterface.h +++ b/Modules/Core/Metadata/include/otbSarDefaultImageMetadataInterface.h @@ -58,8 +58,7 @@ public: typedef double RealType; typedef PointSetType::PointType PointType; - - RealType GetRadiometricCalibrationScale() const + RealType GetRadiometricCalibrationScale() const { itkExceptionMacro("GetRadiometricCalibrationScale() not implemented in SarDefaultImageMetadataInterface, no captor type found"); } @@ -194,9 +193,9 @@ public: /** Get the 3 spectral band numbers corresponding to the default display for visualization, * in the order R, G, B */ - std::vector<unsigned int> GetDefaultDisplay() const + UIntVectorType GetDefaultDisplay() const { - std::vector<unsigned int> rgb(3); + UIntVectorType rgb(3); rgb[0] = 0; rgb[1] = 0; rgb[2] = 0; diff --git a/Modules/Core/Metadata/include/otbSarImageMetadataInterface.h b/Modules/Core/Metadata/include/otbSarImageMetadataInterface.h index 73f055cbdcab660835dd526a3c806f8d318e4703..7ce844f4207ca378e11c7e8d49722bcd6e953bfd 100644 --- a/Modules/Core/Metadata/include/otbSarImageMetadataInterface.h +++ b/Modules/Core/Metadata/include/otbSarImageMetadataInterface.h @@ -19,9 +19,11 @@ #define __otbSarImageMetadataInterface_h #include <string> - +#include <vector> #include "otbImageMetadataInterfaceBase.h" #include "itkPointSet.h" +#include "otbSarCalibrationLookupData.h" +#include "otbStringUtils.h" namespace otb { @@ -50,11 +52,25 @@ public: typedef Superclass::VectorType VectorType; typedef Superclass::VariableLengthVectorType VariableLengthVectorType; typedef Superclass::ImageKeywordlistType ImageKeywordlistType; + typedef Superclass::UIntVectorType UIntVectorType; + typedef Superclass::StringVectorType StringVectorType; typedef itk::PointSet<double, 2> PointSetType; typedef PointSetType::Pointer PointSetPointer; typedef double RealType; typedef PointSetType::PointType PointType; + typedef SarCalibrationLookupData LookupDataType; + typedef LookupDataType::Pointer LookupDataPointerType; + + virtual void CreateCalibrationLookupData(const short t); + const LookupDataPointerType GetCalibrationLookupData(const short type); + + bool HasCalibrationLookupDataFlag() const; + + void SetCalibrationLookupData(LookupDataType* lut) + { + m_SarLut = lut; + } virtual RealType GetRadiometricCalibrationScale() const; @@ -75,10 +91,18 @@ public: virtual double GetRadarFrequency () const = 0; virtual double GetCenterIncidenceAngle() const = 0; + + + virtual double GetRescalingFactor() const; + + virtual const std::string GetProductType() const; + + virtual const std::string GetAcquisitionMode() const; + /** Get the enhanced band names (No enhanced band name support for SAR) */ - std::vector<std::string> GetEnhancedBandNames() const + StringVectorType GetEnhancedBandNames() const { - std::vector<std::string> nothing; + StringVectorType nothing; return nothing; } @@ -91,9 +115,13 @@ protected: void PrintSelf(std::ostream& os, itk::Indent indent) const; + LookupDataPointerType m_SarLut; + + private: SarImageMetadataInterface(const Self &); //purposely not implemented void operator =(const Self&); //purposely not implemented + }; } // end namespace otb diff --git a/Modules/Core/Metadata/include/otbSentinel1ImageMetadataInterface.h b/Modules/Core/Metadata/include/otbSentinel1ImageMetadataInterface.h new file mode 100644 index 0000000000000000000000000000000000000000..c67ead32a4656b69c84f35dfabb0072dfd9d8e1a --- /dev/null +++ b/Modules/Core/Metadata/include/otbSentinel1ImageMetadataInterface.h @@ -0,0 +1,236 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef __otbSentinel1ImageMetadataInterface_h +#define __otbSentinel1ImageMetadataInterface_h + +#include "otbSarImageMetadataInterface.h" + + +namespace otb +{ +/** \class Sentinel1ImageMetadataInterface + * + * \brief Creation of an "otb" Sentinel1ImageMetadataInterface that gets metadata. + * + * + * \ingroup OTBMetadata + */ + +class ITK_ABI_EXPORT Sentinel1ImageMetadataInterface : public SarImageMetadataInterface +{ +public: + + typedef Sentinel1ImageMetadataInterface Self; + typedef SarImageMetadataInterface Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + + /** Run-time type information (and related methods). */ + itkTypeMacro(Sentinel1ImageMetadataInterface, SarImageMetadataInterface); + + typedef Superclass::ImageType ImageType; + typedef Superclass::MetaDataDictionaryType MetaDataDictionaryType; + typedef Superclass::VectorType VectorType; + typedef Superclass::VariableLengthVectorType VariableLengthVectorType; + typedef Superclass::ImageKeywordlistType ImageKeywordlistType; + typedef Superclass::RealType RealType; + typedef Superclass::LookupDataPointerType LookupDataPointerType; + + /** Get the imaging production day from the ossim metadata : DATASET_PRODUCTION_DATE metadata variable */ + int GetProductionDay() const; + + /** Get the imaging production month from the ossim metadata : DATASET_PRODUCTION_DATE metadata variable */ + int GetProductionMonth() const; + + /** Get the imaging production year from the ossim metadata : DATASET_PRODUCTION_DATE metadata variable */ + int GetProductionYear() const; + + /** check sensor ID */ + bool CanRead() const; + + int GetDay() const; + + int GetMonth() const; + + int GetYear() const; + + int GetHour() const; + + int GetMinute() const; + + UIntVectorType GetDefaultDisplay() const; + + /*SarImageMetadataInterface pure virutals rituals */ + double GetPRF() const; + + double GetRSF() const; + + double GetRadarFrequency() const; + + double GetCenterIncidenceAngle() const; + + /*get lookup data for calulating backscatter */ + void CreateCalibrationLookupData(const short type); + +protected: + + /* class ctor */ + Sentinel1ImageMetadataInterface(); + + /* class dtor */ + virtual ~Sentinel1ImageMetadataInterface() {} + +private: + + Sentinel1ImageMetadataInterface(const Self &); //purposely not implemented + void operator =(const Self&); //purposely not implemented + +/* Helper function to parse date and time into a std::vector<std::string> + * using boost::split() expect date time in yyyy-mm-ddThh:mm:ss.ms + * the date-time string is to be found in keywordlist with key 'key' + * fills argument dateFields of type std::vector<std::string> which is mutable! + * TODO: move this method into base class + */ + void ParseDateTime(const char* key, std::vector<int>& dateFields) const; + + mutable std::vector<int> m_ProductionDateFields; + mutable std::vector<int> m_AcquisitionDateFields; +}; + + + +struct Sentinel1CalibrationStruct { + +public: + double timeMJD; + int line; + std::vector<int> pixels; + std::vector<float> vect; +}; + +class Sentinel1CalibrationLookupData : public SarCalibrationLookupData +{ + +public: + + + /** Standard typedefs */ + typedef Sentinel1CalibrationLookupData Self; + typedef SarCalibrationLookupData Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Creation through the object factory */ + itkNewMacro(Self); + + /** RTTI */ + itkTypeMacro(Sentinel1CalibrationLookupData, SarCalibrationLookupData); + + typedef itk::IndexValueType IndexValueType; + + Sentinel1CalibrationLookupData() + : firstLineTime(0.) + , lastLineTime(0.) + , numOfLines(0) + , count(0) + , lineTimeInterval(0.) + { + + } + + virtual ~Sentinel1CalibrationLookupData() + { + + } + + void InitParameters(short type, double ft, double lt, + int lines, int c, + std::vector<Sentinel1CalibrationStruct> vlist) + { + firstLineTime = ft; + lastLineTime = lt; + numOfLines = lines; + count = c; + calibrationVectorList = vlist; + this->SetType(type); + lineTimeInterval = (lt - ft) / ((lines - 1) * 1.0); + } + + virtual double GetValue(const IndexValueType x, const IndexValueType y) + { + const int calVecIdx = GetVectorIndex(y); + const Sentinel1CalibrationStruct vec0 = calibrationVectorList[calVecIdx]; + const Sentinel1CalibrationStruct vec1 = calibrationVectorList[calVecIdx + 1]; + const double azTime = firstLineTime + y * lineTimeInterval; + const double muY = (azTime - vec0.timeMJD) /(vec1.timeMJD - vec0.timeMJD); + const int pixelIdx = GetPixelIndex(x, calibrationVectorList[calVecIdx]); + const double muX = (static_cast<float>(x) - static_cast<float>(vec0.pixels[pixelIdx])) / (static_cast<float>(vec0.pixels[pixelIdx + 1] - vec0.pixels[pixelIdx])); + const double lutVal = (1 - muY) * ((1 - muX) * vec0.vect[pixelIdx] + muX * vec0.vect[pixelIdx + 1]) + + muY * ((1 - muX) * vec1.vect[pixelIdx] + muX * vec1.vect[pixelIdx + 1]); + return lutVal; + } + + int GetVectorIndex(int y) + { + for (int i = 1; i < count; i++) + { + if (y < calibrationVectorList[i].line) + { + return i - 1; + } + } + return -1; + + } + + int GetPixelIndex(int x, const Sentinel1CalibrationStruct& calVec) + { + const int size = calVec.pixels.size(); + for (int i = 0; i < size; i++) + { + if (x < calVec.pixels[i]) + { + return i - 1; + } + } + return size - 2; + } + +private: + + Sentinel1CalibrationLookupData(const Self&); //purposely not implemented + + void operator =(const Self&); //purposely not implemented + + double firstLineTime; + double lastLineTime; + int numOfLines; + int count; + std::vector<Sentinel1CalibrationStruct> calibrationVectorList; + double lineTimeInterval; + +}; + + +} // end namespace otb + +#endif diff --git a/Modules/Core/Metadata/include/otbSentinel1ImageMetadataInterfaceFactory.h b/Modules/Core/Metadata/include/otbSentinel1ImageMetadataInterfaceFactory.h new file mode 100644 index 0000000000000000000000000000000000000000..76964bb4fc2beca05728862e17f16719e0087041 --- /dev/null +++ b/Modules/Core/Metadata/include/otbSentinel1ImageMetadataInterfaceFactory.h @@ -0,0 +1,69 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef __otbSentinel1ImageMetadataInterfaceFactory_h +#define __otbSentinel1ImageMetadataInterfaceFactory_h + + +#include "itkObjectFactoryBase.h" + +namespace otb +{ +/** \class Sentinel1ImageMetadataInterfaceFactory + * \brief Creating an instance of a ImageMetadataInterface object using object factory. + * + * \ingroup OTBMetadata + */ +class ITK_EXPORT Sentinel1ImageMetadataInterfaceFactory : public itk::ObjectFactoryBase +{ +public: + /** Standard class typedefs. */ + typedef Sentinel1ImageMetadataInterfaceFactory Self; + typedef itk::ObjectFactoryBase Superclass; + typedef itk::SmartPointer<Self> Pointer; + typedef itk::SmartPointer<const Self> ConstPointer; + + /** Class methods used to interface with the registered factories. */ + virtual const char* GetITKSourceVersion(void) const; + virtual const char* GetDescription(void) const; + + /** Method for class instantiation. */ + itkFactorylessNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro(Sentinel1ImageMetadataInterfaceFactory, itk::ObjectFactoryBase); + + /** Register one factory of this type */ + static void RegisterOneFactory(void) + { + Pointer factory = Sentinel1ImageMetadataInterfaceFactory::New(); + itk::ObjectFactoryBase::RegisterFactory(factory); + } + +protected: + Sentinel1ImageMetadataInterfaceFactory(); + virtual ~Sentinel1ImageMetadataInterfaceFactory(); + +private: + Sentinel1ImageMetadataInterfaceFactory(const Self &); //purposely not implemented + void operator =(const Self&); //purposely not implemented + +}; + +} // end namespace otb + +#endif diff --git a/Modules/Core/Metadata/otb-module.cmake b/Modules/Core/Metadata/otb-module.cmake index 240e6a3ee1cec76586a97c0078a34861dfb410ee..6e0e51fa4d48d4a1238a7a8de978f6f1a0a4ddc8 100644 --- a/Modules/Core/Metadata/otb-module.cmake +++ b/Modules/Core/Metadata/otb-module.cmake @@ -5,7 +5,7 @@ are supported. for instance: Pleiades, SPOT6, TerraSar, and so on).") otb_module(OTBMetadata DEPENDS OTBObjectList - OTBBoost + OTBBoostAdapters OTBITK OTBOSSIMAdapters OTBCommon diff --git a/Modules/Core/Metadata/src/CMakeLists.txt b/Modules/Core/Metadata/src/CMakeLists.txt index 458188d5246599d101d8cfa68384704f8e7929ae..77dad8c9f5ae67af5ba6ed436ab72c0954abf9a9 100644 --- a/Modules/Core/Metadata/src/CMakeLists.txt +++ b/Modules/Core/Metadata/src/CMakeLists.txt @@ -1,34 +1,49 @@ set(OTBMetadata_SRC + otbWorldView2ImageMetadataInterfaceFactory.cxx otbWorldView2ImageMetadataInterface.cxx + + otbQuickBirdImageMetadataInterfaceFactory.cxx otbQuickBirdImageMetadataInterface.cxx - otbWorldView2ImageMetadataInterfaceFactory.cxx - otbTerraSarImageMetadataInterface.cxx - otbImageMetadataInterfaceBase.cxx + otbImageMetadataInterfaceFactory.cxx - otbFormosatImageMetadataInterface.cxx + otbImageMetadataInterfaceBase.cxx + otbSpotImageMetadataInterfaceFactory.cxx + otbSpotImageMetadataInterface.cxx + otbDefaultImageMetadataInterfaceFactory.cxx otbSarDefaultImageMetadataInterfaceFactory.cxx otbOpticalDefaultImageMetadataInterfaceFactory.cxx - otbSpotImageMetadataInterface.cxx + otbFormosatImageMetadataInterfaceFactory.cxx + otbFormosatImageMetadataInterface.cxx + otbOpticalImageMetadataInterfaceFactory.cxx + otbOpticalImageMetadataInterface.cxx + otbSpot6ImageMetadataInterfaceFactory.cxx - otbSarImageMetadataInterfaceFactory.cxx otbSpot6ImageMetadataInterface.cxx + + otbIkonosImageMetadataInterfaceFactory.cxx otbIkonosImageMetadataInterface.cxx + + otbPleiadesImageMetadataInterfaceFactory.cxx otbPleiadesImageMetadataInterface.cxx - otbQuickBirdImageMetadataInterfaceFactory.cxx - otbOpticalImageMetadataInterface.cxx - otbIkonosImageMetadataInterfaceFactory.cxx + + otbSarImageMetadataInterfaceFactory.cxx otbSarImageMetadataInterface.cxx - otbPleiadesImageMetadataInterfaceFactory.cxx + otbTerraSarImageMetadataInterfaceFactory.cxx + otbTerraSarImageMetadataInterface.cxx + + otbSentinel1ImageMetadataInterfaceFactory.cxx + otbSentinel1ImageMetadataInterface.cxx + otbNoDataHelper.cxx ) add_library(OTBMetadata ${OTBMetadata_SRC}) -target_link_libraries(OTBMetadata +target_link_libraries(OTBMetadata ${OTBBoost_LIBRARIES} ${OTBCommon_LIBRARIES} ${OTBOSSIMAdapters_LIBRARIES} diff --git a/Modules/Core/Metadata/src/otbImageMetadataInterfaceFactory.cxx b/Modules/Core/Metadata/src/otbImageMetadataInterfaceFactory.cxx index 248a69f7f936040f9c7ebf8f6529b9cc9743dc13..4b554bf6267ff9239d5e2beada80d77a0bae57df 100644 --- a/Modules/Core/Metadata/src/otbImageMetadataInterfaceFactory.cxx +++ b/Modules/Core/Metadata/src/otbImageMetadataInterfaceFactory.cxx @@ -32,6 +32,7 @@ // SAR Sensors #include "otbTerraSarImageMetadataInterfaceFactory.h" +#include "otbSentinel1ImageMetadataInterfaceFactory.h" #include "itkMutexLock.h" #include "itkMutexLockHolder.h" @@ -109,7 +110,9 @@ ImageMetadataInterfaceFactory itk::ObjectFactoryBase::RegisterFactory(FormosatImageMetadataInterfaceFactory::New()); itk::ObjectFactoryBase::RegisterFactory(QuickBirdImageMetadataInterfaceFactory::New()); itk::ObjectFactoryBase::RegisterFactory(WorldView2ImageMetadataInterfaceFactory::New()); - itk::ObjectFactoryBase::RegisterFactory( TerraSarImageMetadataInterfaceFactory::New() ); + itk::ObjectFactoryBase::RegisterFactory(TerraSarImageMetadataInterfaceFactory::New()); + itk::ObjectFactoryBase::RegisterFactory(Sentinel1ImageMetadataInterfaceFactory::New()); + firstTime = false; } } diff --git a/Modules/Core/Metadata/src/otbSarImageMetadataInterface.cxx b/Modules/Core/Metadata/src/otbSarImageMetadataInterface.cxx index d1a46a96c6deb37dcdd80531bba5ba1ce72c5332..4dc45688d6f3e86a3637a86ae5735456627062f8 100644 --- a/Modules/Core/Metadata/src/otbSarImageMetadataInterface.cxx +++ b/Modules/Core/Metadata/src/otbSarImageMetadataInterface.cxx @@ -28,8 +28,90 @@ namespace otb SarImageMetadataInterface ::SarImageMetadataInterface() { + } +const std::string +SarImageMetadataInterface +::GetProductType() const +{ + const MetaDataDictionaryType& dict = this->GetMetaDataDictionary(); + if (!this->CanRead()) + { + itkExceptionMacro(<< "Invalid Metadata"); + } + + ImageKeywordlistType imageKeywordlist; + + if (dict.HasKey(MetaDataKey::OSSIMKeywordlistKey)) + { + itk::ExposeMetaData<ImageKeywordlistType>(dict, MetaDataKey::OSSIMKeywordlistKey, imageKeywordlist); + } + + if (imageKeywordlist.HasKey("support_data.product_type")) + { + const std::string product_type = imageKeywordlist.GetMetadataByKey("support_data.product_type"); + return product_type; + } + return ""; +} + +const std::string +SarImageMetadataInterface +::GetAcquisitionMode() const +{ + const MetaDataDictionaryType& dict = this->GetMetaDataDictionary(); + if (!this->CanRead()) + { + itkExceptionMacro(<< "Invalid Metadata"); + } + + ImageKeywordlistType imageKeywordlist; + + if (dict.HasKey(MetaDataKey::OSSIMKeywordlistKey)) + { + itk::ExposeMetaData<ImageKeywordlistType>(dict, MetaDataKey::OSSIMKeywordlistKey, imageKeywordlist); + } + + if (imageKeywordlist.HasKey("support_data.acquisition_mode")) + { + const std::string acquisition_mode = imageKeywordlist.GetMetadataByKey("support_data.acquisition_mode"); + return acquisition_mode; + } + return ""; +} + +void +SarImageMetadataInterface +::CreateCalibrationLookupData(const short itkNotUsed(t)) +{ + +} + +const SarImageMetadataInterface::LookupDataPointerType +SarImageMetadataInterface +::GetCalibrationLookupData(const short type) +{ + if (HasCalibrationLookupDataFlag()) + { + CreateCalibrationLookupData(type); + } + + return m_SarLut; +} + +bool +SarImageMetadataInterface +::HasCalibrationLookupDataFlag() const +{ + const ImageKeywordlist imageKeywordlist = this->GetImageKeywordlist(); + /* checking if the key exist is more than enough */ + if (imageKeywordlist.HasKey("support_data.calibration_lookup_flag")) + { + return true; + } + return false; +} SarImageMetadataInterface::RealType SarImageMetadataInterface @@ -63,7 +145,6 @@ SarImageMetadataInterface return SarImageMetadataInterface::GetConstantValuePointSet(0.0); } - SarImageMetadataInterface::PointSetPointer SarImageMetadataInterface ::GetRadiometricCalibrationAntennaPatternNewGain() const @@ -106,6 +187,12 @@ SarImageMetadataInterface return polynomialDegree; } +double +SarImageMetadataInterface +::GetRescalingFactor() const +{ + return 1.0; +} SarImageMetadataInterface::IndexType SarImageMetadataInterface ::GetRadiometricCalibrationNoisePolynomialDegree() const diff --git a/Modules/Core/Metadata/src/otbSarImageMetadataInterfaceFactory.cxx b/Modules/Core/Metadata/src/otbSarImageMetadataInterfaceFactory.cxx index 8075a2303c4dd83a1aa58e95ef490cb852bb7fe3..0cb27515e7e87d6f06f8c5390162500e6caa4509 100644 --- a/Modules/Core/Metadata/src/otbSarImageMetadataInterfaceFactory.cxx +++ b/Modules/Core/Metadata/src/otbSarImageMetadataInterfaceFactory.cxx @@ -22,6 +22,7 @@ // SAR Sensors #include "otbTerraSarImageMetadataInterfaceFactory.h" +#include "otbSentinel1ImageMetadataInterfaceFactory.h" #include "itkMutexLock.h" #include "itkMutexLockHolder.h" @@ -78,7 +79,8 @@ SarImageMetadataInterfaceFactory itk::MutexLockHolder<itk::SimpleMutexLock> mutexHolder(mutex); if (firstTime) { - itk::ObjectFactoryBase::RegisterFactory( TerraSarImageMetadataInterfaceFactory::New() ); + itk::ObjectFactoryBase::RegisterFactory(TerraSarImageMetadataInterfaceFactory::New()); + itk::ObjectFactoryBase::RegisterFactory(Sentinel1ImageMetadataInterfaceFactory::New()); firstTime = false; } } diff --git a/Modules/Core/Metadata/src/otbSentinel1ImageMetadataInterface.cxx b/Modules/Core/Metadata/src/otbSentinel1ImageMetadataInterface.cxx new file mode 100644 index 0000000000000000000000000000000000000000..daac6d7c363cabf02cf7036876653768b23144b3 --- /dev/null +++ b/Modules/Core/Metadata/src/otbSentinel1ImageMetadataInterface.cxx @@ -0,0 +1,339 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "otbSarImageMetadataInterface.h" +#include "otbSentinel1ImageMetadataInterface.h" + +#include "otbMacro.h" +#include "itkMetaDataObject.h" +#include "otbImageKeywordlist.h" + +//useful constants +#include <otbMath.h> + +namespace otb +{ + +Sentinel1ImageMetadataInterface +::Sentinel1ImageMetadataInterface() +{ + +} + +bool +Sentinel1ImageMetadataInterface::CanRead() const +{ + std::string sensorID = GetSensorID(); + + if (sensorID.find("SENTINEL-1") != std::string::npos) + { + return true; + } + else + return false; +} + +void +Sentinel1ImageMetadataInterface +::CreateCalibrationLookupData(const short type) + { + bool sigmaLut = false; + bool betaLut = false; + bool gammaLut = false; + bool dnLut = false; + + switch (type) + { + case SarCalibrationLookupData::BETA: + { + betaLut = true; + } + break; + + case SarCalibrationLookupData::GAMMA: + { + gammaLut = true; + } + break; + + case SarCalibrationLookupData::DN: + { + dnLut = true; + } + break; + + case SarCalibrationLookupData::SIGMA: + default: + sigmaLut = true; + break; + } + + const ImageKeywordlistType imageKeywordlist = this->GetImageKeywordlist(); + + const double firstLineTime = Utils::LexicalCast<double>(imageKeywordlist.GetMetadataByKey("calibration.startTime"), "calibration.startTime(double)"); + + const double lastLineTime = Utils::LexicalCast<double>(imageKeywordlist.GetMetadataByKey("calibration.stopTime"), "calibration.stopTime(double)"); + + const std::string bandPrefix = "Band[0]."; //make && use GetBandPrefix(subSwath, polarisation) + + const int numOfLines = Utils::LexicalCast<int>(imageKeywordlist.GetMetadataByKey(bandPrefix + "number_lines"), bandPrefix + "number_lines(int)"); + + const int count = Utils::LexicalCast<int>(imageKeywordlist.GetMetadataByKey("calibration.count"), "calibration.count"); + + std::vector<Sentinel1CalibrationStruct> calibrationVectorList(count); + + for(int i = 0; i < count; i++) + { + Sentinel1CalibrationStruct calibrationVector; + + std::stringstream prefix; + prefix << "calibration.calibrationVector[" << i << "]."; + + calibrationVector.line = Utils::LexicalCast<int>(imageKeywordlist.GetMetadataByKey(prefix.str() + "line"), prefix.str() + "line"); + + calibrationVector.timeMJD = Utils::LexicalCast<double>(imageKeywordlist.GetMetadataByKey(prefix.str() + "azimuthTime"), prefix.str() + "azimuthTime"); + + Utils::ConvertStringToVector(imageKeywordlist.GetMetadataByKey(prefix.str() + "pixel"), calibrationVector.pixels, prefix.str() + "pixel"); + + if (sigmaLut) { + Utils::ConvertStringToVector(imageKeywordlist.GetMetadataByKey(prefix.str() + "sigmaNought"), calibrationVector.vect, prefix.str() + "sigmaNought"); + } + + if (betaLut) { + Utils::ConvertStringToVector(imageKeywordlist.GetMetadataByKey(prefix.str() + "betaNought"), calibrationVector.vect, prefix.str() + "betaNought"); + } + + if (gammaLut) { + Utils::ConvertStringToVector(imageKeywordlist.GetMetadataByKey(prefix.str() + "gamma"), calibrationVector.vect, prefix.str() + "gamma"); + } + + if (dnLut) { + Utils::ConvertStringToVector(imageKeywordlist.GetMetadataByKey(prefix.str() + "dn"), calibrationVector.vect, prefix.str() + "dn"); + } + + calibrationVectorList[i] = calibrationVector; + + } + + Sentinel1CalibrationLookupData::Pointer sarLut; + sarLut = Sentinel1CalibrationLookupData::New(); + sarLut->InitParameters(type, firstLineTime, lastLineTime, numOfLines, count, calibrationVectorList); + this->SetCalibrationLookupData(sarLut); + + + } + +void +Sentinel1ImageMetadataInterface +::ParseDateTime(const char* key, std::vector<int>& dateFields) const +{ + if(dateFields.size() < 1 ) + { + //parse from keyword list + if (!this->CanRead()) + { + itkExceptionMacro(<< "Invalid Metadata, not a valid product"); + } + + const ImageKeywordlistType imageKeywordlist = this->GetImageKeywordlist(); + if (!imageKeywordlist.HasKey(key)) + { + itkExceptionMacro( << "no key named " << key ); + } + + const std::string date_time_str = imageKeywordlist.GetMetadataByKey(key); + Utils::ConvertStringToVector(date_time_str, dateFields, key, "T:-."); + } + +} + +int +Sentinel1ImageMetadataInterface::GetYear() const +{ + int value = 0; + ParseDateTime("support_data.image_date", m_AcquisitionDateFields); + if(m_AcquisitionDateFields.size() > 0 ) + { + value = Utils::LexicalCast<int>( m_AcquisitionDateFields[0], "support_data.image_date:year(int)" ); + } + else + { + itkExceptionMacro( << "Invalid year" ); + } + return value; +} + +int +Sentinel1ImageMetadataInterface::GetMonth() const +{ + int value = 0; + ParseDateTime("support_data.image_date", m_AcquisitionDateFields); + if(m_AcquisitionDateFields.size() > 1 ) + { + value = Utils::LexicalCast<int>( m_AcquisitionDateFields[1], "support_data.image_date:month(int)" ); + } + else + { + itkExceptionMacro( << "Invalid month" ); + } + return value; +} + +int +Sentinel1ImageMetadataInterface::GetDay() const +{ + int value = 0; + ParseDateTime("support_data.image_date", m_AcquisitionDateFields); + if(m_AcquisitionDateFields.size() > 2 ) + { + value = Utils::LexicalCast<int>( m_AcquisitionDateFields[2], "support_data.image_date:day(int)"); + } + else + { + itkExceptionMacro( << "Invalid day" ); + } + return value; +} + +int +Sentinel1ImageMetadataInterface::GetHour() const +{ + int value = 0; + ParseDateTime("support_data.image_date", m_AcquisitionDateFields); + if(m_AcquisitionDateFields.size() > 3 ) + { + value = Utils::LexicalCast<int>( m_AcquisitionDateFields[3], "support_data.image_date:hour(int)"); + } + else + { + itkExceptionMacro( << "Invalid hour" ); + } + return value; +} + +int +Sentinel1ImageMetadataInterface::GetMinute() const +{ + int value = 0; + ParseDateTime("support_data.image_date", m_AcquisitionDateFields); + if(m_AcquisitionDateFields.size() > 4 ) + { + value = Utils::LexicalCast<int>( m_AcquisitionDateFields[4], "support_data.image_date:minute(int)"); + } + else + { + itkExceptionMacro( << "Invalid minute" ); + } + return value; +} + +int +Sentinel1ImageMetadataInterface::GetProductionYear() const +{ + int value = 0; + ParseDateTime("support_data.date", m_ProductionDateFields); + if(m_ProductionDateFields.size() > 0 ) + { + value = Utils::LexicalCast<int>( m_ProductionDateFields[0], "support_data.date:year(int)" ); + } + else + { + itkExceptionMacro( << "Invalid production year" ); + } + return value; + +} + +int +Sentinel1ImageMetadataInterface::GetProductionMonth() const +{ + int value = 0; + ParseDateTime("support_data.date", m_ProductionDateFields); + if(m_ProductionDateFields.size() > 1 ) + { + value = Utils::LexicalCast<int>( m_ProductionDateFields[1], "support_data.date:month(int)" ); + } + else + { + itkExceptionMacro( << "Invalid production month" ); + } + return value; +} + +int +Sentinel1ImageMetadataInterface::GetProductionDay() const +{ + int value = 0; + ParseDateTime("support_data.date", m_ProductionDateFields); + if(m_ProductionDateFields.size() > 2 ) + { + value = Utils::LexicalCast<int>( m_ProductionDateFields[2], "support_data.date:day(int)" ); + } + else + { + itkExceptionMacro( << "Invalid production day" ); + } + return value; +} + +double +Sentinel1ImageMetadataInterface::GetPRF() const +{ + double value = 0; + const ImageKeywordlistType imageKeywordlist = this->GetImageKeywordlist(); + if (!imageKeywordlist.HasKey("support_data.pulse_repetition_frequency")) + { + return value; + } + + value = Utils::LexicalCast<double>( imageKeywordlist.GetMetadataByKey("support_data.pulse_repetition_frequency"), + "support_data.pulse_repetition_frequency(double)" ); + + return value; +} + + +Sentinel1ImageMetadataInterface::UIntVectorType +Sentinel1ImageMetadataInterface::GetDefaultDisplay() const +{ + UIntVectorType rgb(3); + rgb[0] = 0; + rgb[1] = 0; + rgb[2] = 0; + return rgb; +} + +double +Sentinel1ImageMetadataInterface::GetRSF() const +{ + return 0; +} + +double +Sentinel1ImageMetadataInterface::GetRadarFrequency() const +{ + return 0; +} + +double +Sentinel1ImageMetadataInterface::GetCenterIncidenceAngle() const +{ + return 0; +} + +} // end namespace otb diff --git a/Modules/Core/Metadata/src/otbSentinel1ImageMetadataInterfaceFactory.cxx b/Modules/Core/Metadata/src/otbSentinel1ImageMetadataInterfaceFactory.cxx new file mode 100644 index 0000000000000000000000000000000000000000..424f825c20ff9e735ab582d44b1519e430374f73 --- /dev/null +++ b/Modules/Core/Metadata/src/otbSentinel1ImageMetadataInterfaceFactory.cxx @@ -0,0 +1,58 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#include <typeinfo> +#include <cassert> + +#include "otbSentinel1ImageMetadataInterfaceFactory.h" +#include "otbSentinel1ImageMetadataInterface.h" + +#include "itkCreateObjectFunction.h" +#include "itkVersion.h" + +namespace otb +{ +Sentinel1ImageMetadataInterfaceFactory +::Sentinel1ImageMetadataInterfaceFactory() +{ + this->RegisterOverride("SarImageMetadataInterface", + "otbSentinel1ImageMetadataInterface", + "Sentinel1 Metadata Interface", + 1, + itk::CreateObjectFunction<Sentinel1ImageMetadataInterface>::New()); +} + +Sentinel1ImageMetadataInterfaceFactory +::~Sentinel1ImageMetadataInterfaceFactory() +{ +} + +const char* +Sentinel1ImageMetadataInterfaceFactory::GetITKSourceVersion(void) const +{ + return ITK_SOURCE_VERSION; +} + +const char* +Sentinel1ImageMetadataInterfaceFactory::GetDescription() const +{ + return "Sentinel1 Metadata Interface Factory, handle Sentinel1 metadata in OTB"; +} + +} // end namespace otb diff --git a/Modules/Core/Metadata/test/CMakeLists.txt b/Modules/Core/Metadata/test/CMakeLists.txt index b48fbffaef79197293daba9fec698e7fe0581bfb..7cf31ac3f3b85b70acc2b6bcb2d192a147e4532c 100644 --- a/Modules/Core/Metadata/test/CMakeLists.txt +++ b/Modules/Core/Metadata/test/CMakeLists.txt @@ -19,10 +19,12 @@ otbSpotImageMetadataInterfaceNew.cxx otbQuickBirdImageMetadataInterfaceNew.cxx otbIkonosImageMetadataInterfaceNew.cxx otbTerraSarImageMetadataInterfaceNew.cxx +otbSentinel1ImageMetadataInterfaceNew.cxx otbWorldView2ImageMetadataInterfaceNew.cxx otbDefaultImageMetadataInterface.cxx otbImageMetadataInterfaceTest2.cxx otbNoDataHelperTest.cxx +otbSarCalibrationLookupDataTest.cxx ) add_executable(otbMetadataTestDriver ${OTBMetadataTests}) @@ -74,6 +76,17 @@ otb_add_test(NAME ioTvSarImageMetadataInterfaceTest_TSX1PANGKALANBUUNUsingHHCosF ${TEMP}/ioTvSarImageMetadataInterface_TSX1PANGKALANBUUNUsingHHCosFile.txt ) +otb_add_test(NAME ioTvImageMetadataInterfaceBaseTest_Sentinel1 COMMAND otbMetadataTestDriver + --compare-ascii ${EPSILON_9} ${BASELINE_FILES}/ioTvImageMetadataInterfaceBase_Sentinel1.txt + ${TEMP}/ioTvImageMetadataInterfaceBase_Sentinel1.txt + otbImageMetadataInterfaceBaseTest + LARGEINPUT{SENTINEL1/S1A_S6_SLC__1SSV_20150619T195043/measurement/s1a-s6-slc-vv-20150619t195043-20150619t195101-006447-00887d-001.tiff} + ${TEMP}/ioTvImageMetadataInterfaceBase_Sentinel1.txt + ) + +otb_add_test(NAME ioTuSentinel1ImageMetadataInterfaceNew COMMAND otbMetadataTestDriver + otbSentinel1ImageMetadataInterfaceNew ) + otb_add_test(NAME ioTuDefaultImageMetadataInterfaceFactoryNew COMMAND otbMetadataTestDriver otbDefaultImageMetadataInterfaceFactoryNew ) @@ -353,6 +366,13 @@ foreach( current_file ${GenericTestSPOT6_DATA_INPUTS} ) ) endforeach() - otb_add_test(NAME coreMetaDataNoDataHelperTest COMMAND otbMetadataTestDriver otbNoDataHelperTest) + +otb_add_test(NAME ioTvSarCalibrationLookupDataTest_SENTINEL1 COMMAND otbMetadataTestDriver + --compare-ascii ${NOTOL} ${BASELINE_FILES}/ioTvSarCalibrationLookupDataTest_SENTINEL1.txt + ${TEMP}/ioTvSarCalibrationLookupDataTest_SENTINEL1.txt + otbSarCalibrationLookupDataTest + ${INPUTDATA}/SENTINEL1_SLC_S6_1S_extract_300_300.tif?&geom=${INPUTDATA}/SENTINEL1_SLC_S6_1S_extract_300_300.geom + ${TEMP}/ioTvSarCalibrationLookupDataTest_SENTINEL1.txt + ) \ No newline at end of file diff --git a/Modules/Core/Metadata/test/otbMetadataTestDriver.cxx b/Modules/Core/Metadata/test/otbMetadataTestDriver.cxx index cd06f2f46e9f46fb412b1f30a278374070ac7405..9b48c72a5bb07d49db1b90cf2e8bc0da4e95aa5e 100644 --- a/Modules/Core/Metadata/test/otbMetadataTestDriver.cxx +++ b/Modules/Core/Metadata/test/otbMetadataTestDriver.cxx @@ -18,8 +18,10 @@ void RegisterTests() REGISTER_TEST(otbQuickBirdImageMetadataInterfaceNew); REGISTER_TEST(otbIkonosImageMetadataInterfaceNew); REGISTER_TEST(otbTerraSarImageMetadataInterfaceNew); + REGISTER_TEST(otbSentinel1ImageMetadataInterfaceNew); REGISTER_TEST(otbWorldView2ImageMetadataInterfaceNew); REGISTER_TEST(otbDefaultImageMetadataInterface); REGISTER_TEST(otbImageMetadataInterfaceTest2); REGISTER_TEST(otbNoDataHelperTest); + REGISTER_TEST(otbSarCalibrationLookupDataTest); } diff --git a/Modules/Core/Metadata/test/otbSarCalibrationLookupDataTest.cxx b/Modules/Core/Metadata/test/otbSarCalibrationLookupDataTest.cxx new file mode 100644 index 0000000000000000000000000000000000000000..5d323c95d9f81644e7256057177b01b4e3e25875 --- /dev/null +++ b/Modules/Core/Metadata/test/otbSarCalibrationLookupDataTest.cxx @@ -0,0 +1,75 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + +#include <iostream> +#include "itkMacro.h" +#include "otbImage.h" +#include "otbImageFileReader.h" +#include "otbSarImageMetadataInterfaceFactory.h" + +int otbSarCalibrationLookupDataTest(int argc, char* argv[]) +{ + typedef double RealType; + typedef otb::SarImageMetadataInterface ImageMetadataInterfaceType; + typedef otb::SarCalibrationLookupData LookupDataType; + typedef otb::Image<double, 2> InputImageType; + typedef otb::ImageFileReader<InputImageType> ImageReaderType; + + if (argc < 3 ) + { + std::cerr << "Usage: otbSarCalibationLookupDataTest /path/to/input/file /path/to/output/file !"<< std::endl; + return EXIT_FAILURE; + } + ImageReaderType::Pointer reader = ImageReaderType::New(); + reader->SetFileName(argv[1]); + reader->UpdateOutputInformation(); + + const char * outFileName = argv[2]; + std::ofstream outfile; + outfile.open(outFileName); + + ImageMetadataInterfaceType::Pointer imageMetadataInterface = + otb::SarImageMetadataInterfaceFactory::CreateIMI( reader->GetOutput()->GetMetaDataDictionary() ); + + if (!imageMetadataInterface.IsNotNull()) + { + std::cerr << "cannot create a otb::SarImageMetadataInterface for input image." << std::endl; + return EXIT_FAILURE; + } + + const std::string sensorId = imageMetadataInterface->GetSensorID(); + + outfile << sensorId << std::endl; + + LookupDataType::Pointer lookupDataObj = imageMetadataInterface->GetCalibrationLookupData(0); + + if (!lookupDataObj.IsNotNull()) + { + std::cerr << "lookupDataObj is Null"<< std::endl; + return EXIT_FAILURE; + } + + RealType lutVal = static_cast<RealType>(lookupDataObj->GetValue(10,19)); + + outfile << imageMetadataInterface->HasCalibrationLookupDataFlag() << std::endl; + outfile << lutVal << std::endl; + + return EXIT_SUCCESS; + +} diff --git a/Modules/Core/Metadata/test/otbSentinel1ImageMetadataInterfaceNew.cxx b/Modules/Core/Metadata/test/otbSentinel1ImageMetadataInterfaceNew.cxx new file mode 100644 index 0000000000000000000000000000000000000000..c0a805ab1832a490c49fbbf2c1732c239efdbe8b --- /dev/null +++ b/Modules/Core/Metadata/test/otbSentinel1ImageMetadataInterfaceNew.cxx @@ -0,0 +1,32 @@ +/*========================================================================= + + Program: ORFEO Toolbox + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. + See OTBCopyright.txt for details. + + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + + + +#include "itkMacro.h" +#include <iostream> +#include "otbSentinel1ImageMetadataInterface.h" + +int otbSentinel1ImageMetadataInterfaceNew(int itkNotUsed(argc), char * itkNotUsed(argv) []) +{ + otb::Sentinel1ImageMetadataInterface::Pointer object = otb::Sentinel1ImageMetadataInterface::New(); + + std::cout << object << std::endl; + + return EXIT_SUCCESS; +} diff --git a/Modules/Filtering/Polarimetry/include/otbReciprocalHAlphaImageFilter.h b/Modules/Filtering/Polarimetry/include/otbReciprocalHAlphaImageFilter.h index 06a7a949d5ae59d1090521a4a914c50627362a5c..0967d1747196fa2632a926d3eedfe26692a92927 100644 --- a/Modules/Filtering/Polarimetry/include/otbReciprocalHAlphaImageFilter.h +++ b/Modules/Filtering/Polarimetry/include/otbReciprocalHAlphaImageFilter.h @@ -137,6 +137,7 @@ public: plog[k]=0.0; else plog[k]=-p[k]*log(p[k])/log(3.0); + } entropy = 0.0; diff --git a/Modules/Filtering/Polarimetry/include/otbSinclairToReciprocalCoherencyMatrixFunctor.h b/Modules/Filtering/Polarimetry/include/otbSinclairToReciprocalCoherencyMatrixFunctor.h index e1d6743c6f9a4f5e960f1897c457f371f50a305e..7fb9ddc327a721737781b24eb065de7bc07dcf63 100644 --- a/Modules/Filtering/Polarimetry/include/otbSinclairToReciprocalCoherencyMatrixFunctor.h +++ b/Modules/Filtering/Polarimetry/include/otbSinclairToReciprocalCoherencyMatrixFunctor.h @@ -18,8 +18,10 @@ #ifndef __otbSinclairToReciprocalCoherencyMatrixFunctor_h #define __otbSinclairToReciprocalCoherencyMatrixFunctor_h -#include "vcl_complex.h" #include "itkMacro.h" +#include "vcl_complex.h" +#include "otbMath.h" +#include "vnl/vnl_matrix.h" namespace otb { @@ -62,6 +64,7 @@ class SinclairToReciprocalCoherencyMatrixFunctor public: /** Some typedefs. */ typedef typename std::complex <double> ComplexType; + typedef vnl_matrix<ComplexType> VNLMatrixType; typedef typename TOutput::ValueType OutputValueType; itkStaticConstMacro(NumberOfComponentsPerPixel, unsigned int, 6); @@ -75,19 +78,23 @@ public: const ComplexType S_hh = static_cast<ComplexType>(Shh); const ComplexType S_hv = static_cast<ComplexType>(Shv); const ComplexType S_vv = static_cast<ComplexType>(Svv); - - const ComplexType HHPlusVV = S_hh + S_vv; - const ComplexType HHMinusVV = S_hh - S_vv; - const ComplexType twoHV = ComplexType( 2.0 ) * S_hv; - - result[0] = static_cast<OutputValueType>( std::norm(HHPlusVV) ); - result[1] = static_cast<OutputValueType>( HHPlusVV * vcl_conj(HHMinusVV) ); - result[2] = static_cast<OutputValueType>( HHPlusVV * vcl_conj(twoHV) ); - result[3] = static_cast<OutputValueType>( std::norm(HHMinusVV) ); - result[4] = static_cast<OutputValueType>( HHMinusVV *vcl_conj(twoHV) ); - result[5] = static_cast<OutputValueType>( std::norm(twoHV) ); - - result /= 2.0; + + + VNLMatrixType f3p(3, 1, 0.); + f3p[0][0]= (S_hh + S_vv) / ComplexType( std::sqrt(2.0) , 0.0); + f3p[1][0]= (S_hh - S_vv) / ComplexType( std::sqrt(2.0) , 0.0); + f3p[2][0]= ComplexType( std::sqrt(2.0) , 0.0) * S_hv; + + + VNLMatrixType res = f3p*f3p.conjugate_transpose(); + + result[0] = static_cast<OutputValueType>( res[0][0] ); + result[1] = static_cast<OutputValueType>( res[0][1] ); + result[2] = static_cast<OutputValueType>( res[0][2] ); + result[3] = static_cast<OutputValueType>( res[1][1] ); + result[4] = static_cast<OutputValueType>( res[1][2] ); + result[5] = static_cast<OutputValueType>( res[2][2] ); + return (result); } diff --git a/Modules/Filtering/Polarimetry/include/otbSinclairToReciprocalCovarianceMatrixFunctor.h b/Modules/Filtering/Polarimetry/include/otbSinclairToReciprocalCovarianceMatrixFunctor.h index 8ad714abef0d6c103c84e882489cf7d3fa634226..632033676ae0d5b2895f723074d9459a736969ba 100644 --- a/Modules/Filtering/Polarimetry/include/otbSinclairToReciprocalCovarianceMatrixFunctor.h +++ b/Modules/Filtering/Polarimetry/include/otbSinclairToReciprocalCovarianceMatrixFunctor.h @@ -19,6 +19,8 @@ #define __otbSinclairToReciprocalCovarianceMatrixFunctor_h #include "vcl_complex.h" +#include "otbMath.h" +#include "vnl/vnl_matrix.h" namespace otb { @@ -61,6 +63,7 @@ class SinclairToReciprocalCovarianceMatrixFunctor public: /** Some typedefs. */ typedef typename std::complex <double> ComplexType; + typedef vnl_matrix<ComplexType> VNLMatrixType; typedef typename TOutput::ValueType OutputValueType; inline TOutput operator ()(const TInput1& Shh, const TInput2& Shv, const TInput3& Svv) { @@ -72,12 +75,19 @@ public: const ComplexType S_hv = static_cast<ComplexType>(Shv); const ComplexType S_vv = static_cast<ComplexType>(Svv); - result[0] = static_cast<OutputValueType>( std::norm( S_hh ) ); - result[1] = static_cast<OutputValueType>( vcl_sqrt(2.0)*S_hh*vcl_conj(S_hv) ); - result[2] = static_cast<OutputValueType>( S_hh*vcl_conj(S_vv) ); - result[3] = static_cast<OutputValueType>( 2.0*std::norm( S_hv ) ); - result[4] = static_cast<OutputValueType>( vcl_sqrt(2.0)*S_hv*vcl_conj(S_vv) ); - result[5] = static_cast<OutputValueType>( std::norm( S_vv ) ); + VNLMatrixType f3l(3, 1, 0.); + f3l[0][0]=S_hh; + f3l[1][0]=ComplexType(std::sqrt(2.0),0.0)*S_hv; + f3l[2][0]=S_vv; + + VNLMatrixType res = f3l*f3l.conjugate_transpose(); + + result[0] = static_cast<OutputValueType>( res[0][0] ); + result[1] = static_cast<OutputValueType>( res[0][1] ); + result[2] = static_cast<OutputValueType>( res[0][2] ); + result[3] = static_cast<OutputValueType>( res[1][1] ); + result[4] = static_cast<OutputValueType>( res[1][2] ); + result[5] = static_cast<OutputValueType>( res[2][2] ); return (result); } diff --git a/Modules/Filtering/Polarimetry/test/CMakeLists.txt b/Modules/Filtering/Polarimetry/test/CMakeLists.txt index 4d7a2a42b78f04c19a89665141b71f17dd4c4cf7..f69bd683b63d17200a0d8d0a0b79b09b7f46de9c 100644 --- a/Modules/Filtering/Polarimetry/test/CMakeLists.txt +++ b/Modules/Filtering/Polarimetry/test/CMakeLists.txt @@ -109,12 +109,12 @@ otb_add_test(NAME saTvMultiChannelsPolarimetricSynthesisFilter COMMAND otbPolari otb_add_test(NAME saTvMultiChannelsPolarimetricSynthesisFilter_C COMMAND otbPolarimetryTestDriver --compare-image ${EPSILON_7} ${BASELINE}/saTvMultiPolarimetricSynthesis2.tif - ${TEMP}/resMultiPolarimetricSynthesis2.tif + ${TEMP}/resMultiPolarimetricSynthesis2_C.tif otbMultiChannelsPolarimetricSynthesisFilter ${INPUTDATA}/RSAT_imageryC_HH.tif ${INPUTDATA}/RSAT_imageryC_HV.tif ${INPUTDATA}/RSAT_imageryC_VV.tif - ${TEMP}/resMultiPolarimetricSynthesis2.tif + ${TEMP}/resMultiPolarimetricSynthesis2_C.tif 32.0 # PsiI 22.0 # KhiI 58.0 # PsiR @@ -134,13 +134,13 @@ otb_add_test(NAME saTvSinclairImageFilter_SinclairToMueller COMMAND otbPolarimet otb_add_test(NAME saTvSinclairImageFilter_SinclairToMueller_C COMMAND otbPolarimetryTestDriver --compare-image ${EPSILON_7} ${BASELINE}/saTvSinclairImageFilter_SinclairToMueller.tif - ${TEMP}/saTvSinclairImageFilter_SinclairToMueller.tif + ${TEMP}/saTvSinclairImageFilter_SinclairToMueller_C.tif otbSinclairImageFilter SinclairToMuellerMatrix ${INPUTDATA}/RSAT_imageryC_HH.tif ${INPUTDATA}/RSAT_imageryC_HV.tif ${INPUTDATA}/RSAT_imageryC_VV.tif - ${TEMP}/saTvSinclairImageFilter_SinclairToMueller.tif + ${TEMP}/saTvSinclairImageFilter_SinclairToMueller_C.tif ) otb_add_test(NAME saTvSinclairImageFilter_SinclairToCovariance COMMAND otbPolarimetryTestDriver @@ -156,13 +156,13 @@ otb_add_test(NAME saTvSinclairImageFilter_SinclairToCovariance COMMAND otbPolari otb_add_test(NAME saTvSinclairImageFilter_SinclairToCovariance_C COMMAND otbPolarimetryTestDriver --compare-image ${EPSILON_7} ${BASELINE}/saTvSinclairImageFilter_SinclairToCovariance.tif - ${TEMP}/saTvSinclairImageFilter_SinclairToCovariance.tif + ${TEMP}/saTvSinclairImageFilter_SinclairToCovariance_C.tif otbSinclairImageFilter SinclairToCovarianceMatrix ${INPUTDATA}/RSAT_imageryC_HH.tif ${INPUTDATA}/RSAT_imageryC_HV.tif ${INPUTDATA}/RSAT_imageryC_VV.tif - ${TEMP}/saTvSinclairImageFilter_SinclairToCovariance.tif + ${TEMP}/saTvSinclairImageFilter_SinclairToCovariance_C.tif ) otb_add_test(NAME saTuSinclairImageFilterNew COMMAND otbPolarimetryTestDriver @@ -182,13 +182,13 @@ otb_add_test(NAME saTvSinclairImageFilter_SinclairToCircularCovarianceMatrix COM otb_add_test(NAME saTvSinclairImageFilter_SinclairToCircularCovarianceMatrix_C COMMAND otbPolarimetryTestDriver --compare-image ${EPSILON_7} ${BASELINE}/saTvSinclairImageFilter_SinclairToCircularCovarianceMatrix.tif - ${TEMP}/saTvSinclairImageFilter_SinclairToCircularCovarianceMatrix.tif + ${TEMP}/saTvSinclairImageFilter_SinclairToCircularCovarianceMatrix_C.tif otbSinclairImageFilter SinclairToCircularCovarianceMatrix ${INPUTDATA}/RSAT_imageryC_HH.tif ${INPUTDATA}/RSAT_imageryC_HV.tif ${INPUTDATA}/RSAT_imageryC_VV.tif - ${TEMP}/saTvSinclairImageFilter_SinclairToCircularCovarianceMatrix.tif + ${TEMP}/saTvSinclairImageFilter_SinclairToCircularCovarianceMatrix_C.tif ) otb_add_test(NAME saTvSinclairImageFilter_SinclairToCoherency COMMAND otbPolarimetryTestDriver @@ -204,13 +204,13 @@ otb_add_test(NAME saTvSinclairImageFilter_SinclairToCoherency COMMAND otbPolarim otb_add_test(NAME saTvSinclairImageFilter_SinclairToCoherency_C COMMAND otbPolarimetryTestDriver --compare-image ${EPSILON_7} ${BASELINE}/saTvSinclairImageFilter_SinclairToCoherency.tif - ${TEMP}/saTvSinclairImageFilter_SinclairToCoherency.tif + ${TEMP}/saTvSinclairImageFilter_SinclairToCoherency_C.tif otbSinclairImageFilter SinclairToCoherencyMatrix ${INPUTDATA}/RSAT_imageryC_HH.tif ${INPUTDATA}/RSAT_imageryC_HV.tif ${INPUTDATA}/RSAT_imageryC_VV.tif - ${TEMP}/saTvSinclairImageFilter_SinclairToCoherency.tif + ${TEMP}/saTvSinclairImageFilter_SinclairToCoherency_C.tif ) otb_add_test(NAME saTuReciprocalCovarianceToReciprocalCoherencyImageFilterNew COMMAND otbPolarimetryTestDriver @@ -238,13 +238,13 @@ otb_add_test(NAME saTvSinclairReciprocalImageFilter_SinclairToReciprocalCovarian otb_add_test(NAME saTvSinclairReciprocalImageFilter_SinclairToReciprocalCovariance_C COMMAND otbPolarimetryTestDriver --compare-image ${EPSILON_7} ${BASELINE}/saTvSinclairImageFilter_SinclairToReciprocalCovariance.tif - ${TEMP}/saTvSinclairImageFilter_SinclairToReciprocalCovariance.tif + ${TEMP}/saTvSinclairImageFilter_SinclairToReciprocalCovariance_C.tif otbSinclairReciprocalImageFilter SinclairToReciprocalCovarianceMatrix ${INPUTDATA}/RSAT_imageryC_HH.tif ${INPUTDATA}/RSAT_imageryC_HV.tif ${INPUTDATA}/RSAT_imageryC_VV.tif - ${TEMP}/saTvSinclairImageFilter_SinclairToReciprocalCovariance.tif + ${TEMP}/saTvSinclairImageFilter_SinclairToReciprocalCovariance_C.tif ) otb_add_test(NAME saTvSinclairReciprocalImageFilter_SinclairToReciprocalCircularCovarianceMatrix COMMAND otbPolarimetryTestDriver @@ -261,13 +261,13 @@ otb_add_test(NAME saTvSinclairReciprocalImageFilter_SinclairToReciprocalCircular otb_add_test(NAME saTvSinclairReciprocalImageFilter_SinclairToReciprocalCircularCovarianceMatrix_C COMMAND otbPolarimetryTestDriver --compare-image ${EPSILON_7} ${BASELINE}/saTvSinclairImageFilter_SinclairToReciprocalCircularCovarianceMatrix.tif - ${TEMP}/saTvSinclairImageFilter_SinclairToReciprocalCircularCovarianceMatrix.tif + ${TEMP}/saTvSinclairImageFilter_SinclairToReciprocalCircularCovarianceMatrix_C.tif otbSinclairReciprocalImageFilter SinclairToReciprocalCircularCovarianceMatrix ${INPUTDATA}/RSAT_imageryC_HH.tif ${INPUTDATA}/RSAT_imageryC_HV.tif ${INPUTDATA}/RSAT_imageryC_VV.tif - ${TEMP}/saTvSinclairImageFilter_SinclairToReciprocalCircularCovarianceMatrix.tif + ${TEMP}/saTvSinclairImageFilter_SinclairToReciprocalCircularCovarianceMatrix_C.tif ) otb_add_test(NAME saTvSinclairReciprocalImageFilter_SinclairToReciprocalCoherency COMMAND otbPolarimetryTestDriver @@ -283,13 +283,13 @@ otb_add_test(NAME saTvSinclairReciprocalImageFilter_SinclairToReciprocalCoherenc otb_add_test(NAME saTvSinclairReciprocalImageFilter_SinclairToReciprocalCoherency_C COMMAND otbPolarimetryTestDriver --compare-image ${EPSILON_7} ${BASELINE}/saTvSinclairImageFilter_SinclairToReciprocalCoherency.tif - ${TEMP}/saTvSinclairImageFilter_SinclairToReciprocalCoherency.tif + ${TEMP}/saTvSinclairImageFilter_SinclairToReciprocalCoherency_C.tif otbSinclairReciprocalImageFilter SinclairToReciprocalCoherencyMatrix ${INPUTDATA}/RSAT_imageryC_HH.tif ${INPUTDATA}/RSAT_imageryC_HV.tif ${INPUTDATA}/RSAT_imageryC_VV.tif - ${TEMP}/saTvSinclairImageFilter_SinclairToReciprocalCoherency.tif + ${TEMP}/saTvSinclairImageFilter_SinclairToReciprocalCoherency_C.tif ) diff --git a/Modules/IO/ExtendedFilename/src/otbExtendedFilenameHelper.cxx b/Modules/IO/ExtendedFilename/src/otbExtendedFilenameHelper.cxx index eb08b5e874318b3825359a16350774c72a7635a6..e7d77129417b8d6ea4015f210a6eeb314e463cae 100644 --- a/Modules/IO/ExtendedFilename/src/otbExtendedFilenameHelper.cxx +++ b/Modules/IO/ExtendedFilename/src/otbExtendedFilenameHelper.cxx @@ -30,6 +30,7 @@ ExtendedFilenameHelper itkGenericExceptionMacro( << "Filename is NULL" ); } this->m_ExtendedFileName = extFname; + this->m_OptionMap.clear(); std::vector<std::string> tmp1; std::vector<std::string> tmp2; if (!m_ExtendedFileName.empty()) diff --git a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx index 1085a23c6f8b86a0b6b7b4e76925f064e45332d1..37c14462dcafe9c7e086da4a10a00f8b4c3019c4 100644 --- a/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx +++ b/Modules/IO/IOGDAL/src/otbGDALImageIO.cxx @@ -1679,6 +1679,28 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer) { dataset->SetProjection(projectionRef.c_str()); } + else + { + /* -------------------------------------------------------------------- */ + /* Set the RPC coeffs if no projection available (since GDAL 1.10.0) */ + /* -------------------------------------------------------------------- */ +#if GDAL_VERSION_NUM >= 1100000 + ImageKeywordlist otb_kwl; + itk::ExposeMetaData<ImageKeywordlist>(dict, + MetaDataKey::OSSIMKeywordlistKey, + otb_kwl); + if( otb_kwl.GetSize() != 0 ) + { + GDALRPCInfo gdalRpcStruct; + if ( otb_kwl.convertToGDALRPC(gdalRpcStruct) ) + { + char **rpcMetadata = RPCInfoToMD(&gdalRpcStruct); + dataset->SetMetadata(rpcMetadata, "RPC"); + CSLDestroy( rpcMetadata ); + } + } +#endif + } /* -------------------------------------------------------------------- */ /* Set the six coefficients of affine geoTransform */ @@ -1719,23 +1741,6 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer) } } -#if GDAL_VERSION_NUM >= 1100000 - // Report any RPC coefficients (feature available since GDAL 1.10.0) - ImageKeywordlist otb_kwl; - itk::ExposeMetaData<ImageKeywordlist>(dict, - MetaDataKey::OSSIMKeywordlistKey, - otb_kwl); - if( otb_kwl.GetSize() != 0 ) - { - GDALRPCInfo gdalRpcStruct; - if ( otb_kwl.convertToGDALRPC(gdalRpcStruct) ) - { - char **rpcMetadata = RPCInfoToMD(&gdalRpcStruct); - dataset->SetMetadata(rpcMetadata, "RPC"); - CSLDestroy( rpcMetadata ); - } - } -#endif // END diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimPluginProjectionFactory.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimPluginProjectionFactory.cpp index 0da1b33a18dd02fcbc479cfdea9fca1da468288e..dd59bd2d8d9d7db8cad0d02cded1f5a12bab636f 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimPluginProjectionFactory.cpp +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimPluginProjectionFactory.cpp @@ -30,7 +30,7 @@ #include <ossim/base/ossimNotifyContext.h> #include "ossimTileMapModel.h" #include "ossimSpot6Model.h" - +#include "ossimSentinel1Model.h" //*** // Define Trace flags for use within this file: //*** @@ -45,15 +45,16 @@ static ossimTrace traceDebug = ossimTrace("ossimPluginProjectionFactory:debug"); namespace ossimplugins { + bool ossimPluginProjectionFactory::initalized_; -ossimPluginProjectionFactory* ossimPluginProjectionFactory::instance() -{ - static ossimPluginProjectionFactory* factoryInstance = - new ossimPluginProjectionFactory(); + ossimPluginProjectionFactory ossimPluginProjectionFactory::factoryInstance; + + ossimPluginProjectionFactory* ossimPluginProjectionFactory::instance() + { + return initalized_ ? &factoryInstance : 0; + + } - return factoryInstance; -} - ossimProjection* ossimPluginProjectionFactory::createProjection( const ossimFilename& filename, ossim_uint32 /*entryIdx*/)const { @@ -61,14 +62,35 @@ ossimProjection* ossimPluginProjectionFactory::createProjection( ossimRefPtr<ossimProjection> projection = 0; //traceDebug.setTraceFlag(true); - if(traceDebug()) + // Sentinel1 + if ( !projection ) { - ossimNotify(ossimNotifyLevel_DEBUG) - << MODULE << " DEBUG: testing ossimRadarSat2Model" << std::endl; + if(traceDebug()) + { + ossimNotify(ossimNotifyLevel_DEBUG) + << MODULE << " DEBUG: testing ossimSentinel1Model" << std::endl; + } + + ossimRefPtr<ossimSentinel1Model> model = new ossimSentinel1Model(); + if ( model->open(filename) ) + { + projection = model.get(); + } + else + { + model = 0; + } } if ( !projection ) { + + if(traceDebug()) + { + ossimNotify(ossimNotifyLevel_DEBUG) + << MODULE << " DEBUG: testing ossimRadarSat2Model" << std::endl; + } + ossimRefPtr<ossimRadarSat2Model> model = new ossimRadarSat2Model(); if ( model->open(filename) ) { @@ -84,16 +106,16 @@ ossimProjection* ossimPluginProjectionFactory::createProjection( model = 0; } } - - if(traceDebug()) - { - ossimNotify(ossimNotifyLevel_DEBUG) - << MODULE << " DEBUG: testing ossimPleiadesModel" << std::endl; - } // Pleiades if ( !projection ) { + if(traceDebug()) + { + ossimNotify(ossimNotifyLevel_DEBUG) + << MODULE << " DEBUG: testing ossimPleiadesModel" << std::endl; + } + ossimRefPtr<ossimPleiadesModel> model = new ossimPleiadesModel(); if ( model->open(filename) ) { @@ -105,14 +127,14 @@ ossimProjection* ossimPluginProjectionFactory::createProjection( } } - if(traceDebug()) - { - ossimNotify(ossimNotifyLevel_DEBUG) - << MODULE << " DEBUG: testing ossimTerraSarModel" << std::endl; - } - if ( !projection ) { + if(traceDebug()) + { + ossimNotify(ossimNotifyLevel_DEBUG) + << MODULE << " DEBUG: testing ossimTerraSarModel" << std::endl; + } + ossimRefPtr<ossimTerraSarModel> model = new ossimTerraSarModel(); if ( model->open(filename) ) @@ -130,14 +152,15 @@ ossimProjection* ossimPluginProjectionFactory::createProjection( } } - if(traceDebug()) - { - ossimNotify(ossimNotifyLevel_DEBUG) - << MODULE << " DEBUG: testing ossimErsSarModel" << std::endl; - } + // ErsSar if ( !projection ) { + if(traceDebug()) + { + ossimNotify(ossimNotifyLevel_DEBUG) + << MODULE << " DEBUG: testing ossimErsSarModel" << std::endl; + } ossimRefPtr<ossimErsSarModel> model = new ossimErsSarModel(); if ( model->open(filename) ) { @@ -149,14 +172,14 @@ ossimProjection* ossimPluginProjectionFactory::createProjection( } } - if(traceDebug()) - { - ossimNotify(ossimNotifyLevel_DEBUG) - << MODULE << " DEBUG: testing ossimEnvisatSarModel" << std::endl; - } - if (!projection) { + if(traceDebug()) + { + ossimNotify(ossimNotifyLevel_DEBUG) + << MODULE << " DEBUG: testing ossimEnvisatSarModel" << std::endl; + } + ossimRefPtr<ossimEnvisatAsarModel> model = new ossimEnvisatAsarModel(); if (model->open(filename)) { @@ -168,14 +191,14 @@ ossimProjection* ossimPluginProjectionFactory::createProjection( } } - if(traceDebug()) + if (!projection) { - ossimNotify(ossimNotifyLevel_DEBUG) + if(traceDebug()) + { + ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " DEBUG: testing ossimRadarSatModel" << std::endl; - } + } - if (!projection) - { ossimRefPtr<ossimRadarSatModel> model = new ossimRadarSatModel(); if (model->open(filename)) { @@ -187,14 +210,14 @@ ossimProjection* ossimPluginProjectionFactory::createProjection( } } - if(traceDebug()) - { - ossimNotify(ossimNotifyLevel_DEBUG) - << MODULE << " DEBUG: testing ossimAlosPalsarModel" << std::endl; - } - if (!projection) { + if(traceDebug()) + { + ossimNotify(ossimNotifyLevel_DEBUG) + << MODULE << " DEBUG: testing ossimAlosPalsarModel" << std::endl; + } + ossimRefPtr<ossimAlosPalsarModel> model = new ossimAlosPalsarModel(); if (model->open(filename)) { @@ -206,47 +229,52 @@ ossimProjection* ossimPluginProjectionFactory::createProjection( } } - if(traceDebug()) - { - ossimNotify(ossimNotifyLevel_DEBUG) - << MODULE << " DEBUG: testing ossimFormosatModel" << std::endl; - } - - ossimFilename formosatTest = filename; - formosatTest = formosatTest.setExtension("geom"); - if(!formosatTest.exists()) + if (!projection) { - formosatTest = filename.path(); - formosatTest = formosatTest.dirCat(ossimFilename("METADATA.DIM")); - if (formosatTest.exists() == false) + + if(traceDebug()) + { + ossimNotify(ossimNotifyLevel_DEBUG) + << MODULE << " DEBUG: testing ossimFormosatModel" << std::endl; + } + + ossimFilename formosatTest = filename; + formosatTest = formosatTest.setExtension("geom"); + if(!formosatTest.exists()) { formosatTest = filename.path(); - formosatTest = formosatTest.dirCat(ossimFilename("metadata.dim")); + formosatTest = formosatTest.dirCat(ossimFilename("METADATA.DIM")); + if (formosatTest.exists() == false) + { + formosatTest = filename.path(); + formosatTest = formosatTest.dirCat(ossimFilename("metadata.dim")); + } } - } - if(formosatTest.exists()) - { - ossimRefPtr<ossimFormosatDimapSupportData> meta = - new ossimFormosatDimapSupportData; - if(meta->loadXmlFile(formosatTest)) + if(formosatTest.exists()) { - ossimRefPtr<ossimFormosatModel> model = new ossimFormosatModel(meta.get()); - if(!model->getErrorStatus()) + ossimRefPtr<ossimFormosatDimapSupportData> meta = + new ossimFormosatDimapSupportData; + if(meta->loadXmlFile(formosatTest)) { - projection = model.get(); + ossimRefPtr<ossimFormosatModel> model = new ossimFormosatModel(meta.get()); + if(!model->getErrorStatus()) + { + projection = model.get(); + } + model = 0; } - model = 0; } } - if(traceDebug()) - { - ossimNotify(ossimNotifyLevel_DEBUG) - << MODULE << " DEBUG: testing ossimTileMapModel" << std::endl; - } if (!projection) { + if(traceDebug()) + { + ossimNotify(ossimNotifyLevel_DEBUG) + << MODULE << " DEBUG: testing ossimTileMapModel" << std::endl; + } + ossimRefPtr<ossimTileMapModel> model = new ossimTileMapModel(); if (model->open(filename)) { @@ -258,19 +286,20 @@ ossimProjection* ossimPluginProjectionFactory::createProjection( } } - if(traceDebug()) - { - ossimNotify(ossimNotifyLevel_DEBUG) - << MODULE << " DEBUG: testing ossimSpot6Model" << std::endl; - } // Spot6 if ( !projection ) { + if(traceDebug()) + { + ossimNotify(ossimNotifyLevel_DEBUG) + << MODULE << " DEBUG: testing ossimSpot6Model" << std::endl; + } + ossimRefPtr<ossimSpot6Model> model = new ossimSpot6Model(); if ( model->open(filename) ) { - projection = model.get(); + projection = model.get(); } else { @@ -278,6 +307,7 @@ ossimProjection* ossimPluginProjectionFactory::createProjection( } } + //*** // ADD_MODEL: (Please leave this comment for the next programmer) //*** @@ -315,10 +345,10 @@ ossimProjection* ossimPluginProjectionFactory::createProjection( << MODULE << " DEBUG: Entering ...." << std::endl; } - // else if (name == STATIC_TYPE_NAME(ossimCosmoSkymedModel)) - // { - // return new ossimCosmoSkymedModel; - // } + // else if (name == STATIC_TYPE_NAME(ossimCosmoSkymedModel)) + // { + // return new ossimCosmoSkymedModel; + // } if (name == STATIC_TYPE_NAME(ossimRadarSat2Model)) { return new ossimRadarSat2Model(); @@ -359,6 +389,11 @@ ossimProjection* ossimPluginProjectionFactory::createProjection( { return new ossimSpot6Model; } + else if (name == STATIC_TYPE_NAME(ossimSentinel1Model)) + { + return new ossimSentinel1Model; + } + //*** // ADD_MODEL: (Please leave this comment for the next programmer) @@ -474,6 +509,15 @@ ossimProjection* ossimPluginProjectionFactory::createProjection( } } + else if (type == "ossimSentinel1Model") + { + result = new ossimSentinel1Model(); + if ( !result->loadState(kwl, prefix) ) + { + result = 0; + } + } + //*** // ADD_MODEL: (Please leave this comment for the next programmer) //*** @@ -493,7 +537,7 @@ ossimProjection* ossimPluginProjectionFactory::createProjection( ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " DEBUG: End ...." << std::endl; } - + return result.release(); } @@ -515,13 +559,14 @@ void ossimPluginProjectionFactory::getTypeNameList(std::vector<ossimString>& typ typeList.push_back(STATIC_TYPE_NAME(ossimRadarSatModel)); typeList.push_back(STATIC_TYPE_NAME(ossimRadarSat2Model)); typeList.push_back(STATIC_TYPE_NAME(ossimTerraSarModel)); - // result.push_back(STATIC_TYPE_NAME(ossimCosmoSkymedModel)); +// typeList.push_back(STATIC_TYPE_NAME(ossimCosmoSkymedModel)); typeList.push_back(STATIC_TYPE_NAME(ossimEnvisatAsarModel)); typeList.push_back(STATIC_TYPE_NAME(ossimErsSarModel)); typeList.push_back(STATIC_TYPE_NAME(ossimAlosPalsarModel)); typeList.push_back(STATIC_TYPE_NAME(ossimFormosatModel)); typeList.push_back(STATIC_TYPE_NAME(ossimTileMapModel)); typeList.push_back(STATIC_TYPE_NAME(ossimPleiadesModel)); + typeList.push_back(STATIC_TYPE_NAME(ossimSentinel1Model)); typeList.push_back(STATIC_TYPE_NAME(ossimSpot6Model)); //*** @@ -534,9 +579,9 @@ bool ossimPluginProjectionFactory::isTileMap(const ossimFilename& filename)const { ossimFilename temp(filename); temp.downcase(); - + ossimString os = temp.beforePos(4); - + if(temp.ext()=="otb") { return true; diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimPluginProjectionFactory.h b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimPluginProjectionFactory.h index 5205d76900b981971e903c497f4a0ef70ecd7c73..f245079a9735c077e6231e51d507fa550269172f 100644 --- a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimPluginProjectionFactory.h +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimPluginProjectionFactory.h @@ -52,8 +52,29 @@ public: virtual void getTypeNameList(std::vector<ossimString>& typeList)const; protected: - ossimPluginProjectionFactory(){} + bool isTileMap(const ossimFilename& filename) const; + +private: + ossimPluginProjectionFactory() + { + initalized_ = true; + } + + ~ossimPluginProjectionFactory() + { + initalized_ = false; + } + + static bool initalized_; + + static ossimPluginProjectionFactory factoryInstance; + + ossimPluginProjectionFactory(ossimPluginProjectionFactory const&); // Don't + // Implement + + void operator=(ossimPluginProjectionFactory const&); // Don't implement + }; } diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9f45f1625222efb4dbd33b6c6f130686d26ac808 --- /dev/null +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.cpp @@ -0,0 +1,547 @@ +#include "ossimSentinel1Model.h" + +namespace ossimplugins +{ + +// Define Trace flags for use within this file: + static ossimTrace traceExec ("ossimSentinel1Model:exec"); + static ossimTrace traceDebug ("ossimSentinel1Model:debug"); + + RTTI_DEF1(ossimSentinel1Model, "ossimSentinel1Model", ossimSarModel); + +//************************************************************************************************* +// Constructor +//************************************************************************************************* + ossimSentinel1Model::ossimSentinel1Model() + : ossimSarModel() + , theOCN(false) + , theSLC(false) + { + theManifestDoc = new ossimXmlDocument(); + theProduct = new ossimSentinel1ProductDoc(); + this->clearFields(); + + } + + void ossimSentinel1Model::clearFields() + { + theOCN = false; + theSLC = false; + theManifestKwl.clear(); + theManifestFile = ossimFilename::NIL; + theProductXmlFile = ossimFilename::NIL; + theProduct->clearFields(); + + } + + +//************************************************************************************************* +// Constructor +//************************************************************************************************* + ossimSentinel1Model::ossimSentinel1Model(const ossimSentinel1Model& rhs) + :ossimSarModel(rhs) + , theOCN(rhs.theOCN) + , theSLC(rhs.theSLC) + + { + + } + +//************************************************************************************************* +// Destructor +//************************************************************************************************* + ossimSentinel1Model::~ossimSentinel1Model() + { + theProduct = 0; + if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG DESTRUCTOR: ~ossimSentinel1Model(): entering..." << std::endl; + } + +//************************************************************************************************* +// Infamous DUP +//************************************************************************************************* + ossimObject* ossimSentinel1Model::dup() const + { + return new ossimSentinel1Model(*this); + } + +//************************************************************************************************* +// Print +//************************************************************************************************* + std::ostream& ossimSentinel1Model::print(std::ostream& out) const + { + // Capture stream flags since we are going to mess with them. + std::ios_base::fmtflags f = out.flags(); + + out << "\nDump of ossimSentinel1Model at address " << (hex) << this + << (dec) + << "\n------------------------------------------------" + << "\n theImageID = " << theImageID + << "\n theImageSize = " << theImageSize + + << "\n------------------------------------------------" + << "\n " << endl; + + // Set the flags back. + out.flags(f); + return ossimSarModel::print(out); + + } + +//************************************************************************************************* +// Save State +//************************************************************************************************* + bool ossimSentinel1Model::saveState(ossimKeywordlist& kwl, + const char* prefix) const + { + + kwl.add(prefix, + ossimKeywordNames::TYPE_KW, + "ossimSentinel1Model", + true); + + kwl.add("support_data.", + "calibration_lookup_flag", + "true", + true); + + kwl.addList(theManifestKwl, true); + + if(theProduct.get()) + { + kwl.addList(theProduct->getProductKwl(), true); + // theProduct->saveState(kwl, prefix); + } + ossimSarModel::saveState(kwl, prefix); + return true; + } + + +//************************************************************************************************* +// Load State +//************************************************************************************************* + bool ossimSentinel1Model::loadState(const ossimKeywordlist& kwl, + const char* prefix) + { + //theManifestKwl.addList(kwl, true); + + ossimSarModel::loadState(kwl, prefix); + return true; + } + + bool ossimSentinel1Model::findSafeManifest(const ossimFilename& file, ossimFilename& manifestFile) + { + manifestFile = ossimFilename(file.path().path() + "/manifest.safe"); + + if(!manifestFile.exists()) + { + if (traceDebug()) + { + ossimNotify(ossimNotifyLevel_DEBUG) << "manifest.safe " << manifestFile << " doesn't exist ...\n"; + } + return false; + } + return true; + } + + bool ossimSentinel1Model::open(const ossimFilename& file) + { + + static const char MODULE[] = "ossimplugins::ossimSentinel1Model::open"; + //traceDebug.setTraceFlag(true); + + if (traceDebug()) + { + ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n"; + } + + bool result = false; + + if ( !file.exists() || (file.ext().downcase() != "tiff") ) + { + return false; + } + else + { + theGSD.makeNan(); + + ossimFilename safeFile; + bool foundManifestFile = findSafeManifest(file, safeFile); + while (foundManifestFile) + { + if(theManifestDoc.get()) + { + if( !theManifestDoc->openFile(safeFile)) + { + std::cerr << MODULE << "error at line:" << __LINE__ << std::endl; + break; + } + } + else + { + ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " theManifestDoc..\n"; + break; + } + + if ( !this->isSentinel1(safeFile)) + { + std::cerr << MODULE << "error at line:" << __LINE__ << std::endl; + break; + } + + ossimString productFile; + if ( !this->getAnnotationFileLocation(safeFile, "^product")) + { + std::cerr << MODULE << "error at line:" << __LINE__ << std::endl; + break; + } + + // Set the image ID to the scene ID. + if ( !this->getImageId( theImageID ) ) + { + std::cerr << MODULE << "error at line:" << __LINE__ << std::endl; + break; + } + + if ( !this->standAloneProductInformation( ) ) + { + std::cerr << MODULE << "error at line:" << __LINE__ << std::endl; + break; + } + + // Set the sensor ID to the mission ID. + if ( !this->initSensorID( theSensorID ) ) + { + std::cerr << MODULE << "error at line:" << __LINE__ << std::endl; + break; + } + + if ( !this->readProduct( safeFile ) ) + { + std::cerr << MODULE << "error at line:" << __LINE__ << std::endl; + break; + } + + if ( !this->initImageSize( theImageSize ) ) + { + std::cerr << MODULE << "error at line:" << __LINE__ << std::endl; + break; + } + + theImageClipRect = ossimDrect( 0, 0, theImageSize.x-1, theImageSize.y-1 ); + theSubImageOffset.x = 0.0; + theSubImageOffset.y = 0.0; + + if ( !this->initGsd( theGSD ) ) + { + std::cerr << MODULE << "error at line:" << __LINE__ << std::endl; + break; + } + + theMeanGSD = (theGSD.x + theGSD.y)/2.0; + + if ( !this->initSRGR( ) ) + { + std::cerr << MODULE << "error at line:" << __LINE__ << std::endl; + break; + } + + // if ( !theSafeManifest->initPlatformPosition( ) ) + // { + // break; + // } + // else + // { + // std::cerr << MODULE << "error at line:" << __LINE__ << std::endl; + // } + + + return true; + } + +// // If we broke out of the while, something happened... + return false; + } + + } + + + bool ossimSentinel1Model::getImageId( ossimString& s) const + { + ossimString xpath; + xpath = "/xfdu:XFDU/metadataSection/metadataObject/metadataWrap/xmlData/s1sarl1:standAloneProductInformation/s1sarl1:missionDataTakeID"; + return ossim::getPath(xpath, theManifestDoc.get(), s); + } + + bool ossimSentinel1Model::initSensorID(ossimString& s) + { + const ossimRefPtr<ossimXmlNode> safePlatform = theManifestDoc->getRoot()->findFirstNode("metadataSection/metadataObject/metadataWrap/xmlData/safe:platform"); + ossimString familyName, instrumentId; + bool ret1 = safePlatform->getChildTextValue(familyName, "safe:familyName"); + bool ret2 = safePlatform->getChildTextValue(instrumentId, "safe:number"); + + theManifestKwl.add("support_data.", + "instrument", + "S1" + instrumentId, + true); + + s = familyName + instrumentId; + return (ret1 && ret2); + } + + bool ossimSentinel1Model::getAnnotationFileLocation(const ossimFilename &manifestFile, const char* pattern) + { + + static const char MODULE[] = "ossimSentinel1SafeManifest::getAnnotationFileLocation"; + //traceDebug.setTraceFlag(true); + const ossimString prefix = "support_data."; + const ossimString xpath = "/xfdu:XFDU/dataObjectSection/dataObject"; + + vector<ossimRefPtr<ossimXmlNode> > xml_nodes; + + theManifestDoc->findNodes(xpath, xml_nodes); + + ossimRefPtr<ossimXmlNode> dataObjectNode = xml_nodes[0]; + ossimString dataObjectId; + dataObjectNode->getAttributeValue(dataObjectId , "ID"); + + if ( dataObjectId.match(pattern) ) + { + ossim::getPath(xpath + "/byteStream/fileLocation", theManifestDoc.get(), theProductXmlFile); + xml_nodes.clear(); + theManifestDoc->findNodes(xpath + "/byteStream/fileLocation", xml_nodes); + if(xml_nodes.size() < 1 ) + { + std::cerr << "error :" << __LINE__ << std::endl; + return false; + } + xml_nodes[0]->getAttributeValue(theProductXmlFile , "href"); + theProductXmlFile.setPath(manifestFile.path() + "/annotation"); + + } + return true; + } + + + bool ossimSentinel1Model::standAloneProductInformation() + { + static const char MODULE[] = "ossimSentinel1ProductDoc::parseSafe"; + + const ossimString prefix = "support_data."; + + const ossimRefPtr<ossimXmlNode> safeProcessing = theManifestDoc->getRoot()->findFirstNode("metadataSection/metadataObject/metadataWrap/xmlData/safe:processing"); + const ossimRefPtr<ossimXmlNode> facility = safeProcessing->findFirstNode("safe:facility"); + const ossimRefPtr<ossimXmlNode> software = facility->findFirstNode("safe:software"); + const ossimString org = facility->getAttributeValue("organisation"); + const ossimString name = software->getAttributeValue("name"); + const ossimString version = software->getAttributeValue("version"); + + theManifestKwl.add(prefix, + "Processing_system_identifier", + org + " " + name + " " + version, + true); + + theManifestKwl.add(prefix, + ossimKeywordNames::DATE_KW, + safeProcessing->getAttributeValue("start"), + true); + + const ossimRefPtr<ossimXmlNode> acquisitionPeriod = theManifestDoc->getRoot()->findFirstNode("metadataSection/metadataObject/metadataWrap/xmlData/safe:acquisitionPeriod"); + ossimString acqStartTime = acquisitionPeriod->getChildTextValue("safe:startTime"); + + theManifestKwl.add(prefix, + "first_line_time", + acqStartTime, + true); + + theManifestKwl.add(prefix, + "last_line_time", + acquisitionPeriod->getChildTextValue("safe:stopTime"), + true); + //RK + theManifestKwl.add(prefix, + ossimKeywordNames::IMAGE_DATE_KW, + acqStartTime, + true); + + const ossimRefPtr<ossimXmlNode> instrumentNode = + theManifestDoc->getRoot()->findFirstNode("metadataSection/metadataObject/metadataWrap/xmlData/safe:platform/safe:instrument"); + ossimString swath = instrumentNode->getChildTextValue("s1sarl1:swath"); + ossimString acquisition_mode = instrumentNode->getChildTextValue("s1sarl1:mode"); + + if( acquisition_mode.empty()) + { + ossimRefPtr<ossimXmlNode> instrumentModeNode = instrumentNode->findFirstNode("safe:extension/s1sarl1:instrumentMode"); + if(instrumentModeNode.get()) + { + acquisition_mode = instrumentModeNode->getChildTextValue("s1sarl1:mode"); + swath = instrumentModeNode->getChildTextValue("s1sarl1:swath"); + } + } + + theManifestKwl.add(prefix, + "acquisition_mode", + acquisition_mode, + true); + + theManifestKwl.add(prefix, + "swath", + swath, + true); + + if (acquisition_mode == "IW" || acquisition_mode == "EW") + theProduct->setTOPSAR(true); + + const ossimRefPtr<ossimXmlNode> orbitReference = + theManifestDoc->getRoot()->findFirstNode("metadataSection/metadataObject/metadataWrap/xmlData/safe:orbitReference"); + + std::vector<ossimRefPtr<ossimXmlNode> > orbitNumberNodes; + const ossimString orbitReference_xpath = "/xfdu:XFDU/metadataSection/metadataObject/metadataWrap/xmlData/safe:orbitReference"; + theManifestDoc->findNodes(orbitReference_xpath + "/safe:orbitNumber", orbitNumberNodes); + + std::vector<ossimRefPtr<ossimXmlNode> >::const_iterator it = orbitNumberNodes.begin(); + while( it != orbitNumberNodes.end()) + { + const ossimRefPtr<ossimXmlAttribute> attribute = (*it)->findAttribute("type"); + if( attribute.get() ) + { + if( attribute->getValue() == "start" ) + { + theManifestKwl.add(prefix, "abs_orbit", (*it)->getText(), true); + break; + } + } + ++it; + } + + orbitNumberNodes.clear(); + theManifestDoc->findNodes(orbitReference_xpath + "/safe:relativeOrbitNumber", orbitNumberNodes); + + std::vector<ossimRefPtr<ossimXmlNode> >::const_iterator it2 = orbitNumberNodes.begin(); + while( it2 != orbitNumberNodes.end()) + { + const ossimRefPtr<ossimXmlAttribute> attribute = (*it2)->findAttribute("start"); + if( attribute.get() ) + { + if( attribute->getValue() == "start" ) + { + theManifestKwl.add(prefix, "rel_orbit", (*it2)->getText(), true); + break; + } + } + ++it2; + } + + theManifestKwl.add(prefix, "orbit_cycle", orbitReference->getChildTextValue("safe:cycleNumber"), true); + + ossimString orbit_pass = ""; + orbit_pass = orbitReference->getChildTextValue("s1:pass"); + + if( orbit_pass.empty() ) + { + orbit_pass = orbitReference->getChildTextValue("safe:extension/s1:orbitProperties/s1:pass"); + } + + theManifestKwl.add(prefix, + "orbit_pass", + orbit_pass, + true); + + ossimString productType = "unknown"; + const ossimRefPtr<ossimXmlNode> standAloneProductInformation = + theManifestDoc->getRoot()->findFirstNode("metadataSection/metadataObject/metadataWrap/xmlData/s1sarl1:standAloneProductInformation"); + + if (theOCN) + { + productType = "OCN"; + } + else + { + if (standAloneProductInformation.get()) + productType = standAloneProductInformation->getChildTextValue("s1sarl1:productType"); + } + + theManifestKwl.add(prefix, + "product_type", + productType, + true); + + if( productType.contains("SLC" ) ) + { + //ossimKeywordNames::PIXEL_TYPE_KW; RK + theManifestKwl.add("sample_type", "COMPLEX", true); + theProduct->setSLC(true); + + } + else + { + theManifestKwl.add("sample_type", "DETECTED", true); + theManifestKwl.add(prefix, "srgr_flag", "true", true); + } + + return true; + } + + bool ossimSentinel1Model::isSentinel1(const ossimFilename &manifestFile ) + { + theOCN = isLevel2(manifestFile); + if( isLevel1(manifestFile) || theOCN || isLevel0(manifestFile)) + return true; + else + return false; + } + + bool ossimSentinel1Model::isLevel1(const ossimFilename& file) + { + bool productXmlCheck = checkDirectory(file, "annotation", ".xml"); + + return productXmlCheck && checkDirectory(file, "measurement", ".tiff"); + } + + bool ossimSentinel1Model::isLevel2(const ossimFilename& file) + { + + return checkDirectory(file, "measurement",".nc"); + } + + bool ossimSentinel1Model::isLevel0(const ossimFilename& file) + { + return checkDirectory(file, "measurement",".dat"); + } + + bool ossimSentinel1Model::checkDirectory(const ossimFilename& file, const char* d, const char* ext) + { + //check dir is valid first + ossimDirectory dir = ossimDirectory(file.path() + "/" + d + "/"); + std::vector<ossimFilename> result; + dir.findAllFilesThatMatch(result, ext); + if ( result.size() < 1 ) + { + if (traceExec()) + { + ossimNotify(ossimNotifyLevel_FATAL) + << " DEBUG:" << " checkDirectory failed for: " << file.path() << "/" << d << " with ext ="<< ext << std::endl; + } + return false; + } + + return true; + } + + bool ossimSentinel1Model::readProduct(const ossimFilename &manifestFile ) + { + theProduct->setMetadataDirectory( manifestFile.path() ); + bool ret = theProduct->readProductMetadata( ); + if ( ret ) + { + theProduct->readCalibrationMetadata(); + theProduct->readNoiseMetadata(); + } + else + { + ossimNotify(ossimNotifyLevel_FATAL) << " theProduct->readProductMetadata() failed" << std::endl; + } + + return true; + } + +} //end namespace diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.h b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.h new file mode 100644 index 0000000000000000000000000000000000000000..65b1fdc77e0d95a76fc96fd3bf2d78e80f11e610 --- /dev/null +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1Model.h @@ -0,0 +1,160 @@ +//---------------------------------------------------------------------------- +// +// "Copyright Centre National d'Etudes Spatiales" +// +// License: LGPL-2 +// +// See LICENSE.txt file in the top level directory for more details. +// +//---------------------------------------------------------------------------- +// $Id$ + +#ifndef ossimSentinel1Model_HEADER +#define ossimSentinel1Model_HEADER + +#include <ossim/base/ossimCommon.h> +#include <ossim/base/ossimFilename.h> +#include <ossim/base/ossimDirectory.h> +#include <ossim/base/ossimKeywordNames.h> +#include <ossim/base/ossimNotify.h> +#include <ossim/base/ossimRefPtr.h> +#include <ossim/base/ossimString.h> +#include <ossim/base/ossimTrace.h> +#include <ossim/base/ossimXmlDocument.h> +#include <ossim/base/ossimXmlNode.h> + +//#include <ossim/projection/ossimSensorModel.h> +//#include <ossim/projection/ossimCoarseGridModel.h> +#include <ossim/projection/ossimSarModel.h> + +#include <ossim/support_data/ossimSupportFilesList.h> + +#include "ossimPluginConstants.h" +#include "ossimPluginCommon.h" +#include <iostream> +#include <cmath> +#include <cstdio> + +//#include "ossimGeometricSarSensorModel.h" + +#include "ossimSentinel1ProductDoc.h" + +//ossimGeometricSarSensorModel + +namespace ossimplugins +{ + + class OSSIM_PLUGINS_DLL ossimSentinel1Model : public ossimSarModel + { + public: + /*! + * CONSTRUCTORS: + */ + /** @brief default constructor */ + ossimSentinel1Model(); + + /** @brief copy constructor */ + ossimSentinel1Model(const ossimSentinel1Model& rhs); + + /** @brief Destructor */ + virtual ~ossimSentinel1Model(); + + + bool open(const ossimFilename& file); + + /*! + * Returns pointer to a new instance, copy of this. + * Not implemented yet! Returns NULL... + */ + virtual ossimObject* dup() const; + + /*! + * Extends base-class implementation. Dumps contents of object to ostream. + */ + virtual std::ostream& print(std::ostream& out) const; + + /*! + * Fulfills ossimObject base-class pure virtuals. Loads and saves geometry + * KWL files. Returns true if successful. + */ + virtual bool saveState(ossimKeywordlist& kwl, + const char* prefix=NULL) const; + + virtual bool loadState(const ossimKeywordlist& kwl, + const char* prefix=NULL); + + bool checkDirectory(const ossimFilename& file, const char* d, const char *ext); + + bool isLevel0(const ossimFilename& file); + + bool isLevel2(const ossimFilename& file); + + bool isLevel1(const ossimFilename& file); + + bool isSentinel1(const ossimFilename &manifestFile); + + bool readProduct(const ossimFilename &manifestFile); + + bool getImageId(ossimString& s) const; + + bool initSensorID(ossimString& s); + + bool standAloneProductInformation(); + + bool getAnnotationFileLocation(const ossimFilename &manifestFile, const char* pattern); + + + bool initImageSize(ossimIpt& imageSize) const + { + // theImageClipRect = ossimDrect(0, 0, theImageSize.x-1, theImageSize.y-1); + // theSubImageOffset.x = 0.0; + // theSubImageOffset.y = 0.0; + + return theProduct->initImageSize(imageSize ); + } + + bool initGsd(ossimDpt& gsd) const + { + return theProduct->initGsd( gsd ); + } + + const ossimKeywordlist getManifestKwl() const + { + return theManifestKwl; + } + + bool isSLC() { return theSLC; } + bool isOCN() { return theOCN; } + + bool initSRGR() + { + // theProduct->initSRGR( ); + return true; + } + + bool findSafeManifest(const ossimFilename& file, ossimFilename& safeFile); + + void clearFields(); + + + protected: + + TYPE_DATA + + private: + + ossimFilename theProductXmlFile; + ossimFilename theManifestFile; + ossimKeywordlist theManifestKwl; + ossimRefPtr<ossimXmlDocument> theManifestDoc; + ossimRefPtr<ossimSentinel1ProductDoc> theProduct; + bool theOCN; + bool theSLC; + + + }; //end class ossimSentinel1Model + +} //end namespace ossimplugins + + +#endif /* #ifndef ossimSentinel1Model_HEADER */ diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1ProductDoc.cpp b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1ProductDoc.cpp new file mode 100644 index 0000000000000000000000000000000000000000..64840e227889d5246096f139694086c94bfc5573 --- /dev/null +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1ProductDoc.cpp @@ -0,0 +1,722 @@ +#include "ossimSentinel1ProductDoc.h" +#include <ossim/base/ossimDirectory.h> +#include <ossim/base/ossimDate.h> + +// Define Trace flags for use within this file: +static ossimTrace traceExec ("ossimSentinel1SupportData:exec"); +static ossimTrace traceDebug ("ossimSentinel1SupportData:debug"); + +namespace ossimplugins +{ + + static const char LOAD_FROM_PRODUCT_FILE_KW[] = "load_from_product_file_flag"; + static const char PRODUCT_XML_FILE_KW[] = "product_xml_filename"; + static const char SUPPORT_DATA_PREFIX[] = "support_data."; + + ossimSentinel1ProductDoc::ossimSentinel1ProductDoc () + : ossimErrorStatusInterface () + , theRangeSpacingTotal (0.0) + , theAzimuthSpacingTotal (0.0) + , theSLC (false) + , theTOPSAR (false) + { + + } + + ossimSentinel1ProductDoc::~ossimSentinel1ProductDoc () + { + + } + + bool ossimSentinel1ProductDoc::openMetadataFile(ossimRefPtr<ossimXmlDocument>& doc, const ossimString file) const + { + if ( !doc->openFile( file ) ) + { + std::cerr << "ossimSentinel1ProductDoc::openMetadataFile() failed." << std::endl; + return false; + } + + return true; + } + + + double + ossimSentinel1ProductDoc + ::getModifiedJulianDate(const ossimString utcTimeString) + { + + std::vector<ossimString> date_time; + std::vector<ossimString> output; + + utcTimeString.split(date_time, "T"); + + date_time[0].split(output, "-"); + + if (output.size () != 3) + { + ossimNotify(ossimNotifyLevel_DEBUG) << "invalid date\n"; + } + + char* stop; + int year = std::strtol( output[0].c_str(), &stop, 10); + if ( *stop != 0 ) + { + ossimNotify(ossimNotifyLevel_DEBUG) << "invalid year\n"; + } + + stop = 0; + int month = std::strtol( output[1].c_str(), &stop, 10); + if ( *stop != 0 ) + { + ossimNotify(ossimNotifyLevel_DEBUG) << "invalid month\n"; + } + stop = 0; + int day = std::strtol( output[2].c_str(), &stop, 10); + if ( *stop != 0 ) + { + ossimNotify(ossimNotifyLevel_DEBUG) << "invalid day\n"; + } + /* Parse time */ + output.clear(); + date_time[1].split(output, ":"); + if (output.size () != 3) + { + ossimNotify(ossimNotifyLevel_DEBUG) << "invalid time\n"; + } + + stop = 0; + int hours = std::strtol( output[0].c_str(), &stop, 10); + if ( *stop != 0 ) + { + ossimNotify(ossimNotifyLevel_DEBUG) << "invalid hours\n"; + } + + stop = 0; + int minutes = std::strtol( output[1].c_str(), &stop, 10); + if ( *stop != 0 ) + { + ossimNotify(ossimNotifyLevel_DEBUG) << "invalid minutes\n"; + } + + stop = 0; + int seconds = std::strtod( output[2].c_str(), &stop); + if ( *stop != 0 ) + { + ossimNotify(ossimNotifyLevel_DEBUG) << "invalid seconds in float\n"; + } + +/* Below method could replace all above split and convert. But there is a lot of + checks done in ossimLocalTm::setIso8601( ) which slows us down. And I dont + want that. */ +/* + ossimLocalTm otm; + if ( !otm.setIso8601(utcString) ) + { + } + ossimDate ossimdate(otm); +*/ + + ossimDate ossimdate(month, day, year); + ossimdate.setHour(hours); + ossimdate.setMin(minutes); + ossimdate.setFloatSec(seconds); + return ossimdate.getModifiedJulian(); + + } + + bool ossimSentinel1ProductDoc::readProductMetadata() + { + bool commonMetadataRetrieved = false; + double heightSum = 0.0; + int numBands = 0; + + ossimDirectory annotationDir( theManifestDirectory.dirCat( "annotation") ); + std::vector<ossimFilename> files; + annotationDir.findAllFilesThatMatch(files, ".xml"); + std::vector<ossimFilename>::const_iterator it = files.begin(); + + /* avoid zero value for numBands. This will result in division by zero below */ + if( files.size() < 1 ) numBands = 1; + + for (int count=0; it != files.end(); ++it, ++count) + { + ossimRefPtr<ossimXmlDocument> theProductXmlDocument = new ossimXmlDocument(); + openMetadataFile(theProductXmlDocument, (*it) ); + + const ossimRefPtr<ossimXmlNode> adsHeader = theProductXmlDocument->getRoot()->findFirstNode("adsHeader"); + + const ossimString swath = adsHeader->getChildTextValue("swath"); + const ossimString polarisation = adsHeader->getChildTextValue("polarisation"); + + std::stringstream _tempstrm; + _tempstrm << "Band[" << count << "]."; + const ossimString bandPrefix = _tempstrm.str(); + + theProductKwl.add(bandPrefix, + "swath", + swath, + true); + + theProductKwl.add(bandPrefix, + "polarisation", + polarisation, + true); + + theProductKwl.add(bandPrefix, + "annotation", + (*it).file(), + true); + + theProductKwl.add(bandPrefix, + "first_line_time", + adsHeader->getChildTextValue("startTime"), + true); + + theProductKwl.add(bandPrefix, + "last_line_time", + adsHeader->getChildTextValue("stopTime"), + true); + //RK maybe use this->getManifestPrefix() + theProductKwl.add(SUPPORT_DATA_PREFIX, + "mds1_tx_rx_polar", + polarisation, + true); + + const ossimRefPtr<ossimXmlNode> imageInformation = theProductXmlDocument->getRoot()->findFirstNode("imageAnnotation/imageInformation"); + + const ossimRefPtr<ossimXmlNode> productInformation = theProductXmlDocument->getRoot()->findFirstNode("generalAnnotation/productInformation"); + + theProductKwl.add(SUPPORT_DATA_PREFIX, + "data_take_id", + adsHeader->getChildTextValue("missionDataTakeId"), + true); + + theProductKwl.add(SUPPORT_DATA_PREFIX, + "slice_num", + imageInformation->getChildTextValue("sliceNumber"), + true); + + theProductKwl.add(SUPPORT_DATA_PREFIX, + "line_time_interval", + imageInformation->getChildTextValue("azimuthTimeInterval"), + true); + + theRangeSpacingTotal += imageInformation->getChildTextValue("rangePixelSpacing").toFloat64(); + + theAzimuthSpacingTotal += imageInformation->getChildTextValue("azimuthPixelSpacing").toFloat64(); + + theProductKwl.add(bandPrefix, + ossimKeywordNames::NUMBER_SAMPLES_KW, + imageInformation->getChildTextValue("numberOfSamples"), + true); + + theProductKwl.add(bandPrefix, + ossimKeywordNames::NUMBER_LINES_KW, + imageInformation->getChildTextValue("numberOfLines"), + true); + + theProductKwl.add(bandPrefix, + "sample_type", //ossimKeywordNames::PIXEL_TYPE_KW, + imageInformation->getChildTextValue("pixelValue").upcase(), + true); + + heightSum += getBandTerrainHeight(theProductXmlDocument); + + + if (!commonMetadataRetrieved) + { + // these should be the same for all swaths + //RK div by oneMillion taken from S1tlbx + theProductKwl.add(SUPPORT_DATA_PREFIX, + "range_sampling_rate", + productInformation->getChildTextValue("rangeSamplingRate"), + true); + + theProductKwl.add(SUPPORT_DATA_PREFIX, + "radar_frequency", + productInformation->getChildTextValue("radarFrequency"), + true); + + theProductKwl.add(SUPPORT_DATA_PREFIX, + "line_time_interval", + imageInformation->getChildTextValue("azimuthTimeInterval"), + true); + + theProductKwl.add(SUPPORT_DATA_PREFIX, + "slant_range_to_first_pixel", + imageInformation->getChildTextValue("slantRangeTime"), + true); + + const ossimRefPtr<ossimXmlNode> downlinkInformation = + theProductXmlDocument->getRoot()->findFirstNode("generalAnnotation/downlinkInformationList/downlinkInformation"); + + theProductKwl.add(SUPPORT_DATA_PREFIX, + "pulse_repetition_frequency", + downlinkInformation->getChildTextValue("prf"), + true); + + const ossimRefPtr<ossimXmlNode> swathProcParams = + theProductXmlDocument->getRoot()->findFirstNode("imageAnnotation/processingInformation/swathProcParamsList/swathProcParams"); + const ossimRefPtr<ossimXmlNode> rangeProcessingNode = swathProcParams->findFirstNode("rangeProcessing"); + const ossimRefPtr<ossimXmlNode> azimuthProcessingNode = swathProcParams->findFirstNode("azimuthProcessing"); + + theProductKwl.add(SUPPORT_DATA_PREFIX, + "azimuth_bandwidth", + azimuthProcessingNode->getChildTextValue("processingBandwidth"), + true); + + theProductKwl.add(SUPPORT_DATA_PREFIX, + "range_bandwidth", + rangeProcessingNode->getChildTextValue("processingBandwidth"), + true); + + theProductKwl.add(SUPPORT_DATA_PREFIX, + "range_looks", + rangeProcessingNode->getChildTextValue("numberOfLooks"), + true); + + theProductKwl.add(SUPPORT_DATA_PREFIX, + "azimuth_looks", + azimuthProcessingNode->getChildTextValue("numberOfLooks"), + true); + + if(!theTOPSAR || !theSLC) + { + theProductKwl.add(SUPPORT_DATA_PREFIX, + ossimKeywordNames::NUMBER_SAMPLES_KW, + imageInformation->getChildTextValue("numberOfSamples"), + true); + + theProductKwl.add(SUPPORT_DATA_PREFIX, + ossimKeywordNames::NUMBER_LINES_KW, + imageInformation->getChildTextValue("numberOfLines"), + true); + } + + const ossimRefPtr<ossimXmlNode> orbitList = theProductXmlDocument->getRoot()->findFirstNode("generalAnnotation/orbitList"); + addOrbitStateVectors(orbitList); + + const ossimRefPtr<ossimXmlNode> coordinateConversionList = theProductXmlDocument->getRoot()->findFirstNode("coordinateConversion/coordinateConversionList"); + addSRGRCoefficients(SUPPORT_DATA_PREFIX, coordinateConversionList); + + const ossimRefPtr<ossimXmlNode> dcEstimateList = theProductXmlDocument->getRoot()->findFirstNode("dopplerCentroid/dcEstimateList"); + addDopplerCentroidCoefficients(dcEstimateList); + + commonMetadataRetrieved = true; + } + + ++numBands; + } + + if(theSLC) + { + numBands = numBands * 2; // real and imaginary + } + + + theProductKwl.add(SUPPORT_DATA_PREFIX, + "range_spacing", + theRangeSpacingTotal / (double)numBands, + true); + + theProductKwl.add(SUPPORT_DATA_PREFIX, + "azimuth_spacing", + theAzimuthSpacingTotal / (double)numBands, + true); + + theProductKwl.add(SUPPORT_DATA_PREFIX, + "avg_scene_height", + heightSum / (double)files.size(), + true); + + theProductKwl.add(SUPPORT_DATA_PREFIX, + ossimKeywordNames::NUMBER_BANDS_KW, + numBands, + true); + return true; + } + + void ossimSentinel1ProductDoc::addDopplerCentroidCoefficients(const ossimRefPtr<ossimXmlNode>& dcEstimateList) + { + if (!dcEstimateList.get()) + return; + + ossimString count_str; + dcEstimateList->getAttributeValue(count_str, "count"); + const int count = count_str.toInt(); + if( count < 1) + { + ossimNotify(ossimNotifyLevel_DEBUG) << "No doppler centroid coefficients available in metadata!!\n"; + return; + } + else + { + ossimXmlNode::ChildListType dcEstimates; + dcEstimateList->findChildNodes("dcEstimate", dcEstimates); + + ossimXmlNode::ChildListType::const_iterator it = dcEstimates.begin(); + + int index = 1; + + while( it != dcEstimates.end()) + { + //Doppler_Centroid_Coefficients.dop_coef_list; + const ossimString prefix = "dopplerCentroid.dop_coef_list" + ossimString::toString(index) + "."; + + ++index; + + const ossimRefPtr<ossimXmlNode> dcEstimate = (*it); + theProductKwl.add(prefix, + "dop_coef_time", + dcEstimate->getChildTextValue("azimuthTime"), + true); + //RK + const double ref_time = dcEstimate->getChildTextValue("t0").toFloat64() * 1e9; // s to ns + + theProductKwl.add(prefix, + "slant_range_time", + ref_time, + true); + + const ossimString ns = dcEstimate->getChildTextValue("ns"); + + if( !ns.empty() ) + theProductKwl.add(prefix, + "slant_range_time", + ns, + true); + + const ossimString coeffStr = dcEstimate->getChildTextValue("geometryDcPolynomial"); + + if (!coeffStr.empty()) + { + const ossimString separatorList = " "; + std::vector<ossimString> result; + + coeffStr.split(result, separatorList, true); + + std::vector<ossimString>::const_iterator coeff = result.begin(); + + int count = 1; + + while (coeff != result.end()) + { + const ossimString coeff_prefix = prefix + ossimString::toString(count) + "."; + + theProductKwl.add(coeff_prefix, + "dop_coef", + (*coeff), + true); + + ++coeff; + + ++count; + } + + } //if (!coeffStr.empty()) + + ++it; + + } // while( it != dcEstimates.end()) + + } // else count < 1 + } + + + double ossimSentinel1ProductDoc::getBandTerrainHeight( const ossimRefPtr<ossimXmlDocument>& theProductXmlDocument ) + { + double heightSum = 0.0; + vector< ossimRefPtr<ossimXmlNode> > heightList; + theProductXmlDocument->findNodes("/product/generalAnnotation/terrainHeightList/terrainHeight", heightList); + vector<ossimRefPtr<ossimXmlNode> >::const_iterator it = heightList.begin(); + while(it != heightList.end()) + { + heightSum += (*it)->getChildTextValue("value").toFloat64(); + ++it; + } + return heightSum / heightList.size(); + } + + bool ossimSentinel1ProductDoc::initImageSize(ossimIpt& imageSize) const + { + const ossimString samples_str = theProductKwl.find(SUPPORT_DATA_PREFIX, ossimKeywordNames::NUMBER_SAMPLES_KW); + const ossimString lines_str = theProductKwl.find(SUPPORT_DATA_PREFIX, ossimKeywordNames::NUMBER_LINES_KW); + + imageSize.samp = samples_str.toInt(); + imageSize.line = lines_str.toInt(); + + return true; + } + + bool ossimSentinel1ProductDoc::initGsd( ossimDpt& gsd) const + { + gsd.x = theRangeSpacingTotal; + gsd.y = theAzimuthSpacingTotal; + return true; + } + + void ossimSentinel1ProductDoc::addOrbitStateVectors(const ossimRefPtr<ossimXmlNode>& orbitList) + { + + if (!orbitList.get()) + { + ossimNotify(ossimNotifyLevel_DEBUG) << "No orbitVectorList info available in metadata!!\n"; + return; + } + + ossimXmlNode::ChildListType stateVectorList; + orbitList->findChildNodes("orbit", stateVectorList); + + if(stateVectorList.size() < 1) + { + ossimNotify(ossimNotifyLevel_DEBUG) << "No orbitVectorList info available in metadata!!\n"; + return; + } + + for (int i = 0; i < stateVectorList.size(); ++i) + { + //orbit_state_vectors + const ossimString orbit_prefix = "orbitList.orbit[" + ossimString::toString(i) + "]."; + + theProductKwl.add(orbit_prefix, + "time", + stateVectorList[i]->getChildTextValue("time"), + true); + + theProductKwl.add(orbit_prefix, + "x_pos", + stateVectorList[i]->getChildTextValue("position/x").toFloat64(), + true); + + theProductKwl.add(orbit_prefix, + "y_pos", + stateVectorList[i]->getChildTextValue("position/y").toFloat64(), + true); + + theProductKwl.add(orbit_prefix, + "z_pos", + stateVectorList[i]->getChildTextValue("position/z").toFloat64(), + true); + + theProductKwl.add(orbit_prefix, + "x_vel", + stateVectorList[i]->getChildTextValue("velocity/x").toFloat64(), + true); + + theProductKwl.add(orbit_prefix, + "y_vel", + stateVectorList[i]->getChildTextValue("velocity/y").toFloat64(), + true); + + theProductKwl.add(orbit_prefix, + "z_vel", + stateVectorList[i]->getChildTextValue("velocity/z").toFloat64(), + true); + } + } + + void ossimSentinel1ProductDoc::addSRGRCoefficients(const char* prefix, const ossimRefPtr<ossimXmlNode>& coordinateConversionList) + { + if (!coordinateConversionList.get()) + return; + + ossimString count_str; + coordinateConversionList->getAttributeValue(count_str, "count"); + const int count = count_str.toInt(); + if( count < 1) + { + if(traceDebug()) + ossimNotify(ossimNotifyLevel_DEBUG) << "No coordinate conversion info available in metadata!!\n"; + return; + } + else + { + ossimNotify(ossimNotifyLevel_FATAL) << "shouldn't reach here!!\n"; + return; + } + + } + + void ossimSentinel1ProductDoc::readCalibrationMetadata() + { + ossimDirectory calibrationDir( theManifestDirectory.dirCat( "annotation/calibration") ); + std::vector<ossimFilename> files; + calibrationDir.findAllFilesThatMatch(files, "calibration*"); + std::vector<ossimFilename>::const_iterator it = files.begin(); + + std::stringstream strm; + for (; it != files.end(); ++it) + { + ossimRefPtr<ossimXmlDocument> calibrationDoc = new ossimXmlDocument(); + openMetadataFile(calibrationDoc, (*it) ); + + ossimRefPtr<ossimXmlNode> adsHeader = calibrationDoc->getRoot()->findFirstNode("adsHeader"); + ossimRefPtr<ossimXmlNode> calibrationInformation = calibrationDoc->getRoot()->findFirstNode("calibrationInformation"); + ossimRefPtr<ossimXmlNode> calibrationVectorList = calibrationDoc->getRoot()->findFirstNode("calibrationVectorList"); + + const ossimString calibrationPrefix = "calibration."; + + theProductKwl.add(calibrationPrefix, + "swath", + adsHeader->getChildTextValue("swath"), + true); + + theProductKwl.add(calibrationPrefix, + "polarisation", + adsHeader->getChildTextValue("polarisation"), + true); + + theProductKwl.add(calibrationPrefix, + "startTime", + getModifiedJulianDate(adsHeader->getChildTextValue("startTime")), + true); + + theProductKwl.add(calibrationPrefix, + "stopTime", + getModifiedJulianDate(adsHeader->getChildTextValue("stopTime")), + true); + + theProductKwl.add(calibrationPrefix, + "absoluteCalibrationConstant", + calibrationInformation->getChildTextValue("absoluteCalibrationConstant"), + true); + + theProductKwl.add(calibrationPrefix, + "count", + calibrationVectorList->getAttributeValue("count"), + true); + + const ossimRefPtr<ossimXmlNode> calibrationRoot = calibrationDoc->getRoot(); + std::vector< ossimRefPtr<ossimXmlNode> > calibrationVectors; + calibrationRoot->findChildNodes("calibrationVectorList/calibrationVector", calibrationVectors); + for( unsigned int idx = 0; idx < calibrationVectors.size(); ++idx) + { + + const ossimString calibrationVectorPrefix = calibrationPrefix + "calibrationVector[" + ossimString::toString(idx) + "]."; + + const ossimRefPtr<ossimXmlNode> node = calibrationVectors[idx]->findFirstNode("pixel"); + + theProductKwl.add(calibrationVectorPrefix, + "pixel_count", + node->getAttributeValue("count"), + false); + + theProductKwl.add(calibrationVectorPrefix, + "azimuthTime", + getModifiedJulianDate(calibrationVectors[idx]->getChildTextValue("azimuthTime")), + true); + + theProductKwl.add(calibrationVectorPrefix, + "line", + calibrationVectors[idx]->getChildTextValue("line"), + true); + + theProductKwl.add(calibrationVectorPrefix, + "pixel", + calibrationVectors[idx]->getChildTextValue("pixel"), + true); + + theProductKwl.add(calibrationVectorPrefix, + "sigmaNought", + calibrationVectors[idx]->getChildTextValue("sigmaNought"), + true); + + theProductKwl.add(calibrationVectorPrefix, + "betaNought", + calibrationVectors[idx]->getChildTextValue("betaNought"), + true); + + theProductKwl.add(calibrationVectorPrefix, + "gamma", + calibrationVectors[idx]->getChildTextValue("gamma"), + true); + + theProductKwl.add(calibrationVectorPrefix, + "dn", + calibrationVectors[idx]->getChildTextValue("dn"), + true); + + // calibrationVectors[idx]->toKwl(theProductKwl, "calibrationVectorList_" + ossimString::toString(idx+1) + "."); + } + } + } + + void ossimSentinel1ProductDoc::readNoiseMetadata() + { + ossimDirectory calibrationDir( theManifestDirectory.dirCat( "annotation/calibration") ); + std::vector<ossimFilename> files; + calibrationDir.findAllFilesThatMatch(files, "noise*"); + std::vector<ossimFilename>::const_iterator it = files.begin(); + const ossimString noisePrefix = "noise."; + + for (; it != files.end(); ++it) + { + ossimRefPtr<ossimXmlDocument> noiseDoc = new ossimXmlDocument(); + openMetadataFile(noiseDoc, (*it) ); + + const ossimRefPtr<ossimXmlNode> noiseRoot = noiseDoc->getRoot(); + std::vector< ossimRefPtr<ossimXmlNode> > noiseVectors; + noiseRoot->findChildNodes("noiseVectorList/noiseVector", noiseVectors); + for( unsigned int idx = 0; idx < noiseVectors.size(); ++idx) + { + const ossimString noiseVectorPrefix = noisePrefix + "noiseVector[" + ossimString::toString(idx) + "]."; + + const ossimRefPtr<ossimXmlNode> node = noiseVectors[idx]->findFirstNode("pixel"); + + theProductKwl.add(noiseVectorPrefix, + "pixel_count", + node->getAttributeValue("count"), + false); + + theProductKwl.add(noiseVectorPrefix, + "azimuthTime", + getModifiedJulianDate(noiseVectors[idx]->getChildTextValue("azimuthTime")), + true); + + theProductKwl.add(noiseVectorPrefix, + "line", + noiseVectors[idx]->getChildTextValue("line"), + true); + + theProductKwl.add(noiseVectorPrefix, + "pixel", + noiseVectors[idx]->getChildTextValue("pixel"), + true); + + theProductKwl.add(noiseVectorPrefix, + "noiseLut", + noiseVectors[idx]->getChildTextValue("noiseLut"), + true); + + //noiseVectorList[idx]->toKwl(theProductKwl, "noiseVectorList_" + ossimString::toString(idx+1) + "."); + } + } + } + + + void ossimSentinel1ProductDoc::clearFields( ) + { + theProductKwl.clear(); + } + //RK + // bool ossimSentinel1ProductDoc::saveState(ossimKeywordlist& kwl, + // const char* prefix)const + // { + // kwl.addList(theProductKwl); + + // kwl.add(prefix, + // "sample_type", + // theSampleType, + // true); + + // return true; + // } + + // bool ossimSentinel1ProductDoc::loadState(const ossimKeywordlist& kwl, + // const char* prefix) + // { + + // return true; + + // } +} diff --git a/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1ProductDoc.h b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1ProductDoc.h new file mode 100644 index 0000000000000000000000000000000000000000..50b0f5107b7141c6a9cde719ffab4551d8d0b524 --- /dev/null +++ b/Modules/ThirdParty/OssimPlugins/src/ossim/ossimSentinel1ProductDoc.h @@ -0,0 +1,112 @@ +//---------------------------------------------------------------------------- +// +// "Copyright Centre National d'Etudes Spatiales" +// +// License: LGPL-2 +// +// See LICENSE.txt file in the top level directory for more details. +// +//---------------------------------------------------------------------------- +// $Id$ + +#ifndef ossimSentinel1ProductDoc_HEADER +#define ossimSentinel1ProductDoc_HEADER + +#include <ossim/base/ossimConstants.h> +#include <ossim/base/ossimIpt.h> +#include <ossim/base/ossimObject.h> +#include <ossim/base/ossimString.h> +#include <ossim/base/ossimErrorStatusInterface.h> +#include <ossim/base/ossimFilename.h> +#include <ossim/base/ossimDpt.h> +#include <ossim/base/ossimDrect.h> +#include <ossim/base/ossimGpt.h> +#include <ossim/base/ossimXmlDocument.h> +#include <ossim/base/ossimXmlNode.h> +#include <ossim/base/ossimKeywordlist.h> +#include <ossim/base/ossimNotify.h> +#include <ossim/base/ossimNotifyContext.h> +#include <ossim/base/ossimKeywordNames.h> +#include <ossim/base/ossimTrace.h> +#include <ossim/base/ossimCommon.h> +#include "ossimPluginCommon.h" +#include "ossimPluginConstants.h" + +#include <cstdio> +#include <vector> +#include <sstream> +#include <iostream> +#include <iterator> + +namespace ossimplugins +{ + + class OSSIM_PLUGINS_DLL ossimSentinel1ProductDoc : public ossimObject, + public ossimErrorStatusInterface + { + public: + + ossimSentinel1ProductDoc(); + + virtual ~ossimSentinel1ProductDoc(); + + void clearFields(); + + bool openMetadataFile(ossimRefPtr<ossimXmlDocument>& doc, const ossimString file) const; + + bool initImageSize(ossimIpt& imageSize) const; + + bool initGsd( ossimDpt& gsd) const; + + void addSRGRCoefficients(const char* prefix, const ossimRefPtr<ossimXmlNode>& coordinateConversion); + + void addDopplerCentroidCoefficients(const ossimRefPtr<ossimXmlNode>& dcEstimateList); + + void addOrbitStateVectors(const ossimRefPtr<ossimXmlNode>& dcEstimateList); + + void readCalibrationMetadata(); + + void readNoiseMetadata(); + + double getModifiedJulianDate(const ossimString utc_time); + + bool readProductMetadata( ); + + double getBandTerrainHeight( const ossimRefPtr<ossimXmlDocument>& theProductXmlDocument ); + + inline const ossimKeywordlist getProductKwl() const + { + return theProductKwl; + } + + inline void setMetadataDirectory(const ossimFilename d) + { + theManifestDirectory = d; + } + + + inline void setSLC(bool b) + { + theSLC = true; + } + + inline void setTOPSAR(bool b) + { + theTOPSAR = true; + } + + private: + ossimFilename theManifestDirectory; + double theRangeSpacingTotal; + double theAzimuthSpacingTotal; + bool theTOPSAR; + bool theSLC; + ossimFilename theProductXmlFile; + ossimString theSampleType; + ossimKeywordlist theProductKwl; + + }; + +} + +#endif /* #ifndef ossimSentinel1ProductDoc_HEADER */ diff --git a/SuperBuild/CMake/External_ossim.cmake b/SuperBuild/CMake/External_ossim.cmake index 20948d3bf68e676ee3fbad5728bb38b6355f116e..7303c9f9c0659c00f784c05526cb4530d180fd99 100644 --- a/SuperBuild/CMake/External_ossim.cmake +++ b/SuperBuild/CMake/External_ossim.cmake @@ -17,14 +17,14 @@ if(USE_SYSTEM_OSSIM) else() SETUP_SUPERBUILD(PROJECT ${proj}) message(STATUS " Using OSSIM SuperBuild version") - + # declare dependencies ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(${proj} TIFF GEOTIFF GEOS JPEG OPENTHREADS FREETYPE) INCLUDE_SUPERBUILD_DEPENDENCIES(${${proj}_DEPENDENCIES}) # set proj back to its original value set(proj OSSIM) - + ADD_SUPERBUILD_CMAKE_VAR(TIFF_INCLUDE_DIR) ADD_SUPERBUILD_CMAKE_VAR(TIFF_LIBRARY) ADD_SUPERBUILD_CMAKE_VAR(GEOTIFF_INCLUDE_DIR) @@ -39,93 +39,45 @@ else() ADD_SUPERBUILD_CMAKE_VAR(FREETYPE_LIBRARY) set(OSSIM_CXX_FLAGS -D__STDC_CONSTANT_MACROS) - + if(MSVC) set(OSSIM_CXX_FLAGS /EHsc) endif() - - if(0) - # SVN version - ExternalProject_Add(ossim_cmakemodules - PREFIX ${proj}/_cmakemodules - SVN_REPOSITORY "http://svn.osgeo.org/ossim/trunk/ossim_package_support/cmake/CMakeModules" - SVN_REVISION -r 23087 - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - PATCH_COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_SOURCE_DIR}/patches/${proj}/OssimUtilities.cmake - ${CMAKE_BINARY_DIR}/${proj}/_cmakemodules/src/ossim_cmakemodules) - - list(APPEND ${proj}_DEPENDENCIES ossim_cmakemodules) - - ExternalProject_Add(${proj} - PREFIX ${proj} - SVN_REPOSITORY "http://svn.osgeo.org/ossim/trunk/ossim/" - SVN_REVISION -r 23092 - BINARY_DIR ${OSSIM_SB_BUILD_DIR} - INSTALL_DIR ${SB_INSTALL_PREFIX} - DOWNLOAD_DIR ${DOWNLOAD_LOCATION} - CMAKE_CACHE_ARGS - -DOSSIM_VERSION:STRING=1.8.18-1 - -DCMAKE_INSTALL_PREFIX:STRING=${SB_INSTALL_PREFIX} - -DCMAKE_BUILD_TYPE:STRING=Release - -DCMAKE_CXX_FLAGS:STRING=${OSSIM_CXX_FLAGS} - -DBUILD_OSSIM_MPI_SUPPORT:BOOL=OFF - -DBUILD_OSSIM_APPS:BOOL=OFF - -DBUILD_OSSIM_FRAMEWORKS:BOOL=OFF - -DINSTALL_ARCHIVE_DIR:STRING=lib - -DINSTALL_LIBRARY_DIR:STRING=lib - -DCMAKE_PREFIX_PATH:STRING=${SB_INSTALL_PREFIX};${CMAKE_PREFIX_PATH} - ${OSSIM_SB_CONFIG} - DEPENDS ${${proj}_DEPENDENCIES} - CMAKE_COMMAND ${SB_CMAKE_COMMAND} - ) - - ExternalProject_Add_Step(${proj} copy_CMakeModules - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${CMAKE_BINARY_DIR}/${proj}/_cmakemodules/src/ossim_cmakemodules ${OSSIM_SB_SRC}/CMakeModules - DEPENDEES patch update - DEPENDERS configure - ) - else() - # archive version - ExternalProject_Add(${proj} - PREFIX ${proj} - URL "https://www.orfeo-toolbox.org/packages/ossim-minimal-r23092.tar.gz" - URL_MD5 1bb7247fa490eb4a6e57b3c2e129d587 - BINARY_DIR ${OSSIM_SB_BUILD_DIR} - INSTALL_DIR ${SB_INSTALL_PREFIX} - DOWNLOAD_DIR ${DOWNLOAD_LOCATION} - CMAKE_CACHE_ARGS - -DOSSIM_VERSION:STRING=1.8.18-1 - -DProject_WC_REVISION:STRING=23092 - -DCMAKE_INSTALL_PREFIX:STRING=${SB_INSTALL_PREFIX} - -DCMAKE_BUILD_TYPE:STRING=Release - -DCMAKE_CXX_FLAGS:STRING=${OSSIM_CXX_FLAGS} - -DBUILD_OSSIM_MPI_SUPPORT:BOOL=OFF - -DBUILD_OSSIM_FREETYPE_SUPPORT:BOOL=ON - -DBUILD_OSSIM_APPS:BOOL=OFF - -DBUILD_OSSIM_FRAMEWORKS:BOOL=OFF - -DINSTALL_ARCHIVE_DIR:STRING=lib - -DINSTALL_LIBRARY_DIR:STRING=lib - -DCMAKE_PREFIX_PATH:STRING=${SB_INSTALL_PREFIX};${CMAKE_PREFIX_PATH} - ${OSSIM_SB_CONFIG} - PATCH_COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_SOURCE_DIR}/patches/${proj}/OssimUtilities.cmake - ${OSSIM_SB_SRC}/CMakeModules - DEPENDS ${${proj}_DEPENDENCIES} - CMAKE_COMMAND ${SB_CMAKE_COMMAND} - ) - endif() - + + # archive version + ExternalProject_Add(${proj} + PREFIX ${proj} + URL "https://www.orfeo-toolbox.org/packages/ossim-minimal-r23537.tar.gz" + URL_MD5 f77d574ab2817bcc36633f77824facb5 + BINARY_DIR ${OSSIM_SB_BUILD_DIR} + INSTALL_DIR ${SB_INSTALL_PREFIX} + DOWNLOAD_DIR ${DOWNLOAD_LOCATION} + CMAKE_CACHE_ARGS + -DProject_WC_REVISION:STRING=23537 + -DCMAKE_INSTALL_PREFIX:STRING=${SB_INSTALL_PREFIX} + -DCMAKE_BUILD_TYPE:STRING=Release + -DCMAKE_CXX_FLAGS:STRING=${OSSIM_CXX_FLAGS} + -DBUILD_OSSIM_MPI_SUPPORT:BOOL=OFF + -DBUILD_OSSIM_FREETYPE_SUPPORT:BOOL=ON + -DBUILD_OSSIM_APPS:BOOL=OFF + -DBUILD_OSSIM_TEST_APPS:BOOL=OFF + -DBUILD_OSSIM_FRAMEWORKS:BOOL=OFF + -DBUILD_WMS:BOOL=OFF + -DINSTALL_ARCHIVE_DIR:STRING=lib + -DINSTALL_LIBRARY_DIR:STRING=lib + -DCMAKE_PREFIX_PATH:STRING=${SB_INSTALL_PREFIX};${CMAKE_PREFIX_PATH} + ${OSSIM_SB_CONFIG} + DEPENDS ${${proj}_DEPENDENCIES} + CMAKE_COMMAND ${SB_CMAKE_COMMAND} + ) + set(_SB_${proj}_INCLUDE_DIR ${SB_INSTALL_PREFIX}/include) if(WIN32) set(_SB_${proj}_LIBRARY ${SB_INSTALL_PREFIX}/lib/ossim.lib) elseif(UNIX) set(_SB_${proj}_LIBRARY ${SB_INSTALL_PREFIX}/lib/libossim${CMAKE_SHARED_LIBRARY_SUFFIX}) endif() - + endif() endif()