diff --git a/Testing/Code/IO/otbImageKeywordlist.cxx b/Testing/Code/IO/otbImageKeywordlist.cxx index 09c0a9488c3e824154a44ff3e59f2d314627fa19..86eaadb0377f286e8e51c173241e21ed64b76dd0 100644 --- a/Testing/Code/IO/otbImageKeywordlist.cxx +++ b/Testing/Code/IO/otbImageKeywordlist.cxx @@ -36,7 +36,6 @@ int otbImageKeywordlist(int argc, char* argv[]) if (argc != 4) { std::cout << argv[0] << " <input filename> <output filename> <output filename2>" << std::endl; - return EXIT_FAILURE; } diff --git a/Utilities/otbossimplugins/ossim/RadarSat/Data/Data.cpp b/Utilities/otbossimplugins/ossim/RadarSat/Data/Data.cpp index e7b1021f0627ea4f24c4780bd0ded3a16fa0266b..32abbf55d46db54b9261fa81f037ec3db841cb1b 100644 --- a/Utilities/otbossimplugins/ossim/RadarSat/Data/Data.cpp +++ b/Utilities/otbossimplugins/ossim/RadarSat/Data/Data.cpp @@ -14,8 +14,12 @@ #include <RadarSat/RadarSatRecordHeader.h> #include <RadarSat/Data/ImageOptionsFileDescriptor.h> +#include <ossim/base/ossimTrace.h> + namespace ossimplugins { +// Static trace for debugging +static ossimTrace traceDebug("Data:debug"); const int Data::ImageOptionsFileDescriptorID = 1; const int Data::FirstProcessedDataRecordID = 2; @@ -48,9 +52,9 @@ std::istream& operator>>(std::istream& is, Data& data) data.ClearRecords(); - if (sizeof(int)!=4) std::cout << "RadarSat Data WARNING : (int) not coded over 32 bits, metadata might not be byte swapped correctly"<< std::endl ; - if (sizeof(float)!=4) std::cout << "RadarSat Data WARNING : (float) not coded over 32 bits, metadata might not be byte swapped correctly"<< std::endl ; - if (sizeof(double)!=8) std::cout << "RadarSat Data WARNING : (double) not coded over 64 bits, metadata might not be byte swapped correctly"<< std::endl ; + if (sizeof(int)!=4) ossimNotify(ossimNotifyLevel_WARN) << "RadarSat Data WARNING : (int) not coded over 32 bits, metadata might not be byte swapped correctly"<< std::endl ; + if (sizeof(float)!=4) ossimNotify(ossimNotifyLevel_WARN) << "RadarSat Data WARNING : (float) not coded over 32 bits, metadata might not be byte swapped correctly"<< std::endl ; + if (sizeof(double)!=8) ossimNotify(ossimNotifyLevel_WARN) << "RadarSat Data WARNING : (double) not coded over 64 bits, metadata might not be byte swapped correctly"<< std::endl ; RadarSatRecordHeader header; bool eof = false; @@ -81,7 +85,7 @@ std::istream& operator>>(std::istream& is, Data& data) nbLin = ((ImageOptionsFileDescriptor *) record)->get_nlin() ; if (nbLin == -1) { - std::cout << "WARNING: nbLin is not read in the file, it will produce some errors later !!!" << std::endl; + ossimNotify(ossimNotifyLevel_DEBUG) << "WARNING: nbLin is not read in the file !" << std::endl; } } else @@ -137,9 +141,9 @@ std::istream& operator>>(std::istream& is, Data& data) { if (nbLin == -1) { - // Compute the number of line per dataset from the size of file and the different header + // Compute the number of line per dataset from the size of file and current position int nbLines = ( ( lengthOfFile - is.tellg() ) / lineLength ) + 2; - std::cout<< "MSG: To move in the dat file we compute the nb of lines = " << nbLines << std::endl; + ossimNotify(ossimNotifyLevel_DEBUG) << "To move in the dat file we compute the nb of lines = " << nbLines << std::endl; // We move in the file to the last line is.seekg((nbLines - 2) * lineLength - 12, std::ios::cur); diff --git a/Utilities/otbossimplugins/ossim/RadarSat/Data/ImageOptionsFileDescriptor.cpp b/Utilities/otbossimplugins/ossim/RadarSat/Data/ImageOptionsFileDescriptor.cpp index e628a75389464da75cba9bd6f4cef271de3fe64f..44678c595c8a559500c8ac7a0891db023545a80b 100644 --- a/Utilities/otbossimplugins/ossim/RadarSat/Data/ImageOptionsFileDescriptor.cpp +++ b/Utilities/otbossimplugins/ossim/RadarSat/Data/ImageOptionsFileDescriptor.cpp @@ -10,10 +10,13 @@ // $Id$ #include <RadarSat/Data/ImageOptionsFileDescriptor.h> -#include <errno.h> +#include <ossim/base/ossimNotify.h> +#include <ossim/base/ossimTrace.h> namespace ossimplugins { +static ossimTrace traceDebug("ImageOptionsFileDescriptor:debug"); + ImageOptionsFileDescriptor::ImageOptionsFileDescriptor() : RadarSatRecord("imop_desc_rec") { } @@ -161,7 +164,6 @@ std::istream& operator>>(std::istream& is, ImageOptionsFileDescriptor& data) is.read(buf,16); buf[16] = '\0'; data._file_name = buf; - //std::cout<< "_file_name : " << buf <<std::endl; is.read(buf,4); buf[4] = '\0'; @@ -242,10 +244,13 @@ std::istream& operator>>(std::istream& is, ImageOptionsFileDescriptor& data) // We should use strtol() to avoid wrong conversion with atoi() char* p; int result = strtol(buf, &p, 10); - if (errno != 0 || *p != 0 || p == buf) + if ( *p != 0 || p == buf) { - std::cout << "WARNING: strtol() try to convert an empty tab of characters, buf = " << buf << "!" << std::endl; - std::cout << "=> _nlin = -1" << std::endl; + if(traceDebug()) + { + ossimNotify(ossimNotifyLevel_DEBUG) << "WARNING: strtol() try to convert an empty tab of characters. It may be possible in case of SCN and SCW format" << buf << "!" << std::endl; + ossimNotify(ossimNotifyLevel_DEBUG) << "=> _nlin = -1" << std::endl; + } data._nlin = -1; } else diff --git a/Utilities/otbossimplugins/ossim/ossimRadarSatModel.cpp b/Utilities/otbossimplugins/ossim/ossimRadarSatModel.cpp index cfbee7601f07b4e0932b6cb29a14a2850f68a082..0b2cdaebc3bfb3e2a40dd60b5ad36d0f42948c49 100644 --- a/Utilities/otbossimplugins/ossim/ossimRadarSatModel.cpp +++ b/Utilities/otbossimplugins/ossim/ossimRadarSatModel.cpp @@ -40,9 +40,6 @@ namespace ossimplugins { - - - RTTI_DEF1(ossimRadarSatModel, "ossimRadarSatModel", ossimGeometricSarSensorModel); // Static trace for debugging @@ -117,6 +114,7 @@ double ossimRadarSatModel::getSlantRangeFromGeoreferenced(double col) const bool ossimRadarSatModel::open(const ossimFilename& file) { + //traceDebug.setTraceFlag(true); if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) @@ -156,8 +154,11 @@ bool ossimRadarSatModel::open(const ossimFilename& file) } else { - ossimNotify(ossimNotifyLevel_DEBUG) + if(traceDebug()) + { + ossimNotify(ossimNotifyLevel_DEBUG) << "File Name not coherent (searching for *DAT_01* or *dat_01* or *vdf_dat* or *VDF_DAT* ) : " << file << std::endl; + } return false; } } @@ -220,24 +221,24 @@ bool ossimRadarSatModel::open(const ossimFilename& file) if ((((VolumeDescriptorRecord*) recordVDF)->get_logvol_id()).substr(0, 10) == "RSAT-1-SAR") { std::string subProduct = (((VolumeDescriptorRecord*) recordVDF)->get_logvol_id()).substr(11, 3); - if (subProduct == "RAW") - std::cout << "FATAL_ERROR: RAW format is not supported" <<std::endl; - else if (subProduct == "SCN") - std::cout << "WARNING: SCN format is supported but not tested" <<std::endl; - else if (subProduct == "SCW") - std::cout << "MSG: SCW format is supported and tested" <<std::endl; - else if (subProduct == "SGF") - std::cout << "MSG: SGF format is supported and tested" <<std::endl; - else if (subProduct == "SGX") - std::cout << "WARNING: SGX format is supported but not tested" <<std::endl; - else if (subProduct == "SLC") - std::cout << "WARNING: SLC format is supported but not tested" <<std::endl; - else if (subProduct == "SPG") - std::cout << "FATAL_ERROR: SPG format is not supported" <<std::endl; - else if (subProduct == "SSG") - std::cout << "FATAL_ERROR: SSG format is not supported" <<std::endl; - + if ( (subProduct == "RAW") || (subProduct == "SPG") || (subProduct == "SSG") ) + { + if(traceDebug()) + ossimNotify(ossimNotifyLevel_DEBUG) << "RAW, SPG and SSG format are not supported" <<std::endl; + volumeDirFile.close(); + return false; + } + else if ( (subProduct == "SCN") || (subProduct == "SGX") || (subProduct == "SLC") ) + { + if(traceDebug()) + ossimNotify(ossimNotifyLevel_DEBUG) << "SCN, SGX and SLC format are supported but not tested" <<std::endl; + } + else if ( (subProduct == "SCW") || (subProduct == "SGF") ) + { + if(traceDebug()) + ossimNotify(ossimNotifyLevel_DEBUG) << "SCW and SGF format are supported and tested" <<std::endl; + } //Reading of the remaining of the volume directory file @@ -468,7 +469,7 @@ bool ossimRadarSatModel::saveState(ossimKeywordlist& kwl, } else { - std::cerr << "It is not possible to add dataSetSummary from _leader or _trailer file" <<std::endl; + ossimNotify(ossimNotifyLevel_DEBUG) << "It is not possible to add dataSetSummary from _leader or _trailer file" <<std::endl; return false; } @@ -511,7 +512,7 @@ bool ossimRadarSatModel::saveState(ossimKeywordlist& kwl, } else { - std::cerr << "It is not possible to add processingParameters from _leader or _trailer file" <<std::endl; + ossimNotify(ossimNotifyLevel_DEBUG) << "It is not possible to add processingParameters from _leader or _trailer file" <<std::endl; return false; } @@ -549,7 +550,7 @@ bool ossimRadarSatModel::saveState(ossimKeywordlist& kwl, } else { - std::cerr << "It is not possible to add platformPositionData from _leader file" <<std::endl; + ossimNotify(ossimNotifyLevel_DEBUG) << "It is not possible to add platformPositionData from _leader file" <<std::endl; return false; } @@ -561,7 +562,7 @@ bool ossimRadarSatModel::saveState(ossimKeywordlist& kwl, } else { - std::cerr << "It is not possible to add imageOptionsFileDescriptor from _data file" <<std::endl; + ossimNotify(ossimNotifyLevel_DEBUG) << "It is not possible to add imageOptionsFileDescriptor from _data file" <<std::endl; return false; } @@ -580,7 +581,7 @@ bool ossimRadarSatModel::saveState(ossimKeywordlist& kwl, } else { - std::cerr << "It is not possible to add firstProcessedDataRecord from _data file" <<std::endl; + ossimNotify(ossimNotifyLevel_DEBUG) << "It is not possible to add firstProcessedDataRecord from _data file" <<std::endl; return false; } @@ -599,7 +600,7 @@ bool ossimRadarSatModel::saveState(ossimKeywordlist& kwl, } else { - std::cerr << "It is not possible to add lastProcessedDataRecord from _data file" <<std::endl; + ossimNotify(ossimNotifyLevel_DEBUG) << "It is not possible to add lastProcessedDataRecord from _data file" <<std::endl; return false; } @@ -1037,10 +1038,6 @@ bool ossimRadarSatModel::InitSRGR(const ossimKeywordlist &kwl, const char *prefi // pixel spacing const char* pixel_spacing_str = kwl.find(prefix,"pixel_spacing"); - if (!pixel_spacing_str) - { - std::cout << "pixel_spacing_str is NULL" <<std::endl; - } _pixel_spacing = atof(pixel_spacing_str); // number of SRGR sets