From 2e8b8130576206cab565d25acd39a357ed50f970 Mon Sep 17 00:00:00 2001 From: Cyrille Valladeau <cyrille.valladeau@c-s.fr> Date: Mon, 7 Sep 2009 18:27:25 +0200 Subject: [PATCH] ENH : missing OTBCommonTest11 init --- .../otbAtmosphericCorrectionParameters.cxx | 26 ++++--- ...ectanceToSurfaceReflectanceImageFilter.txx | 21 +++-- Code/Radiometry/otbSIXSTraits.cxx | 1 - Testing/Code/Common/CMakeLists.txt | 1 + .../support_data/ossimSpotDimapSupportData.h | 8 +- .../ossimSpotDimapSupportData.cpp | 78 ++++++++++++++++++- 6 files changed, 113 insertions(+), 22 deletions(-) diff --git a/Code/Radiometry/otbAtmosphericCorrectionParameters.cxx b/Code/Radiometry/otbAtmosphericCorrectionParameters.cxx index a0ae8fe144..bbab60783d 100644 --- a/Code/Radiometry/otbAtmosphericCorrectionParameters.cxx +++ b/Code/Radiometry/otbAtmosphericCorrectionParameters.cxx @@ -33,6 +33,8 @@ FilterFunctionValues { m_MinSpectralValue = 0; m_MaxSpectralValue = 1; + // Fill with 1. Size 3 for 6S interpolation + m_FilterFunctionValues = ValuesVectorType(3,1.); m_UserStep = 0.0025; } @@ -138,21 +140,21 @@ AtmosphericCorrectionParameters { if(bandId != 0) { - function->SetFilterFunctionValues(vect); - m_WavelenghtSpectralBand.push_back(function); - function = FilterFunctionValues::New(); - vect.clear(); - } - bandId++; - function->SetMinSpectralValue(keywordStrings[0].toDouble()); - function->SetMaxSpectralValue(keywordStrings[1].toDouble()); - if(keywordStrings.size() == 3) - function->SetUserStep(keywordStrings[2].toDouble()); - } + function->SetFilterFunctionValues(vect); + m_WavelenghtSpectralBand.push_back(function); + function = FilterFunctionValues::New(); + vect.clear(); + } + bandId++; + function->SetMinSpectralValue(keywordStrings[0].toDouble()); + function->SetMaxSpectralValue(keywordStrings[1].toDouble()); + if(keywordStrings.size() == 3) + function->SetUserStep(keywordStrings[2].toDouble()); + } else if(keywordStrings.size()==1) vect.push_back(keywordStrings[0].toDouble()); else if(keywordStrings.size()!=0) - itkExceptionMacro("File "<<filename<<" not valid."); + itkExceptionMacro("File "<<filename<<" not valid."); } function->SetFilterFunctionValues(vect); m_WavelenghtSpectralBand.push_back(function); diff --git a/Code/Radiometry/otbReflectanceToSurfaceReflectanceImageFilter.txx b/Code/Radiometry/otbReflectanceToSurfaceReflectanceImageFilter.txx index 8f739008e9..e18c48ff7b 100644 --- a/Code/Radiometry/otbReflectanceToSurfaceReflectanceImageFilter.txx +++ b/Code/Radiometry/otbReflectanceToSurfaceReflectanceImageFilter.txx @@ -96,17 +96,26 @@ ReflectanceToSurfaceReflectanceImageFilter<TInputImage,TOutputImage> // the user has set the filter function values else { - if( m_FilterFunctionCoef.size() != this->GetInput()->GetNumberOfComponentsPerPixel() ) - { - itkExceptionMacro(<<"Filter Function and image channels mismatch."); - } + bool ffvfOK = true; + if( m_FilterFunctionCoef.size() == 0 ) + ffvfOK = false; + else if( m_FilterFunctionCoef.size() != this->GetInput()->GetNumberOfComponentsPerPixel() ) + itkExceptionMacro(<<"Function Values and Input image size dismatch"); + for(unsigned int i=0; i<this->GetInput()->GetNumberOfComponentsPerPixel(); i++) { FilterFunctionValuesType::Pointer functionValues = FilterFunctionValuesType::New(); - functionValues->SetFilterFunctionValues(m_FilterFunctionCoef[i]); + // if no ffvf set, set 1 as coef + if(ffvfOK) + functionValues->SetFilterFunctionValues(m_FilterFunctionCoef[i]); + functionValues->SetMinSpectralValue(imageMetadataInterface->GetFirstWavelengths(dict)[i]); functionValues->SetMaxSpectralValue(imageMetadataInterface->GetLastWavelengths(dict)[i]); - + + // if no ffvf set, compute the step to be sure that the valueswavelength are between min and max + if(!ffvfOK) + functionValues->SetUserStep( functionValues->GetMaxSpectralValue()-functionValues->GetMinSpectralValue()/2. ); + m_CorrectionParameters->SetWavelenghtSpectralBandWithIndex(i, functionValues); } } diff --git a/Code/Radiometry/otbSIXSTraits.cxx b/Code/Radiometry/otbSIXSTraits.cxx index d707abd3b7..3e137bbc9e 100644 --- a/Code/Radiometry/otbSIXSTraits.cxx +++ b/Code/Radiometry/otbSIXSTraits.cxx @@ -174,7 +174,6 @@ SIXSTraits::ComputeWavelenghtSpectralBandValuesFor6S( { itkGenericExceptionMacro(<<"The FilterFunctionValues vector must have more than 1 values !"); } - //if( vcl_abs((static_cast<double>(FilterFunctionValues.size()-1)*L_userStep)-(L_max-L_min) ) > .000001 ) if( L_min+static_cast<double>(FilterFunctionValues.size()-1)*L_userStep < (L_max - epsilon )) { itkGenericExceptionMacro(<<"The following condition: "<<L_min<<"+("<<FilterFunctionValues.size()<<"-1)*"<<L_userStep<<" < ("<< L_max <<"-"<<epsilon<<") is not respected !"); diff --git a/Testing/Code/Common/CMakeLists.txt b/Testing/Code/Common/CMakeLists.txt index aa64f28418..a8c0a03453 100755 --- a/Testing/Code/Common/CMakeLists.txt +++ b/Testing/Code/Common/CMakeLists.txt @@ -31,6 +31,7 @@ ENDIF(OTB_USE_MAPNIK) IF(OTB_USE_PQXX) SET(COMMON_TESTS10 ${CXX_TEST_PATH}/otbCommonTests10) ENDIF(OTB_USE_PQXX) +SET(COMMON_TESTS11 ${CXX_TEST_PATH}/otbCommonTests11) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ otbCommonTests1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/Utilities/otbossim/include/ossim/support_data/ossimSpotDimapSupportData.h b/Utilities/otbossim/include/ossim/support_data/ossimSpotDimapSupportData.h index d4e35e7c6c..39775b7518 100644 --- a/Utilities/otbossim/include/ossim/support_data/ossimSpotDimapSupportData.h +++ b/Utilities/otbossim/include/ossim/support_data/ossimSpotDimapSupportData.h @@ -65,6 +65,8 @@ public: ossimString getAcquisitionDate() const; ossimString getProductionDate() const; ossimString getImageID() const; + ossimString getInstrument() const; + ossim_uint32 getInstrumentIndex() const; ossimFilename getMetadataFile() const; void getSunAzimuth(ossim_float64& az) const; void getSunElevation(ossim_float64& el) const; @@ -74,7 +76,7 @@ public: void getViewingAngle(ossim_float64& va) const; void getSceneOrientation(ossim_float64& so) const; ossim_uint32 getNumberOfBands() const; - ossim_uint16 getStepCount() const; + ossim_uint32 getStepCount() const; bool isStarTrackerUsed() const; bool isSwirDataUsed() const; @@ -222,6 +224,8 @@ private: ossimString theImageID; ossimFilename theMetadataFile; ossimString theProductionDate; + ossimString theInstrument; + ossim_uint32 theInstrumentIndex; /* * From xml section: @@ -265,7 +269,7 @@ private: bool theSwirDataFlag; ossim_uint32 theNumBands; ossimString theAcquisitionDate; - ossim_uint16 theStepCount; + ossim_uint32 theStepCount; //--- diff --git a/Utilities/otbossim/src/ossim/support_data/ossimSpotDimapSupportData.cpp b/Utilities/otbossim/src/ossim/support_data/ossimSpotDimapSupportData.cpp index cfbe251269..92e674d356 100644 --- a/Utilities/otbossim/src/ossim/support_data/ossimSpotDimapSupportData.cpp +++ b/Utilities/otbossim/src/ossim/support_data/ossimSpotDimapSupportData.cpp @@ -38,6 +38,9 @@ ossimSpotDimapSupportData::ossimSpotDimapSupportData () theMetadataVersion(OSSIM_SPOT_METADATA_VERSION_UNKNOWN), theImageID(), theMetadataFile(), + theProductionDate(), + theInstrument(), + theInstrumentIndex(0), theSunAzimuth(0.0), theSunElevation(0.0), theIncidenceAngle(0.0), @@ -74,7 +77,10 @@ ossimSpotDimapSupportData::ossimSpotDimapSupportData () ossimSpotDimapSupportData::ossimSpotDimapSupportData(const ossimSpotDimapSupportData& rhs) :ossimErrorStatusInterface(rhs), theMetadataVersion(rhs.theMetadataVersion), + theProductionDate(rhs.theProductionDate), theImageID(rhs.theImageID), + theInstrument(rhs.theInstrument), + theInstrumentIndex(rhs.theInstrumentIndex), theMetadataFile (rhs.theMetadataFile), theSunAzimuth(rhs.theSunAzimuth), theSunElevation(rhs.theSunElevation), @@ -116,6 +122,9 @@ ossimSpotDimapSupportData::ossimSpotDimapSupportData (const ossimFilename& dimap theMetadataVersion(OSSIM_SPOT_METADATA_VERSION_UNKNOWN), theImageID(), theMetadataFile (dimapFile), + theInstrument(), + theInstrumentIndex(0), + theProductionDate(), theSunAzimuth(0.0), theSunElevation(0.0), theIncidenceAngle(0.0), @@ -180,6 +189,8 @@ void ossimSpotDimapSupportData::clearFields() clearErrorStatus(); theSensorID="Spot 5"; theMetadataVersion = OSSIM_SPOT_METADATA_VERSION_UNKNOWN; + theInstrument = ""; + theInstrumentIndex = 0; theImageID = ""; theMetadataFile = ""; theProductionDate = ""; @@ -852,6 +863,8 @@ void ossimSpotDimapSupportData::printInfo(ostream& os) const << "\n " << "\n Job Number (ID): " << theImageID << "\n Acquisition Date: " << theAcquisitionDate + << "\n Instrument: " << theInstrument + << "\n Instrument Index: " << theInstrumentIndex << "\n Production Date: " << theProductionDate << "\n Number of Bands: " << theNumBands << "\n Geo Center Point: " << theRefGroundPoint @@ -915,6 +928,16 @@ ossimFilename ossimSpotDimapSupportData::getMetadataFile() const return theMetadataFile; } +ossimString ossimSpotDimapSupportData::getInstrument() const +{ + return theInstrument; +} + +ossim_uint32 ossimSpotDimapSupportData::getInstrumentIndex() const +{ + return theInstrumentIndex; +} + void ossimSpotDimapSupportData::getSunAzimuth(ossim_float64& az) const { az = theSunAzimuth; @@ -950,7 +973,7 @@ ossim_uint32 ossimSpotDimapSupportData::getNumberOfBands() const return theNumBands; } -ossim_uint16 ossimSpotDimapSupportData::getStepCount() const +ossim_uint32 ossimSpotDimapSupportData::getStepCount() const { return theStepCount; } @@ -1234,6 +1257,16 @@ bool ossimSpotDimapSupportData::saveState(ossimKeywordlist& kwl, theNumBands, true); + kwl.add(prefix, + "instrument", + theInstrument, + true); + + kwl.add(prefix, + "instrument_index", + theInstrumentIndex, + true); + kwl.add(prefix, ossimKeywordNames::IMAGE_DATE_KW, theAcquisitionDate, @@ -1321,6 +1354,7 @@ bool ossimSpotDimapSupportData::saveState(ossimKeywordlist& kwl, { tempString += (ossimString::toString(theSolarIrradiance[idx]) + " "); } + kwl.add(prefix, "solar_irradiance", tempString, @@ -1480,6 +1514,8 @@ bool ossimSpotDimapSupportData::loadState(const ossimKeywordlist& kwl, theNumBands = ossimString(kwl.find(prefix, ossimKeywordNames::NUMBER_BANDS_KW)).toUInt32(); theAcquisitionDate = kwl.find(prefix, ossimKeywordNames::IMAGE_DATE_KW); theProductionDate = kwl.find(prefix, "production_date"); + theInstrument = kwl.find(prefix, "instrument"); + theInstrumentIndex = ossimString(kwl.find(prefix, "instrument_index")).toUInt32(); theStepCount = ossimString(kwl.find(prefix, "step_count")).toInt32(); theIncidenceAngle = ossimString(kwl.find(prefix, "incident_angle")).toDouble(); @@ -1714,6 +1750,46 @@ bool ossimSpotDimapSupportData::parsePart1( } theProductionDate = xml_nodes[0]->getText(); + //--- + // Fetch the Instrument: + //--- + xml_nodes.clear(); + xpath = "/Dimap_Document/Dataset_Sources/INSTRUMENT"; + xmlDocument->findNodes(xpath, xml_nodes); + if (xml_nodes.size() == 0) + { + setErrorStatus(); + if(traceDebug()) + { + ossimNotify(ossimNotifyLevel_DEBUG) + << MODULE << " DEBUG:" + << "\nCould not find: " << xpath + << std::endl; + } + return false; + } + theInstrument = xml_nodes[0]->getText(); + + //--- + // Fetch the Instrument Index: + //--- + xml_nodes.clear(); + xpath = "/Dimap_Document/Dataset_Sources/INSTRUMENT"; + xmlDocument->findNodes(xpath, xml_nodes); + if (xml_nodes.size() == 0) + { + setErrorStatus(); + if(traceDebug()) + { + ossimNotify(ossimNotifyLevel_DEBUG) + << MODULE << " DEBUG:" + << "\nCould not find: " << xpath + << std::endl; + } + return false; + } + theInstrumentIndex = xml_nodes[0]->getText().toUInt32(); + return true; } -- GitLab