diff --git a/Code/IO/otbImageMetadataInterfaceFactory.cxx b/Code/IO/otbImageMetadataInterfaceFactory.cxx index f9b564bd8297eb6fe9f231d28e5f75193f762646..1291cca6d1f256896eac3f790410397de6ac1810 100644 --- a/Code/IO/otbImageMetadataInterfaceFactory.cxx +++ b/Code/IO/otbImageMetadataInterfaceFactory.cxx @@ -28,6 +28,8 @@ #include "otbSpotImageMetadataInterfaceFactory.h" #include "otbQuickBirdImageMetadataInterfaceFactory.h" // SAR Sensors +//#include "otbTerraSarImageMetadataInterfaceFactory.h" + #include "itkObjectFactoryBase.h" #include "itkMutexLock.h" #include "itkMutexLockHolder.h" @@ -87,7 +89,7 @@ ImageMetadataInterfaceFactory itk::ObjectFactoryBase::RegisterFactory( IkonosImageMetadataInterfaceFactory::New() ); itk::ObjectFactoryBase::RegisterFactory( SpotImageMetadataInterfaceFactory::New() ); itk::ObjectFactoryBase::RegisterFactory( QuickBirdImageMetadataInterfaceFactory::New() ); - //itk::ObjectFactoryBase::RegisterFactory( QuickBirdImageMetadataInterfaceFactory::New() ); + //itk::ObjectFactoryBase::RegisterFactory( TerraSarImageMetadataInterfaceFactory::New() ); firstTime = false; } } diff --git a/Code/IO/otbTerraSarImageMetadataInterface.cxx b/Code/IO/otbTerraSarImageMetadataInterface.cxx index 995f06ca47f3fef147e33591c29c5c7de77d748b..8a1519f61c280e1d6afe5df0f8556e905df30213 100644 --- a/Code/IO/otbTerraSarImageMetadataInterface.cxx +++ b/Code/IO/otbTerraSarImageMetadataInterface.cxx @@ -44,20 +44,17 @@ std::string TerraSarImageMetadataInterface::GetSensorID( const MetaDataDictionaryType & dict ) const { ImageKeywordlistType ImageKeywordlist; - std::cout<<"theSensorID"<<std::endl; if (dict.HasKey(MetaDataKey::OSSIMKeywordlistKey)) { itk::ExposeMetaData<ImageKeywordlistType>(dict, MetaDataKey::OSSIMKeywordlistKey, ImageKeywordlist); } ossimKeywordlist kwl; ImageKeywordlist.convertToOSSIMKeywordlist(kwl); - std::cout<<kwl<<std::endl; - std::cout<<"##########################################################"<<std::endl; std::string key= "sensor"; ossimString keywordString = kwl.find(key.c_str()); std::string output(keywordString.chars()); - + return output; } @@ -65,8 +62,7 @@ bool TerraSarImageMetadataInterface::CanRead( const MetaDataDictionaryType & dict ) const { std::string sensorID = GetSensorID(dict); - std::cout<<"sensorID : "<<sensorID<<std::endl; - if (sensorID.find("TerraSar") != std::string::npos) + if (sensorID.find("TSX") != std::string::npos) return true; else return false; @@ -80,7 +76,7 @@ TerraSarImageMetadataInterface::GetDay( const MetaDataDictionaryType & dict ) co { itkExceptionMacro(<<"Invalid Metadata, no TerraSar Image"); } - /* + ImageKeywordlistType imageKeywordlist; if (dict.HasKey(MetaDataKey::OSSIMKeywordlistKey)) @@ -93,7 +89,7 @@ TerraSarImageMetadataInterface::GetDay( const MetaDataDictionaryType & dict ) co std::string key; ossimString separatorList; - key = "support_data.image_date"; + key = "azimuth_start_time"; separatorList = "-T"; ossimString keywordString = kwl.find(key.c_str()); @@ -105,8 +101,6 @@ TerraSarImageMetadataInterface::GetDay( const MetaDataDictionaryType & dict ) co ossimString day = keywordStrings[2]; return day.toInt(); - */ - return 1; } @@ -118,7 +112,7 @@ TerraSarImageMetadataInterface::GetMonth( const MetaDataDictionaryType & dict ) { itkExceptionMacro(<<"Invalid Metadata, no TerraSar Image"); } - /* + ImageKeywordlistType imageKeywordlist; if (dict.HasKey(MetaDataKey::OSSIMKeywordlistKey)) @@ -131,7 +125,7 @@ TerraSarImageMetadataInterface::GetMonth( const MetaDataDictionaryType & dict ) std::string key; ossimString separatorList; - key = "support_data.image_date"; + key = "azimuth_start_time"; separatorList = "-T"; @@ -144,8 +138,6 @@ TerraSarImageMetadataInterface::GetMonth( const MetaDataDictionaryType & dict ) ossimString month = keywordStrings[1]; return month.toInt(); - */ - return 1; } @@ -156,7 +148,7 @@ TerraSarImageMetadataInterface::GetYear( const MetaDataDictionaryType & dict ) c { itkExceptionMacro(<<"Invalid Metadata, no TerraSar Image"); } - /* + ImageKeywordlistType imageKeywordlist; if (dict.HasKey(MetaDataKey::OSSIMKeywordlistKey)) @@ -169,7 +161,7 @@ TerraSarImageMetadataInterface::GetYear( const MetaDataDictionaryType & dict ) c std::string key; ossimString separatorList; - key = "support_data.image_date"; + key = "azimuth_start_time"; separatorList = "-T"; ossimString keywordString = kwl.find(key.c_str()); @@ -181,8 +173,7 @@ TerraSarImageMetadataInterface::GetYear( const MetaDataDictionaryType & dict ) c ossimString year = keywordStrings[0]; return year.toInt(); - */ - return 1; + } int @@ -192,7 +183,7 @@ TerraSarImageMetadataInterface::GetHour( const MetaDataDictionaryType & dict ) c { itkExceptionMacro(<<"Invalid Metadata, no TerraSar Image"); } - /* + ImageKeywordlistType imageKeywordlist; if (dict.HasKey(MetaDataKey::OSSIMKeywordlistKey)) @@ -205,20 +196,18 @@ TerraSarImageMetadataInterface::GetHour( const MetaDataDictionaryType & dict ) c std::string key; ossimString separatorList; - key = "support_data.image_date"; + key = "azimuth_start_time"; separatorList = "-T:"; ossimString keywordString = kwl.find(key.c_str()); std::vector<ossimString> keywordStrings = keywordString.split(separatorList); - if( keywordStrings.size() <= 2 ) + if( keywordStrings.size() <= 4 ) itkExceptionMacro("Invalid Hour"); ossimString hour = keywordStrings[3]; return hour.toInt(); - */ - return 1; } int @@ -228,7 +217,7 @@ TerraSarImageMetadataInterface::GetMinute( const MetaDataDictionaryType & dict ) { itkExceptionMacro(<<"Invalid Metadata, no TerraSar Image"); } - /* + ImageKeywordlistType imageKeywordlist; if (dict.HasKey(MetaDataKey::OSSIMKeywordlistKey)) @@ -241,19 +230,17 @@ TerraSarImageMetadataInterface::GetMinute( const MetaDataDictionaryType & dict ) std::string key; ossimString separatorList; - key = "support_data.image_date"; + key = "azimuth_start_time"; separatorList = "-T:"; ossimString keywordString = kwl.find(key.c_str()); std::vector<ossimString> keywordStrings = keywordString.split(separatorList); - if( keywordStrings.size() <= 2 ) + if( keywordStrings.size() <= 5 ) itkExceptionMacro("Invalid Minute"); ossimString minute = keywordStrings[4]; return minute.toInt(); - */ - return 1; } int @@ -276,14 +263,14 @@ TerraSarImageMetadataInterface::GetProductionDay( const MetaDataDictionaryType & std::string key; ossimString separatorList; - key = "support_data.generation_time"; + key = "generation_time"; separatorList = "-T:"; ossimString keywordString = kwl.find(key.c_str()); std::vector<ossimString> keywordStrings = keywordString.split(separatorList); if(keywordStrings.size() <= 2) - itkExceptionMacro(<<"Invalid Day"); + itkExceptionMacro(<<"Invalid Production Day"); ossimString day = keywordStrings[2]; @@ -310,14 +297,14 @@ TerraSarImageMetadataInterface::GetProductionMonth( const MetaDataDictionaryType std::string key; ossimString separatorList; - key = "support_data.generation_time"; + key = "generation_time"; separatorList = "-T"; ossimString keywordString = kwl.find(key.c_str()); std::vector<ossimString> keywordStrings = keywordString.split(separatorList); if(keywordStrings.size() <= 2) - itkExceptionMacro(<<"Invalid Month"); + itkExceptionMacro(<<"Invalid Production Month"); ossimString month = keywordStrings[1]; @@ -345,21 +332,43 @@ TerraSarImageMetadataInterface::GetProductionYear( const MetaDataDictionaryType std::string key; ossimString separatorList; - key = "support_data.generation_time"; + key = "generation_time"; separatorList = "-T"; ossimString keywordString = kwl.find(key.c_str()); std::vector<ossimString> keywordStrings = keywordString.split(separatorList); if( keywordStrings.size() <= 2 ) - itkExceptionMacro("Invalid Year"); + itkExceptionMacro("Invalid Production Year"); ossimString year = keywordStrings[0]; return year.toInt(); } +double +TerraSarImageMetadataInterface::GetCalibrationFactor( const MetaDataDictionaryType & dict ) const +{ + if( !this->CanRead( dict ) ) + { + itkExceptionMacro(<<"Invalid Metadata, no TerraSar Image"); + } + ImageKeywordlistType imageKeywordlist; + + if (dict.HasKey(MetaDataKey::OSSIMKeywordlistKey)) + { + itk::ExposeMetaData<ImageKeywordlistType>(dict, MetaDataKey::OSSIMKeywordlistKey, imageKeywordlist); + } + + ossimKeywordlist kwl; + imageKeywordlist.convertToOSSIMKeywordlist(kwl); + + std::string key = "calibration.calibrationConstant.calFactor"; + ossimString calFac = kwl.find(key.c_str()); + + return calFac.toDouble(); +} } // end namespace otb diff --git a/Code/IO/otbTerraSarImageMetadataInterface.h b/Code/IO/otbTerraSarImageMetadataInterface.h index 0ca5ec2ae7c1f8e9a12448ebcde00320cd57bb37..9ac96ad82fd8c42dccdbae1a6e8a413efb2eca32 100644 --- a/Code/IO/otbTerraSarImageMetadataInterface.h +++ b/Code/IO/otbTerraSarImageMetadataInterface.h @@ -63,54 +63,36 @@ public: /** Set the image used to get the metadata */ itkSetObjectMacro(Image,ImageType); - /** Get the radiometric bias from the ossim metadata */ - VariableLengthVectorType GetPhysicalBias( const MetaDataDictionaryType & ) const - { - VariableLengthVectorType toto; - return toto; - }; - - /** Get the radiometric gain from the ossim metadata */ - VariableLengthVectorType GetPhysicalGain( const MetaDataDictionaryType & ) const - { - VariableLengthVectorType toto; - return toto; - }; - - /** Get the solar irradiance from the ossim metadata */ - VariableLengthVectorType GetSolarIrradiance( const MetaDataDictionaryType & ) const - { - VariableLengthVectorType toto; - return toto; - }; - /** Get the sensor ID from the ossim metadata */ std::string GetSensorID(const MetaDataDictionaryType & dict ) const; - /** Get the imaging acquisition day from the ossim metadata */ + /** Get the imaging start acquisition day from the ossim metadata */ int GetDay( const MetaDataDictionaryType & ) const; - /** Get the imaging acquisition month from the ossim metadata */ + /** Get the imaging start acquisition month from the ossim metadata */ int GetMonth( const MetaDataDictionaryType & ) const; - /** Get the imaging acquisition year from the ossim metadata */ + /** Get the imaging start acquisition year from the ossim metadata */ int GetYear( const MetaDataDictionaryType & ) const; - /** Get the imaging acquisition hour from the ossim metadata */ + /** Get the imaging start acquisition hour from the ossim metadata */ int GetHour( const MetaDataDictionaryType & ) const; - /** Get the imaging acquisition minute from the ossim metadata */ + /** Get the imaging start acquisition minute from the ossim metadata */ int GetMinute( const MetaDataDictionaryType & ) const; - /** Get the imaging production day from the ossim metadata */ + /** Get the imaging production day from the ossim metadata : generationTime variable */ int GetProductionDay( const MetaDataDictionaryType & ) const; - /** Get the imaging production month from the ossim metadata */ + /** Get the imaging production month from the ossim metadata : generationTime variable */ int GetProductionMonth( const MetaDataDictionaryType & ) const; - /** Get the imaging production year from the ossim metadata */ + /** Get the imaging production year from the ossim metadata : generationTime variable */ int GetProductionYear( const MetaDataDictionaryType & ) const; + /** Get the calibration.calFactor : generationTime variable */ + double GetCalibrationFactor( const MetaDataDictionaryType & ) const; + bool CanRead( const MetaDataDictionaryType & ) const; protected: diff --git a/Testing/Code/IO/CMakeLists.txt b/Testing/Code/IO/CMakeLists.txt index ea165bcb386812262bcefd973275d5c10e47ecd3..3cad40f5b54d426ac23db72f882ce8384aeb20a9 100755 --- a/Testing/Code/IO/CMakeLists.txt +++ b/Testing/Code/IO/CMakeLists.txt @@ -1992,14 +1992,6 @@ ADD_TEST(ioTvImageMetadataInterfaceSPOTTest ${IO_TESTS17} ${LARGEDATA}/SPOT5/TEHERAN/IMAGERY.TIF ${TEMP}/ioTvImageMetadataInterfaceSPOT.txt ) - -ADD_TEST(ioTvImageMetadataInterfaceTerraSarTest ${IO_TESTS17} - --compare-ascii ${NOTOL} ${BASELINE_FILES}/ioTvImageMetadataInterfaceTerraSarTest.txt - ${TEMP}/ioTvImageMetadataInterfaceTerraSarTest.txt - otbImageMetadataInterfaceTest - ${LARGEDATA}/TERRASARX/2007-12-15_Toronto_SSC/TSX1_SAR__SSC______SL_S_SRA_20071215T112105_20071215T112107/IMAGEDATA/IMAGE_HH_SRA_spot_074.cos - ${TEMP}/ioTvImageMetadataInterfaceTerraSarTest.txt -) ENDIF(OTB_DATA_USE_LARGEINPUT) ADD_TEST(ioTvImageMetadataInterfaceTest ${IO_TESTS17} @@ -2015,14 +2007,20 @@ ADD_TEST(ioTvImageMetadataInterfaceTest ${IO_TESTS17} # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ IF(OTB_DATA_USE_LARGEINPUT) -ADD_TEST(ioTvTerraSarImageMetadataInterface ${IO_TESTS18} - --compare-ascii ${EPSILON_9} ${BASELINE_FILES}/ioTvTerraSarImageMetadataInterface.txt - ${TEMP}/ioTvITerraSarImageMetadataInterface.txt +ADD_TEST(ioTvTerraSarImageMetadataInterface_dims ${IO_TESTS18} + --compare-ascii ${EPSILON_9} ${BASELINE_FILES}/ioTvTerraSarImageMetadataInterface_dims.txt + ${TEMP}/ioTvTerraSarImageMetadataInterface_dims.txt otbTerraSarImageMetadataInterface ${LARGEDATA}/TERRASARX/dims/TSX-1.SAR.L1B/TSX1_SAR__SSC/IMAGEDATA/IMAGE_HH_SRA_strip_011.cos - ${TEMP}/ioTvTerraSarImageMetadataInterface.txt + ${TEMP}/ioTvTerraSarImageMetadataInterface_dims.txt +) +ADD_TEST(ioTvTerraSarImageMetadataInterface_TORONTO ${IO_TESTS18} + --compare-ascii ${EPSILON_9} ${BASELINE_FILES}/ioTvTerraSarImageMetadataInterface_TORONTO.txt + ${TEMP}/ioTvTerraSarImageMetadataInterface_TORONTO.txt + otbTerraSarImageMetadataInterface + ${LARGEDATA}/TERRASARX/TORONTO/TSX1_SAR__SSC/IMAGEDATA/IMAGE_HH_SRA_spot_074.cos + ${TEMP}/ioTvTerraSarImageMetadataInterface_TORONTO.txt ) - ADD_TEST(ioTvImageKeywordlistSpot5 ${IO_TESTS18} --compare-n-ascii ${NOTOL} 2 diff --git a/Testing/Code/IO/otbImageMetadataInterfaceTest.cxx b/Testing/Code/IO/otbImageMetadataInterfaceTest.cxx index f6366a16befb867ce0094012d5598443391c826a..efb8f58b58874fb7d6143d20c3624dea7f9f02be 100644 --- a/Testing/Code/IO/otbImageMetadataInterfaceTest.cxx +++ b/Testing/Code/IO/otbImageMetadataInterfaceTest.cxx @@ -46,6 +46,7 @@ int otbImageMetadataInterfaceTest (int argc, char* argv[]) std::ofstream file; file.open(outputFilename); + std::cout<<lImageMetadata->GetSensorID(reader->GetOutput()->GetMetaDataDictionary())<<std::endl; file<<"GetSensorID: "<<lImageMetadata->GetSensorID(reader->GetOutput()->GetMetaDataDictionary())<<std::endl; file<<"GetPhysicalGain: "<<lImageMetadata->GetPhysicalGain(reader->GetOutput()->GetMetaDataDictionary())<<std::endl; file<<"GetPhysicalBias: "<<lImageMetadata->GetPhysicalBias(reader->GetOutput()->GetMetaDataDictionary())<<std::endl; diff --git a/Testing/Code/IO/otbTerraSarImageMetadataInterface.cxx b/Testing/Code/IO/otbTerraSarImageMetadataInterface.cxx index 7fa5790e5e04b42aa1684309fbe81dc6410bacf5..3945eb37dd287208c3f1bb02b57e9e4c530f991d 100644 --- a/Testing/Code/IO/otbTerraSarImageMetadataInterface.cxx +++ b/Testing/Code/IO/otbTerraSarImageMetadataInterface.cxx @@ -43,19 +43,18 @@ int otbTerraSarImageMetadataInterface (int argc, char* argv[]) otb::TerraSarImageMetadataInterface::Pointer lImageMetadata = otb::TerraSarImageMetadataInterface::New(); - reader->GetOutput()->GetMetaDataDictionary().Print(std::cout); - std::ofstream file; file.open(outputFilename); - file<<"GetSensorID: "<<lImageMetadata->GetSensorID(reader->GetOutput()->GetMetaDataDictionary())<<std::endl; - file<<"GetMinute: "<<lImageMetadata->GetMinute(reader->GetOutput()->GetMetaDataDictionary())<<std::endl; - file<<"GetHour: "<<lImageMetadata->GetHour(reader->GetOutput()->GetMetaDataDictionary())<<std::endl; - file<<"GetDay: "<<lImageMetadata->GetDay(reader->GetOutput()->GetMetaDataDictionary())<<std::endl; - file<<"GetMonth: "<<lImageMetadata->GetMonth(reader->GetOutput()->GetMetaDataDictionary())<<std::endl; - file<<"GetYear: "<<lImageMetadata->GetYear(reader->GetOutput()->GetMetaDataDictionary())<<std::endl; - file<<"GetProductionDay: "<<lImageMetadata->GetProductionDay(reader->GetOutput()->GetMetaDataDictionary())<<std::endl; - file<<"GetProductionMonth: "<<lImageMetadata->GetProductionMonth(reader->GetOutput()->GetMetaDataDictionary())<<std::endl; - file<<"GetProductionYear: "<<lImageMetadata->GetProductionYear(reader->GetOutput()->GetMetaDataDictionary())<<std::endl; + file<<"GetSensorID: "<<lImageMetadata->GetSensorID(reader->GetOutput()->GetMetaDataDictionary())<<std::endl; + file<<"GetMinute: "<<lImageMetadata->GetMinute(reader->GetOutput()->GetMetaDataDictionary())<<std::endl; + file<<"GetHour: "<<lImageMetadata->GetHour(reader->GetOutput()->GetMetaDataDictionary())<<std::endl; + file<<"GetDay: "<<lImageMetadata->GetDay(reader->GetOutput()->GetMetaDataDictionary())<<std::endl; + file<<"GetMonth: "<<lImageMetadata->GetMonth(reader->GetOutput()->GetMetaDataDictionary())<<std::endl; + file<<"GetYear: "<<lImageMetadata->GetYear(reader->GetOutput()->GetMetaDataDictionary())<<std::endl; + file<<"GetProductionDay: "<<lImageMetadata->GetProductionDay(reader->GetOutput()->GetMetaDataDictionary())<<std::endl; + file<<"GetProductionMonth: "<<lImageMetadata->GetProductionMonth(reader->GetOutput()->GetMetaDataDictionary())<<std::endl; + file<<"GetProductionYear: "<<lImageMetadata->GetProductionYear(reader->GetOutput()->GetMetaDataDictionary())<<std::endl; + file<<"GetCalibrationFactor: "<<lImageMetadata->GetCalibrationFactor(reader->GetOutput()->GetMetaDataDictionary())<<std::endl; file.close(); return EXIT_SUCCESS; diff --git a/Utilities/otbossimplugins/ossim/ossimTerraSarModel.cpp b/Utilities/otbossimplugins/ossim/ossimTerraSarModel.cpp index 1f9d754896d875cd30f8cc799f43b2ed98991d7c..e11a8e74268b32ceb42ac63d98e0ead6e9e270d5 100644 --- a/Utilities/otbossimplugins/ossim/ossimTerraSarModel.cpp +++ b/Utilities/otbossimplugins/ossim/ossimTerraSarModel.cpp @@ -13,6 +13,7 @@ #include <ossimPluginCommon.h> #include <ossimTerraSarProductDoc.h> #include <ossim/base/ossimKeywordNames.h> +#include <ossim/base/ossimDirectory.h> #include <ossim/base/ossimRefPtr.h> #include <ossim/base/ossimTrace.h> #include <ossim/base/ossimXmlDocument.h> @@ -39,6 +40,9 @@ static const char ALT_SR_GR_COEFFICIENT1_KW[] = "alt_sr_gr_coeff1"; static const char ALT_SR_GR_COEFFICIENT2_KW[] = "alt_sr_gr_coeff2"; static const char PRODUCT_TYPE[] = "product_type"; static const char RADIOMETRIC_CORRECTION[] = "radiometricCorrection"; +static const char AZ_START_TIME[] = "azimuth_start_time"; +static const char AZ_STOP_TIME[] = "azimuth_stop_time"; +static const char GENERATION_TIME[] = "generation_time"; static const char ACQUISITION_INFO[] = "acquisitionInfo."; static const char IMAGING_MODE[] = "imagingMode"; @@ -80,6 +84,9 @@ ossimplugins::ossimTerraSarModel::ossimTerraSarModel() _polLayer(), _noise(0), _calFactor(0.), + _azStartTime(), + _azStopTime(), + _generationTime(), theProductXmlFile() { } @@ -102,6 +109,9 @@ ossimplugins::ossimTerraSarModel::ossimTerraSarModel( _polLayer(rhs._polLayer), _noise(rhs._noise), _calFactor(rhs._calFactor), + _azStartTime(rhs._azStartTime), + _azStopTime(rhs._azStopTime), + _generationTime(rhs._generationTime), theProductXmlFile(rhs.theProductXmlFile) { } @@ -153,15 +163,37 @@ bool ossimplugins::ossimTerraSarModel::open(const ossimFilename& file) << "file: " << file << "\n"; } + ossimFilename filePath = ossimFilename(file.path()); + ossimDirectory directory = ossimDirectory(filePath.path()); + + std::vector<ossimFilename> vectName; + ossimString reg = ".xml"; + directory.findAllFilesThatMatch( vectName, reg, 1 ); + bool result = false; + ossimFilename xmlfile; + + bool goodFileFound = false; + unsigned int loop = 0; + while(loop<vectName.size() && !goodFileFound) + { + ossimFilename curFile = vectName[loop]; + if(curFile.file().beforePos(3) == ossimString("TSX")) + goodFileFound = true; + else + loop++; +} - if ( file.exists() && (file.ext().downcase() == "xml") ) + //if ( file.exists() && (file.ext().downcase() == "xml") ) + if(goodFileFound) { + xmlfile = vectName[loop]; + //--- // Instantiate the XML parser: //--- ossimXmlDocument* xdoc = new ossimXmlDocument(); - if ( xdoc->openFile(file) ) + if ( xdoc->openFile(xmlfile) ) { ossimTerraSarProductDoc tsDoc; @@ -170,7 +202,6 @@ bool ossimplugins::ossimTerraSarModel::open(const ossimFilename& file) if (debug) cout << "result of IsTSX " << result << endl; - if (result) { if (traceDebug()) @@ -204,18 +235,18 @@ bool ossimplugins::ossimTerraSarModel::open(const ossimFilename& file) { result = tsDoc.getSceneId(xdoc, theImageID); if (debug) - cout << "result of getting SceneIDe" << result << endl; + cout << "result of getting SceneID" << result << endl; } // Set the sensor ID to the mission ID. if (result) { result = tsDoc.getMission(xdoc, theSensorID); + + if (debug) + cout << "result of getting MissionID...." << result << endl; } - if (debug) - cout << "result of getting MissionID...." << result << endl; - // Set the base class gsd: result = tsDoc.initGsd(xdoc, theGSD); @@ -272,14 +303,23 @@ bool ossimplugins::ossimTerraSarModel::open(const ossimFilename& file) ossimString s; result = tsDoc.getCalFactor(xdoc, s); _calFactor = s.toFloat64(); + if (result) + { + result = tsDoc.getAzimuthStartTime(xdoc, _azStartTime); + if (result) + { + result = tsDoc.getAzimuthStopTime(xdoc, _azStopTime); + if (result) + { + result = tsDoc.getGenerationTime(xdoc, _generationTime); + } + } + } } } } } - } - - } } } @@ -301,10 +341,10 @@ bool ossimplugins::ossimTerraSarModel::open(const ossimFilename& file) if (result) { - theProductXmlFile = file; + theProductXmlFile = xmlfile; if (debug) - cout << "theProductXmlFile : " << file << endl; + cout << "theProductXmlFile : " << xmlfile << endl; // Assign the ossimSensorModel::theBoundGndPolygon ossimGpt ul; @@ -397,6 +437,7 @@ bool ossimplugins::ossimTerraSarModel::saveState(ossimKeywordlist& kwl, } kwl.add(prefix, PRODUCT_TYPE, _productType.c_str()); + kwl.add(prefix, RADIOMETRIC_CORRECTION, _radiometricCorrection.c_str()); ossimString kw = ACQUISITION_INFO; @@ -415,6 +456,10 @@ bool ossimplugins::ossimTerraSarModel::saveState(ossimKeywordlist& kwl, _noise->saveState(kwl,prefix); kwl.add(prefix, CALIBRATION_CALFACTOR, ossimString::toString(_calFactor).c_str()); + kwl.add(prefix, AZ_START_TIME, _azStartTime.c_str()); + kwl.add(prefix, AZ_STOP_TIME, _azStopTime.c_str()); + kwl.add(prefix, GENERATION_TIME, _generationTime.c_str()); + if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) @@ -451,6 +496,7 @@ bool ossimplugins::ossimTerraSarModel::loadState (const ossimKeywordlist &kwl, // Get the product.xml file name. lookup = kwl.find(prefix, PRODUCT_XML_FILE_KW); + if (lookup) { theProductXmlFile = lookup; @@ -719,6 +765,57 @@ bool ossimplugins::ossimTerraSarModel::loadState (const ossimKeywordlist &kwl, result = false; } + lookup = kwl.find(prefix, AZ_START_TIME); + if (lookup) + { + _azStartTime = lookup; + } + else + { + if (traceDebug()) + { + ossimNotify(ossimNotifyLevel_WARN) + << MODULE + << "\nRequired keyword not found: " + << AZ_START_TIME << "\n"; + } + result = false; + } + + lookup = kwl.find(prefix, AZ_STOP_TIME); + if (lookup) + { + _azStopTime = lookup; + } + else + { + if (traceDebug()) + { + ossimNotify(ossimNotifyLevel_WARN) + << MODULE + << "\nRequired keyword not found: " + << AZ_STOP_TIME << "\n"; + } + result = false; + } + + lookup = kwl.find(prefix, GENERATION_TIME); + if (lookup) + { + _generationTime = lookup; + } + else + { + if (traceDebug()) + { + ossimNotify(ossimNotifyLevel_WARN) + << MODULE + << "\nRequired keyword not found: " + << GENERATION_TIME << "\n"; + } + result = false; + } + if (traceDebug()) { @@ -782,8 +879,11 @@ std::ostream& ossimplugins::ossimTerraSarModel::print(std::ostream& out) const } out << CALIBRATION_CALFACTOR << ": " << _calFactor << "\n"; - // Reset flags. + out << AZ_START_TIME << ": " << _azStartTime << "\n"; + out << AZ_STOP_TIME << ": " << _azStopTime << "\n"; + out << GENERATION_TIME << ": " << _generationTime << "\n"; + // Reset flags. ossimString kw = ACQUISITION_INFO; ossimString kw2 = kw + IMAGING_MODE; diff --git a/Utilities/otbossimplugins/ossim/ossimTerraSarModel.h b/Utilities/otbossimplugins/ossim/ossimTerraSarModel.h index b6ad8b6af7a6fc0c5477d97729b3b8c94c08b3c7..3427e54dcc71c6b2757c460c228073ab94d6bcd2 100644 --- a/Utilities/otbossimplugins/ossim/ossimTerraSarModel.h +++ b/Utilities/otbossimplugins/ossim/ossimTerraSarModel.h @@ -231,6 +231,21 @@ namespace ossimplugins */ double _calFactor; + /** + * @brief Azimuthal Start Time (Start acquisition time). + */ + ossimString _azStartTime; + + /** + * @brief Azimuthal Stop Time (Start acquisition time). + */ + ossimString _azStopTime; + + /** + * @brief Generation time. + */ + ossimString _generationTime; + ossimFilename theProductXmlFile; TYPE_DATA diff --git a/Utilities/otbossimplugins/ossim/ossimTerraSarProductDoc.cpp b/Utilities/otbossimplugins/ossim/ossimTerraSarProductDoc.cpp index aabb8e3e81e497e58c1960c2690f2c35fde259c8..8f80d056fc4760eee41c6544a68a76c8dc674c59 100644 --- a/Utilities/otbossimplugins/ossim/ossimTerraSarProductDoc.cpp +++ b/Utilities/otbossimplugins/ossim/ossimTerraSarProductDoc.cpp @@ -849,7 +849,7 @@ bool ossimplugins::ossimTerraSarProductDoc::getAzimuthStartTime( const ossimXmlDocument* xdoc, ossimString& s) const { ossimString path = - "/level1Product/productInfo/sceneInfo/start/timeUTC"; + "/level1Product/instrument/settings/rxGainSetting/startTimeUTC"; return ossim::getPath(path, xdoc, s); } @@ -857,7 +857,7 @@ bool ossimplugins::ossimTerraSarProductDoc::getAzimuthStopTime( const ossimXmlDocument* xdoc, ossimString& s) const { ossimString path = - "/level1Product/productInfo/sceneInfo/stop/timeUTC"; + "/level1Product/instrument/settings/rxGainSetting/stopTimeUTC"; return ossim::getPath(path, xdoc, s); }