diff --git a/Modules/Core/Metadata/include/otbMetadataSupplierInterface.h b/Modules/Core/Metadata/include/otbMetadataSupplierInterface.h index edc5b2aa1d15c61da590fc67cfb25458073cba37..b78599207c2daad1dcb35584cf44d0d5f06e9564 100644 --- a/Modules/Core/Metadata/include/otbMetadataSupplierInterface.h +++ b/Modules/Core/Metadata/include/otbMetadataSupplierInterface.h @@ -70,8 +70,6 @@ public: { bool hasValue; std::string ret = GetMetadataValue(path, hasValue, band); - std::cout << "hasValue : " << hasValue << std::endl ; - std::cout << "ret : " << ret << std::endl ; if (!hasValue) { otbGenericExceptionMacro(MissingMetadataException,<<"Missing metadata '"<<path<<"'") diff --git a/Modules/Core/Metadata/src/otbImageMetadataInterfaceBase.cxx b/Modules/Core/Metadata/src/otbImageMetadataInterfaceBase.cxx index afd58a4f6eadc54b88f8da071f2a17bd032deaf3..c13bfbfd68b85d37a1606fc076b2a4911faa0844 100644 --- a/Modules/Core/Metadata/src/otbImageMetadataInterfaceBase.cxx +++ b/Modules/Core/Metadata/src/otbImageMetadataInterfaceBase.cxx @@ -661,14 +661,12 @@ ImageMetadataInterfaceBase::Fetch( const char *path, int band) { - std::cout << "Fetching..." << std::endl ; if (band >= 0) { assert( (size_t)(band) < m_Imd.Bands.size()); m_Imd.Bands[band].Add(key, mds.GetAs<MetaData::Time>(path, band)); return m_Imd.Bands[band][key]; } - std::cout << "path : " << path << std::endl ; m_Imd.Add(key, mds.GetAs<MetaData::Time>(path)); return m_Imd[key]; diff --git a/Modules/Core/Metadata/src/otbMetaDataKey.cxx b/Modules/Core/Metadata/src/otbMetaDataKey.cxx index db6ec2ac9111cf24fd9783d42e1a445862c8d590..0a21706a52ffcbec153b4c12589c1dc7803c5b70 100644 --- a/Modules/Core/Metadata/src/otbMetaDataKey.cxx +++ b/Modules/Core/Metadata/src/otbMetaDataKey.cxx @@ -182,6 +182,11 @@ std::istream& operator>>(std::istream& is, Time& val) _OTB_ISTREAM_FAIL_IF( val.tm_sec < 0 || val.tm_sec > 60 ) _OTB_ISTREAM_FAIL_IF( val.frac_sec < 0.0 || val.frac_sec >= 1.0) //_OTB_ISTREAM_FAIL_IF( is.get() != 'Z' ) + if (!is.eof()) + { + _OTB_ISTREAM_FAIL_IF( is.get() != 'Z' ) + } + return is; } diff --git a/Modules/Core/Metadata/src/otbRadarsat2ImageMetadataInterface.cxx b/Modules/Core/Metadata/src/otbRadarsat2ImageMetadataInterface.cxx index 19b2bc66219ff4a0929727f14946657fad68d7be..184a0de53c817da7aa5b875f72ffaa2962d3b194 100644 --- a/Modules/Core/Metadata/src/otbRadarsat2ImageMetadataInterface.cxx +++ b/Modules/Core/Metadata/src/otbRadarsat2ImageMetadataInterface.cxx @@ -28,6 +28,7 @@ // useful constants #include <otbMath.h> +#include "otbXMLMetadataSupplier.h" namespace otb { @@ -239,6 +240,8 @@ Radarsat2ImageMetadataInterface::UIntVectorType Radarsat2ImageMetadataInterface: return rgb; } +//" + void Radarsat2ImageMetadataInterface::Parse(const MetadataSupplierInterface *mds) { @@ -247,12 +250,12 @@ void Radarsat2ImageMetadataInterface::Parse(const MetadataSupplierInterface *mds // Metadata read by GDAL Fetch(MDTime::AcquisitionStartTime, *mds, "ACQUISITION_START_TIME"); - // Fetch(MDTime::AcquisitionStopTime, *mds, "ACQUISITION_STOP_TIME"); + // Fetch(MDTime::AcquisitionStopTime, *mds, "PROCESSING_TIME"); Fetch(MDStr::BeamMode, *mds, "BEAM_MODE"); - // Fetch(MDStr::BeamSwath, *mds, "BEAM_SWATH"); Fetch("FACILITY_IDENTIFIER", *mds, "FACILITY_IDENTIFIER"); Fetch(MDNum::LineSpacing, *mds, "LINE_SPACING"); - // Fetch(MDStr::Mission, *mds, "MISSION_ID"); + Fetch(MDNum::PixelSpacing, *mds, "PIXEL_SPACING"); + // Fetch(MDStr::Mission, *mds, "MISSION_ID"); // TODO : product.sourceAttributes.satellite ? // Fetch(MDStr::Mode, *mds, "MODE"); Fetch(MDStr::OrbitDirection, *mds, "ORBIT_DIRECTION"); // Fetch(MDNum::OrbitNumber, *mds, "ORBIT_NUMBER"); @@ -260,9 +263,30 @@ void Radarsat2ImageMetadataInterface::Parse(const MetadataSupplierInterface *mds Fetch(MDStr::ProductType, *mds, "PRODUCT_TYPE"); Fetch(MDStr::Instrument, *mds, "SATELLITE_IDENTIFIER"); Fetch(MDStr::SensorID, *mds, "SENSOR_IDENTIFIER"); - // Fetch(MDStr::Swath, *mds, "SWATH"); + - } + // Product file + std::string ProductFilePath = mds->GetResourceFile("product.xml"); + if (!ProductFilePath.empty()) + { + // std::cout<< ProductFilePath << std::endl; + XMLMetadataSupplier ProductMS(ProductFilePath); + + // m_Imd.Add(MDNum::NumberOfLines, ProductMS.GetAs<int>("product.imageAttributes.rasterAttributes.numberOfLines")); + // m_Imd.Add(MDNum::NumberOfColumns, ProductMS.GetAs<int>("product.imageAttributes.rasterAttributes.numberOfSamplesPerLine")); + m_Imd.Add(MDTime::ProductionDate, + ProductMS.GetFirstAs<MetaData::Time>("product.imageGenerationParameters.generalProcessingInformation.processingTime")); + // m_Imd.Add(MDNum::RadarFrequency, ProductMS.GetAs<double>("product.sourceAttributes.radarParameters.radarCenterFrequency")); + // m_Imd.Add(MDNum::AverageSceneHeight, ProductMS.GetAs<double>("product.imageAttributes.geographicInformation.referenceEllipsoidParameters.geodeticTerrainHeight")); + + SARParam sarParam; + for (int bandId = 0 ; bandId < mds->GetNbBands() ; ++bandId) + { + Fetch(MDStr::Polarization, *mds, "POLARIMETRIC_INTERP", bandId); + m_Imd.Bands[bandId].Add(MDGeom::SAR, sarParam); + } + } +} -} // end namespace otb +} // end namespace otb \ No newline at end of file diff --git a/Modules/Core/Metadata/test/CMakeLists.txt b/Modules/Core/Metadata/test/CMakeLists.txt index b20374f6cb6f07306decc9a23e0266553790531f..946fb0dbf5a1a3c15de771d951a8cb88baeec4ce 100644 --- a/Modules/Core/Metadata/test/CMakeLists.txt +++ b/Modules/Core/Metadata/test/CMakeLists.txt @@ -431,8 +431,9 @@ otb_add_test(NAME ioTuotbXMLMetadataSupplierTest COMMAND otbMetadataTestDriver ) - -otb_add_test(NAME ioTvImageMetadataInterfaceTest_Radarsat2 COMMAND otbMetadataTestDriver + otb_add_test(NAME ioTvImageMetadataInterfaceTest_Radarsat2 COMMAND otbMetadataTestDriver + --compare-ascii ${EPSILON_9} ${BASELINE_FILES}/ioTvImageMetadataInterfaceTest_Radarsat2.txt + ${TEMP}/ioTvImageMetadataInterfaceTest_Radarsat2.txt otbImageMetadataInterfaceTest LARGEINPUT{RADARSAT2/ALTONA/Fine_Quad-Pol_Dataset/PK6621_DK406_FQ9_20080405_124900_HH_VV_HV_VH_SLC_Altona} ${TEMP}/ioTvImageMetadataInterfaceTest_Radarsat2.txt