Loading .gitignore +2 −1 Original line number Diff line number Diff line Loading @@ -27,10 +27,11 @@ object_script.*.Debug *_plugin_import.cpp *.moc ui_*.h *.html *html # ignore all files created by squish coco *csmes *csexe print.prt Loading isis/src/base/objs/ProcessImport/ProcessImport.cpp +42 −60 Original line number Diff line number Diff line Loading @@ -1847,11 +1847,6 @@ namespace Isis { */ void ProcessImport::ProcessBip(void funct(Isis::Buffer &out)) { // Figure out the number of bytes to read for a single line int readBytes = Isis::SizeOf(p_pixelType); readBytes = readBytes * p_ns * p_nb; char *in = new char [readBytes]; // Set up an Isis::EndianSwapper object QString tok(Isis::ByteOrderName(p_byteOrder)); tok = tok.toUpper(); Loading Loading @@ -1902,6 +1897,11 @@ namespace Isis { p_progress->SetMaximumSteps(p_nl); p_progress->CheckStatus(); // Figure out the number of bytes to read for a single line int sampleBytes = Isis::SizeOf(p_pixelType) * p_nb + p_dataPreBytes + p_dataPostBytes; int readBytes = p_ns * sampleBytes; char *in = new char [readBytes]; // Loop for each line for(int line = 0; line < p_nl; line++) { // Check the last io Loading @@ -1915,16 +1915,6 @@ namespace Isis { // Space for storing prefix and suffix data pointers vector<char *> tempPre, tempPost; // Handle any line prefix bytes pos = fin.tellg(); if (p_saveDataPre) { tempPre.push_back(new char[p_dataPreBytes]); fin.read(tempPre.back(), p_dataPreBytes); } else { fin.seekg(p_dataPreBytes, ios_base::cur); } // Check the last io if (!fin.good()) { QString msg = "Cannot read file [" + p_inFile + "]. Position [" + Loading Loading @@ -1960,31 +1950,32 @@ namespace Isis { // to special pixels int osamp = 0; for(int samp = band; samp < p_ns * p_nb; samp += p_nb) { for(int samp = 0; samp < p_ns; samp++) { int bufferIndex = p_dataPreBytes + Isis::SizeOf(p_pixelType)*band + samp*sampleBytes; switch(p_pixelType) { case Isis::UnsignedByte: (*out)[osamp] = (double)((unsigned char *)in)[samp]; (*out)[osamp] = (double)((unsigned char *)in)[bufferIndex]; break; case Isis::UnsignedWord: (*out)[osamp] = (double)swapper.UnsignedShortInt((unsigned short int *)in+samp); (double)swapper.UnsignedShortInt(&in[bufferIndex]); break; case Isis::SignedWord: (*out)[osamp] = (double)swapper.ShortInt((short int *)in+samp); (*out)[osamp] = (double)swapper.ShortInt(&in[bufferIndex]); break; case Isis::SignedInteger: (*out)[samp] = (double)swapper.Int((int *)in+samp); (*out)[samp] = (double)swapper.Int(&in[bufferIndex]); break; case Isis::Real: if(p_vax_convert) { (*out)[osamp]= VAXConversion( (float *)in+samp ); (*out)[osamp]= VAXConversion(&in[bufferIndex]); } else { (*out)[osamp] = (double)swapper.Float((float *)in+samp); (*out)[osamp] = (double)swapper.Float(&in[bufferIndex]); } break; case Isis::Double: (*out)[osamp] = (double)swapper.Double((double *)in+samp); (*out)[osamp] = (double)swapper.Double(&in[bufferIndex]); break; default: break; Loading @@ -2008,33 +1999,25 @@ namespace Isis { funct(*out); } // Handle any line suffix bytes pos = fin.tellg(); if (p_saveDataPost) { tempPost.push_back(new char[p_dataPostBytes]); fin.read(tempPost.back(), p_dataPostBytes); } else { fin.seekg(p_dataPostBytes, ios_base::cur); } // Check the last io if (!fin.good()) { QString msg = "Cannot read file [" + p_inFile + "]. Position [" + toString((int)pos) + "]. Byte count [" + toString(p_dataPreBytes) + "]" ; throw IException(IException::Io, msg, _FILEINFO_); } } // End band loop // Save off the prefix bytes vector // Handle record prefix and suffix if (p_saveDataPre) { for(int samp = 0; samp < p_ns; samp++) { char *samplePrefix = new char[p_dataPreBytes]; memcpy(samplePrefix, &in[samp*sampleBytes], p_dataPreBytes); tempPre.push_back(samplePrefix); } p_dataPre.push_back(tempPre); tempPre.clear(); } // Save off the suffix bytes vector if (p_saveDataPost) { for(int samp = 0; samp < p_ns; samp++) { char *sampleSuffix = new char[p_dataPostBytes]; int suffixIndex = p_dataPreBytes + Isis::SizeOf(p_pixelType)*p_nb + samp*sampleBytes; memcpy(sampleSuffix, &in[suffixIndex], p_dataPostBytes); tempPost.push_back(sampleSuffix); } p_dataPost.push_back(tempPost); tempPost.clear(); } Loading @@ -2043,12 +2026,11 @@ namespace Isis { if (!fin.good()) { QString msg = "Cannot read file [" + p_inFile + "]. Position [" + toString((int)pos) + "]. Byte count [" + toString(p_fileHeaderBytes) + "]" ; toString(p_dataPreBytes) + "]" ; throw IException(IException::Io, msg, _FILEINFO_); } } // End band loop // Handle the data trailer pos = fin.tellg(); if (p_saveDataTrailer) { p_dataTrailer.push_back(new char[p_dataTrailerBytes]); Loading isis/src/base/objs/ProcessImport/ProcessImport.h +13 −2 Original line number Diff line number Diff line Loading @@ -152,6 +152,17 @@ namespace Isis { * @history 2017-05-29 Kristin Berry - Added support for data trailers in BIP files and fixed * a typo so that DataTrailerBytes() will return the correct value. * References #3888. * @history 2018-05-01 Jesse Mapel - Changed data suffix and prefix in BIP files. Previously, * data suffixes and prefixes were for each band before/after each line. * Now, data suffixes and prefixes are before/after each sample. For a * RGB, 3-band image with n samples a line of data was previously * | Header | R prefix | G prefix | B prefix | R 1 | G 1 | B 1| ... * | R n | G n | B n| R suffix | G suffix | B suffix | Trailer |. Now * it is | Header | Prefix 1 | R 1 | G 1 | B 1 | Suffix 1 | ... * | Prefix n | R n | G n | B n | Suffix n | Trailer |. This change * was made to accomodate Rosetta VIRTIS-m calibrated data files and * has no impact on other supported BIP files. * Fixes #5398. * */ class ProcessImport : public Isis::Process { Loading isis/src/base/objs/PvlToPvlTranslationManager/PvlToPvlTranslationManager.cpp +77 −51 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ namespace Isis { * set the input label before translating. This may be done by using * SetLabel(Pvl inputLabel) or Auto(Pvl inputLabel, Pvl outputLabel). * * @param transFile The translation file to be used to tranlate keywords in * @param transFile The translation file to be used to translate keywords in * the input label. */ PvlToPvlTranslationManager::PvlToPvlTranslationManager(const QString &transFile) Loading @@ -53,8 +53,8 @@ namespace Isis { * input label before translating. This may be done by using SetLabel(Pvl * inputLabel) or Auto(Pvl inputLabel, Pvl outputLabel). * * @param transStrm A stream containing the tranlation table to be used to * tranlate keywords in the input label. * @param transStrm A stream containing the translation table to be used to * translate keywords in the input label. */ PvlToPvlTranslationManager::PvlToPvlTranslationManager(std::istream &transStrm) : LabelTranslationManager(transStrm) { Loading @@ -66,7 +66,7 @@ namespace Isis { * * @param inputLabel The Pvl holding the input label. * * @param transFile The translation file to be used to tranlate keywords in * @param transFile The translation file to be used to translate keywords in * the input label. */ PvlToPvlTranslationManager::PvlToPvlTranslationManager(Pvl &inputLabel, Loading @@ -81,8 +81,8 @@ namespace Isis { * * @param inputLabel The Pvl holding the input label. * * @param transStrm A stream containing the tranlation table to be used to * tranlate keywords in the input label. * @param transStrm A stream containing the translation table to be used to * translate keywords in the input label. */ PvlToPvlTranslationManager::PvlToPvlTranslationManager(Pvl &inputLabel, std::istream &transStrm) Loading @@ -103,47 +103,58 @@ namespace Isis { /** * Returns a translated value. The output name is used to find the input * group, keyword, default and tranlations in the translation table. If the * keyword does not exist in the input label, the input default if * available will be used as the input value. This input value * is then used to search all of the translations. If a match is * found the translated value is returned. * group, keyword, default and translations in the translation table. If the * keyword does not exist in the input label and an input default is available, * then this default will be used as the input value. This input value is * then used to search all of the translations. If a match is found the * translated value is returned. * * @param nName The output name used to identify the input keyword to be * translated. * @param translationGroupName The name of the PVL translation * group used to identify the * input/output keywords to be * translated. Often, this is the * same as the output keyword name. * * @param findex The index into the input keyword array. Defaults to 0 * * @return string */ QString PvlToPvlTranslationManager::Translate(QString nName, int findex) { QString PvlToPvlTranslationManager::Translate(QString translationGroupName, int findex) { const PvlContainer *con; int inst = 0; PvlKeyword grp; while((grp = InputGroup(nName, inst++)).name() != "") { while((grp = InputGroup(translationGroupName, inst++)).name() != "") { if((con = GetContainer(grp)) != NULL) { if(con->hasKeyword(InputKeywordName(nName))) { return PvlTranslationTable::Translate(nName, (*con)[InputKeywordName(nName)][findex]); if(con->hasKeyword(InputKeywordName(translationGroupName))) { return PvlTranslationTable::Translate(translationGroupName, (*con)[InputKeywordName(translationGroupName)][findex]); } } } return PvlTranslationTable::Translate(nName); return PvlTranslationTable::Translate(translationGroupName); } /** * Translate the requested output name to output values using the input name * and values or default value * and values or default value. * * @param nName The output name used to identify the input keyword to be * translated. * Note: This is a protected method used when automatically * translating * * @see Auto(). * * @param translationGroupName The name of the PVL translation * group used to identify the * input/output keywords to be * translated. Often, this is the * same as the output keyword name. * * @return PvlKeyword */ PvlKeyword PvlToPvlTranslationManager::DoTranslation(const QString nName) { PvlKeyword PvlToPvlTranslationManager::DoTranslation(const QString translationGroupName) { const PvlContainer *con = NULL; PvlKeyword key; Loading @@ -151,9 +162,9 @@ namespace Isis { PvlGroup transGroup; PvlKeyword grp; while((grp = InputGroup(nName, inst++)).name() != "") { while((grp = InputGroup(translationGroupName, inst++)).name() != "") { if((con = GetContainer(grp)) != NULL) { transGroup = TranslationTable().findGroup(nName); transGroup = TranslationTable().findGroup(translationGroupName); Pvl::ConstPvlKeywordIterator it = transGroup.findKeyword("InputKey", transGroup.begin(), transGroup.end()); Loading @@ -162,10 +173,10 @@ namespace Isis { while(it != transGroup.end()) { const PvlKeyword &result = *it; if(con->hasKeyword(result[0])) { key.setName(OutputName(nName)); key.setName(OutputName(translationGroupName)); for(int v = 0; v < (*con)[(result[0])].size(); v++) { key.addValue(PvlTranslationTable::Translate(nName, key.addValue(PvlTranslationTable::Translate(translationGroupName, (*con)[result[0]][v]), (*con)[result[0]].unit(v)); } Loading @@ -177,8 +188,8 @@ namespace Isis { } } return PvlKeyword(OutputName(nName), PvlTranslationTable::Translate(nName, "")); return PvlKeyword(OutputName(translationGroupName), PvlTranslationTable::Translate(translationGroupName, "")); } Loading Loading @@ -222,16 +233,20 @@ namespace Isis { /** * Returns the ith input value associated with the output name argument. * * @param nName The output name used to identify the input keyword. * @param translationGroupName The name of the PVL translation * group used to identify the * input/output keywords to be * translated. Often, this is the * same as the output keyword name. * * @param findex The index into the input keyword array. Defaults to 0 * * @throws IException::Programmer */ const PvlKeyword &PvlToPvlTranslationManager::InputKeyword(const QString nName) const { const PvlKeyword &PvlToPvlTranslationManager::InputKeyword(const QString translationGroupName) const { int instanceNumber = 0; PvlKeyword inputGroupKeyword = InputGroup(nName, instanceNumber); PvlKeyword inputGroupKeyword = InputGroup(translationGroupName, instanceNumber); bool anInputGroupFound = false; while(inputGroupKeyword.name() != "") { Loading @@ -239,31 +254,31 @@ namespace Isis { if(containingGroup != NULL) { anInputGroupFound = true; if(containingGroup->hasKeyword(InputKeywordName(nName))) { return containingGroup->findKeyword(InputKeywordName(nName)); if(containingGroup->hasKeyword(InputKeywordName(translationGroupName))) { return containingGroup->findKeyword(InputKeywordName(translationGroupName)); } } instanceNumber ++; inputGroupKeyword = InputGroup(nName, instanceNumber); inputGroupKeyword = InputGroup(translationGroupName, instanceNumber); } if(anInputGroupFound) { QString msg = "Unable to find input keyword [" + InputKeywordName(nName) + "] for output name [" + nName + "] in file [" + TranslationTable().fileName() + "]"; QString msg = "Unable to find input keyword [" + InputKeywordName(translationGroupName) + "] for output name [" + translationGroupName + "] in file [" + TranslationTable().fileName() + "]"; throw IException(IException::Programmer, msg, _FILEINFO_); } else { QString container = ""; for(int i = 0; i < InputGroup(nName).size(); i++) { for(int i = 0; i < InputGroup(translationGroupName).size(); i++) { if(i > 0) container += ","; container += InputGroup(nName)[i]; container += InputGroup(translationGroupName)[i]; } QString msg = "Unable to find input group [" + container + "] for output name [" + nName + "] in file [" + TranslationTable().fileName() + "]"; "] for output name [" + translationGroupName + "] in file [" + TranslationTable().fileName() + "]"; throw IException(IException::Programmer, msg, _FILEINFO_); } } Loading @@ -273,21 +288,25 @@ namespace Isis { * Indicates if the input keyword corresponding to the output name exists in * the label * * @param nName The output name used to identify the input keyword. * @param translationGroupName The name of the PVL translation * group used to identify the * input/output keywords to be * translated. Often, this is the * same as the output keyword name. */ bool PvlToPvlTranslationManager::InputHasKeyword(const QString nName) { bool PvlToPvlTranslationManager::InputHasKeyword(const QString translationGroupName) { // Set the current position in the input label pvl // by finding the input group corresponding to the output group const PvlContainer *con; int inst = 0; //while ((con = GetContainer(InputGroup(nName, inst++))) != NULL) { //if ((con = GetContainer (InputGroup(nName))) != NULL) { //while ((con = GetContainer(InputGroup(translationGroupName, inst++))) != NULL) { //if ((con = GetContainer (InputGroup(translationGroupName))) != NULL) { PvlKeyword grp; while((grp = InputGroup(nName, inst++)).name() != "") { while((grp = InputGroup(translationGroupName, inst++)).name() != "") { if((con = GetContainer(grp)) != NULL) { if(con->hasKeyword(InputKeywordName(nName))) return true; if(con->hasKeyword(InputKeywordName(translationGroupName))) return true; } } Loading Loading @@ -335,10 +354,17 @@ namespace Isis { /** * Create the requsted container and any containers above it and * return a reference to the container * list is an PvlKeyword with an array of container types an their names * return a reference to the container. List is a PvlKeyword * with an array of container types and their names. * * @param translationGroupName The name of the PVL translation * group used to identify the * input/output keywords to be * translated. Often, this is the * same as the output keyword name. * @param pvl Pvl */ PvlContainer *PvlToPvlTranslationManager::CreateContainer(const QString nName, Pvl &pvl) { return LabelTranslationManager::CreateContainer(nName, pvl); PvlContainer *PvlToPvlTranslationManager::CreateContainer(const QString translationGroupName, Pvl &pvl) { return LabelTranslationManager::CreateContainer(translationGroupName, pvl); } } // end namespace isis isis/src/base/objs/PvlToPvlTranslationManager/PvlToPvlTranslationManager.h +27 −31 Original line number Diff line number Diff line Loading @@ -44,42 +44,38 @@ namespace Isis { * @author 2003-05-29 Stuart Sides * * @internal * @history 2003-09-03 Stuart Sides - Modified to work with new isis label * format * @history 2003-09-25 Stuart Sides - Added the Translate member * @history 2005-02-15 Elizabeth Ribelin - Modified file to support Doxygen * documentation * @history 2006-08-09 Brendan George - Modified to support Optional keyword * translation * @history 2003-09-03 Stuart Sides - Modified to work with new isis label format. * @history 2003-09-25 Stuart Sides - Added the Translate member. * @history 2005-02-15 Elizabeth Ribelin - Modified file to support Doxygen documentation. * @history 2006-08-09 Brendan George - Modified to support Optional keyword translation. * @history 2006-10-01 Stuart Sides - Fixed bug with Optional keyword. * Non-optional keywords were being reported * instantly. * Non-optional keywords were being reported instantly. * @history 2006-11-16 Brendan George - Changed instances of "Foreign" to "Input" * and "Native" to "Output" * and "Native" to "Output". * @history 2007-06-22 Stuart Sides - Added ability to have more than one input location * keyword for a translation. The first one found * which contains the input keyword is used. * keyword for a translation. The first one found which contains * the input keyword is used. * @history 2008-05-09 Steven Lambright - Added ability to change input label without * re-reading the translation file. * @history 2008-07-10 Noah Hilt - Changed while loops to continue searching * other groups if a group has been found, but the keyword does not * exist in that group. * @history 2008-07-10 Steven Lambright - Changed to use new accessors * @history 2008-07-10 Noah Hilt - Changed while loops to continue searching other groups * if a group has been found, but the keyword does not exist in * that group. * @history 2008-07-10 Steven Lambright - Changed to use new accessors. * @history 2010-01-04 Steven Lambright - Added InputKeyword method and removed * InputSize, InputUnits, InputValue. * Renamed private Translate method to * DoTranslation to remove ambiguity * with a parent method, instead of * using a dummy parameter. * @history 2017-01-11 Jeannie Backer - Moved several methods to a generic * parent class, LabelTranslationManager. Fixes #4584. * InputSize, InputUnits, InputValue. Renamed private Translate() method * to DoTranslation() to remove ambiguity with a parent method, * instead of using a dummy parameter. * @history 2017-01-11 Jeannie Backer - Moved several methods to a generic parent class, * LabelTranslationManager. Fixes #4584. * @history 2017-06-13 Adam Paquette - Changed PvlTranslationManager file name to * PvlToPvlTranslationManager. Fixes #4901. * @history 2018-01-10 Christopher Combs - Changed ProcessDataFilePointer call to reflect * changes made to voy2isis. Fixes #4345, #4421. * @history 2018-04-16 Jeannie Backer - Fixed indentation of history comments and * brought code closer to coding standards. * @todo 2005-02-15 Stuart Sides - add coded example and implementation example * to class documentation, and finish * documentation * documentation. */ class PvlToPvlTranslationManager : public LabelTranslationManager { public: Loading @@ -97,24 +93,24 @@ namespace Isis { // Attempt to translate the requested output name to output value // using the input name and value/default value virtual QString Translate(QString nName, int findex = 0); virtual QString Translate(QString translationGroupName, int findex = 0); // Translate all translation table groups which contain "Auto" void Auto(Pvl &outputLabel); void Auto(Pvl &inputLabel, Pvl &outputLabel); // Return the ith input value associated with a output name virtual const PvlKeyword &InputKeyword(const QString nName) const; virtual const PvlKeyword &InputKeyword(const QString translationGroupName) const; // Return true if the input lable contains the translated group and key names virtual bool InputHasKeyword(const QString nName); virtual bool InputHasKeyword(const QString translationGroupName); void SetLabel(Pvl &inputLabel); protected: virtual PvlKeyword DoTranslation(const QString nName); virtual PvlKeyword DoTranslation(const QString translationGroupName); virtual const PvlContainer *GetContainer(const PvlKeyword &inputGroup) const; virtual PvlContainer *CreateContainer(const QString nName, Pvl &pvl); virtual PvlContainer *CreateContainer(const QString translationGroupName, Pvl &pvl); private: Pvl p_fLabel; //!< A Pvl object for the input label file }; Loading Loading
.gitignore +2 −1 Original line number Diff line number Diff line Loading @@ -27,10 +27,11 @@ object_script.*.Debug *_plugin_import.cpp *.moc ui_*.h *.html *html # ignore all files created by squish coco *csmes *csexe print.prt Loading
isis/src/base/objs/ProcessImport/ProcessImport.cpp +42 −60 Original line number Diff line number Diff line Loading @@ -1847,11 +1847,6 @@ namespace Isis { */ void ProcessImport::ProcessBip(void funct(Isis::Buffer &out)) { // Figure out the number of bytes to read for a single line int readBytes = Isis::SizeOf(p_pixelType); readBytes = readBytes * p_ns * p_nb; char *in = new char [readBytes]; // Set up an Isis::EndianSwapper object QString tok(Isis::ByteOrderName(p_byteOrder)); tok = tok.toUpper(); Loading Loading @@ -1902,6 +1897,11 @@ namespace Isis { p_progress->SetMaximumSteps(p_nl); p_progress->CheckStatus(); // Figure out the number of bytes to read for a single line int sampleBytes = Isis::SizeOf(p_pixelType) * p_nb + p_dataPreBytes + p_dataPostBytes; int readBytes = p_ns * sampleBytes; char *in = new char [readBytes]; // Loop for each line for(int line = 0; line < p_nl; line++) { // Check the last io Loading @@ -1915,16 +1915,6 @@ namespace Isis { // Space for storing prefix and suffix data pointers vector<char *> tempPre, tempPost; // Handle any line prefix bytes pos = fin.tellg(); if (p_saveDataPre) { tempPre.push_back(new char[p_dataPreBytes]); fin.read(tempPre.back(), p_dataPreBytes); } else { fin.seekg(p_dataPreBytes, ios_base::cur); } // Check the last io if (!fin.good()) { QString msg = "Cannot read file [" + p_inFile + "]. Position [" + Loading Loading @@ -1960,31 +1950,32 @@ namespace Isis { // to special pixels int osamp = 0; for(int samp = band; samp < p_ns * p_nb; samp += p_nb) { for(int samp = 0; samp < p_ns; samp++) { int bufferIndex = p_dataPreBytes + Isis::SizeOf(p_pixelType)*band + samp*sampleBytes; switch(p_pixelType) { case Isis::UnsignedByte: (*out)[osamp] = (double)((unsigned char *)in)[samp]; (*out)[osamp] = (double)((unsigned char *)in)[bufferIndex]; break; case Isis::UnsignedWord: (*out)[osamp] = (double)swapper.UnsignedShortInt((unsigned short int *)in+samp); (double)swapper.UnsignedShortInt(&in[bufferIndex]); break; case Isis::SignedWord: (*out)[osamp] = (double)swapper.ShortInt((short int *)in+samp); (*out)[osamp] = (double)swapper.ShortInt(&in[bufferIndex]); break; case Isis::SignedInteger: (*out)[samp] = (double)swapper.Int((int *)in+samp); (*out)[samp] = (double)swapper.Int(&in[bufferIndex]); break; case Isis::Real: if(p_vax_convert) { (*out)[osamp]= VAXConversion( (float *)in+samp ); (*out)[osamp]= VAXConversion(&in[bufferIndex]); } else { (*out)[osamp] = (double)swapper.Float((float *)in+samp); (*out)[osamp] = (double)swapper.Float(&in[bufferIndex]); } break; case Isis::Double: (*out)[osamp] = (double)swapper.Double((double *)in+samp); (*out)[osamp] = (double)swapper.Double(&in[bufferIndex]); break; default: break; Loading @@ -2008,33 +1999,25 @@ namespace Isis { funct(*out); } // Handle any line suffix bytes pos = fin.tellg(); if (p_saveDataPost) { tempPost.push_back(new char[p_dataPostBytes]); fin.read(tempPost.back(), p_dataPostBytes); } else { fin.seekg(p_dataPostBytes, ios_base::cur); } // Check the last io if (!fin.good()) { QString msg = "Cannot read file [" + p_inFile + "]. Position [" + toString((int)pos) + "]. Byte count [" + toString(p_dataPreBytes) + "]" ; throw IException(IException::Io, msg, _FILEINFO_); } } // End band loop // Save off the prefix bytes vector // Handle record prefix and suffix if (p_saveDataPre) { for(int samp = 0; samp < p_ns; samp++) { char *samplePrefix = new char[p_dataPreBytes]; memcpy(samplePrefix, &in[samp*sampleBytes], p_dataPreBytes); tempPre.push_back(samplePrefix); } p_dataPre.push_back(tempPre); tempPre.clear(); } // Save off the suffix bytes vector if (p_saveDataPost) { for(int samp = 0; samp < p_ns; samp++) { char *sampleSuffix = new char[p_dataPostBytes]; int suffixIndex = p_dataPreBytes + Isis::SizeOf(p_pixelType)*p_nb + samp*sampleBytes; memcpy(sampleSuffix, &in[suffixIndex], p_dataPostBytes); tempPost.push_back(sampleSuffix); } p_dataPost.push_back(tempPost); tempPost.clear(); } Loading @@ -2043,12 +2026,11 @@ namespace Isis { if (!fin.good()) { QString msg = "Cannot read file [" + p_inFile + "]. Position [" + toString((int)pos) + "]. Byte count [" + toString(p_fileHeaderBytes) + "]" ; toString(p_dataPreBytes) + "]" ; throw IException(IException::Io, msg, _FILEINFO_); } } // End band loop // Handle the data trailer pos = fin.tellg(); if (p_saveDataTrailer) { p_dataTrailer.push_back(new char[p_dataTrailerBytes]); Loading
isis/src/base/objs/ProcessImport/ProcessImport.h +13 −2 Original line number Diff line number Diff line Loading @@ -152,6 +152,17 @@ namespace Isis { * @history 2017-05-29 Kristin Berry - Added support for data trailers in BIP files and fixed * a typo so that DataTrailerBytes() will return the correct value. * References #3888. * @history 2018-05-01 Jesse Mapel - Changed data suffix and prefix in BIP files. Previously, * data suffixes and prefixes were for each band before/after each line. * Now, data suffixes and prefixes are before/after each sample. For a * RGB, 3-band image with n samples a line of data was previously * | Header | R prefix | G prefix | B prefix | R 1 | G 1 | B 1| ... * | R n | G n | B n| R suffix | G suffix | B suffix | Trailer |. Now * it is | Header | Prefix 1 | R 1 | G 1 | B 1 | Suffix 1 | ... * | Prefix n | R n | G n | B n | Suffix n | Trailer |. This change * was made to accomodate Rosetta VIRTIS-m calibrated data files and * has no impact on other supported BIP files. * Fixes #5398. * */ class ProcessImport : public Isis::Process { Loading
isis/src/base/objs/PvlToPvlTranslationManager/PvlToPvlTranslationManager.cpp +77 −51 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ namespace Isis { * set the input label before translating. This may be done by using * SetLabel(Pvl inputLabel) or Auto(Pvl inputLabel, Pvl outputLabel). * * @param transFile The translation file to be used to tranlate keywords in * @param transFile The translation file to be used to translate keywords in * the input label. */ PvlToPvlTranslationManager::PvlToPvlTranslationManager(const QString &transFile) Loading @@ -53,8 +53,8 @@ namespace Isis { * input label before translating. This may be done by using SetLabel(Pvl * inputLabel) or Auto(Pvl inputLabel, Pvl outputLabel). * * @param transStrm A stream containing the tranlation table to be used to * tranlate keywords in the input label. * @param transStrm A stream containing the translation table to be used to * translate keywords in the input label. */ PvlToPvlTranslationManager::PvlToPvlTranslationManager(std::istream &transStrm) : LabelTranslationManager(transStrm) { Loading @@ -66,7 +66,7 @@ namespace Isis { * * @param inputLabel The Pvl holding the input label. * * @param transFile The translation file to be used to tranlate keywords in * @param transFile The translation file to be used to translate keywords in * the input label. */ PvlToPvlTranslationManager::PvlToPvlTranslationManager(Pvl &inputLabel, Loading @@ -81,8 +81,8 @@ namespace Isis { * * @param inputLabel The Pvl holding the input label. * * @param transStrm A stream containing the tranlation table to be used to * tranlate keywords in the input label. * @param transStrm A stream containing the translation table to be used to * translate keywords in the input label. */ PvlToPvlTranslationManager::PvlToPvlTranslationManager(Pvl &inputLabel, std::istream &transStrm) Loading @@ -103,47 +103,58 @@ namespace Isis { /** * Returns a translated value. The output name is used to find the input * group, keyword, default and tranlations in the translation table. If the * keyword does not exist in the input label, the input default if * available will be used as the input value. This input value * is then used to search all of the translations. If a match is * found the translated value is returned. * group, keyword, default and translations in the translation table. If the * keyword does not exist in the input label and an input default is available, * then this default will be used as the input value. This input value is * then used to search all of the translations. If a match is found the * translated value is returned. * * @param nName The output name used to identify the input keyword to be * translated. * @param translationGroupName The name of the PVL translation * group used to identify the * input/output keywords to be * translated. Often, this is the * same as the output keyword name. * * @param findex The index into the input keyword array. Defaults to 0 * * @return string */ QString PvlToPvlTranslationManager::Translate(QString nName, int findex) { QString PvlToPvlTranslationManager::Translate(QString translationGroupName, int findex) { const PvlContainer *con; int inst = 0; PvlKeyword grp; while((grp = InputGroup(nName, inst++)).name() != "") { while((grp = InputGroup(translationGroupName, inst++)).name() != "") { if((con = GetContainer(grp)) != NULL) { if(con->hasKeyword(InputKeywordName(nName))) { return PvlTranslationTable::Translate(nName, (*con)[InputKeywordName(nName)][findex]); if(con->hasKeyword(InputKeywordName(translationGroupName))) { return PvlTranslationTable::Translate(translationGroupName, (*con)[InputKeywordName(translationGroupName)][findex]); } } } return PvlTranslationTable::Translate(nName); return PvlTranslationTable::Translate(translationGroupName); } /** * Translate the requested output name to output values using the input name * and values or default value * and values or default value. * * @param nName The output name used to identify the input keyword to be * translated. * Note: This is a protected method used when automatically * translating * * @see Auto(). * * @param translationGroupName The name of the PVL translation * group used to identify the * input/output keywords to be * translated. Often, this is the * same as the output keyword name. * * @return PvlKeyword */ PvlKeyword PvlToPvlTranslationManager::DoTranslation(const QString nName) { PvlKeyword PvlToPvlTranslationManager::DoTranslation(const QString translationGroupName) { const PvlContainer *con = NULL; PvlKeyword key; Loading @@ -151,9 +162,9 @@ namespace Isis { PvlGroup transGroup; PvlKeyword grp; while((grp = InputGroup(nName, inst++)).name() != "") { while((grp = InputGroup(translationGroupName, inst++)).name() != "") { if((con = GetContainer(grp)) != NULL) { transGroup = TranslationTable().findGroup(nName); transGroup = TranslationTable().findGroup(translationGroupName); Pvl::ConstPvlKeywordIterator it = transGroup.findKeyword("InputKey", transGroup.begin(), transGroup.end()); Loading @@ -162,10 +173,10 @@ namespace Isis { while(it != transGroup.end()) { const PvlKeyword &result = *it; if(con->hasKeyword(result[0])) { key.setName(OutputName(nName)); key.setName(OutputName(translationGroupName)); for(int v = 0; v < (*con)[(result[0])].size(); v++) { key.addValue(PvlTranslationTable::Translate(nName, key.addValue(PvlTranslationTable::Translate(translationGroupName, (*con)[result[0]][v]), (*con)[result[0]].unit(v)); } Loading @@ -177,8 +188,8 @@ namespace Isis { } } return PvlKeyword(OutputName(nName), PvlTranslationTable::Translate(nName, "")); return PvlKeyword(OutputName(translationGroupName), PvlTranslationTable::Translate(translationGroupName, "")); } Loading Loading @@ -222,16 +233,20 @@ namespace Isis { /** * Returns the ith input value associated with the output name argument. * * @param nName The output name used to identify the input keyword. * @param translationGroupName The name of the PVL translation * group used to identify the * input/output keywords to be * translated. Often, this is the * same as the output keyword name. * * @param findex The index into the input keyword array. Defaults to 0 * * @throws IException::Programmer */ const PvlKeyword &PvlToPvlTranslationManager::InputKeyword(const QString nName) const { const PvlKeyword &PvlToPvlTranslationManager::InputKeyword(const QString translationGroupName) const { int instanceNumber = 0; PvlKeyword inputGroupKeyword = InputGroup(nName, instanceNumber); PvlKeyword inputGroupKeyword = InputGroup(translationGroupName, instanceNumber); bool anInputGroupFound = false; while(inputGroupKeyword.name() != "") { Loading @@ -239,31 +254,31 @@ namespace Isis { if(containingGroup != NULL) { anInputGroupFound = true; if(containingGroup->hasKeyword(InputKeywordName(nName))) { return containingGroup->findKeyword(InputKeywordName(nName)); if(containingGroup->hasKeyword(InputKeywordName(translationGroupName))) { return containingGroup->findKeyword(InputKeywordName(translationGroupName)); } } instanceNumber ++; inputGroupKeyword = InputGroup(nName, instanceNumber); inputGroupKeyword = InputGroup(translationGroupName, instanceNumber); } if(anInputGroupFound) { QString msg = "Unable to find input keyword [" + InputKeywordName(nName) + "] for output name [" + nName + "] in file [" + TranslationTable().fileName() + "]"; QString msg = "Unable to find input keyword [" + InputKeywordName(translationGroupName) + "] for output name [" + translationGroupName + "] in file [" + TranslationTable().fileName() + "]"; throw IException(IException::Programmer, msg, _FILEINFO_); } else { QString container = ""; for(int i = 0; i < InputGroup(nName).size(); i++) { for(int i = 0; i < InputGroup(translationGroupName).size(); i++) { if(i > 0) container += ","; container += InputGroup(nName)[i]; container += InputGroup(translationGroupName)[i]; } QString msg = "Unable to find input group [" + container + "] for output name [" + nName + "] in file [" + TranslationTable().fileName() + "]"; "] for output name [" + translationGroupName + "] in file [" + TranslationTable().fileName() + "]"; throw IException(IException::Programmer, msg, _FILEINFO_); } } Loading @@ -273,21 +288,25 @@ namespace Isis { * Indicates if the input keyword corresponding to the output name exists in * the label * * @param nName The output name used to identify the input keyword. * @param translationGroupName The name of the PVL translation * group used to identify the * input/output keywords to be * translated. Often, this is the * same as the output keyword name. */ bool PvlToPvlTranslationManager::InputHasKeyword(const QString nName) { bool PvlToPvlTranslationManager::InputHasKeyword(const QString translationGroupName) { // Set the current position in the input label pvl // by finding the input group corresponding to the output group const PvlContainer *con; int inst = 0; //while ((con = GetContainer(InputGroup(nName, inst++))) != NULL) { //if ((con = GetContainer (InputGroup(nName))) != NULL) { //while ((con = GetContainer(InputGroup(translationGroupName, inst++))) != NULL) { //if ((con = GetContainer (InputGroup(translationGroupName))) != NULL) { PvlKeyword grp; while((grp = InputGroup(nName, inst++)).name() != "") { while((grp = InputGroup(translationGroupName, inst++)).name() != "") { if((con = GetContainer(grp)) != NULL) { if(con->hasKeyword(InputKeywordName(nName))) return true; if(con->hasKeyword(InputKeywordName(translationGroupName))) return true; } } Loading Loading @@ -335,10 +354,17 @@ namespace Isis { /** * Create the requsted container and any containers above it and * return a reference to the container * list is an PvlKeyword with an array of container types an their names * return a reference to the container. List is a PvlKeyword * with an array of container types and their names. * * @param translationGroupName The name of the PVL translation * group used to identify the * input/output keywords to be * translated. Often, this is the * same as the output keyword name. * @param pvl Pvl */ PvlContainer *PvlToPvlTranslationManager::CreateContainer(const QString nName, Pvl &pvl) { return LabelTranslationManager::CreateContainer(nName, pvl); PvlContainer *PvlToPvlTranslationManager::CreateContainer(const QString translationGroupName, Pvl &pvl) { return LabelTranslationManager::CreateContainer(translationGroupName, pvl); } } // end namespace isis
isis/src/base/objs/PvlToPvlTranslationManager/PvlToPvlTranslationManager.h +27 −31 Original line number Diff line number Diff line Loading @@ -44,42 +44,38 @@ namespace Isis { * @author 2003-05-29 Stuart Sides * * @internal * @history 2003-09-03 Stuart Sides - Modified to work with new isis label * format * @history 2003-09-25 Stuart Sides - Added the Translate member * @history 2005-02-15 Elizabeth Ribelin - Modified file to support Doxygen * documentation * @history 2006-08-09 Brendan George - Modified to support Optional keyword * translation * @history 2003-09-03 Stuart Sides - Modified to work with new isis label format. * @history 2003-09-25 Stuart Sides - Added the Translate member. * @history 2005-02-15 Elizabeth Ribelin - Modified file to support Doxygen documentation. * @history 2006-08-09 Brendan George - Modified to support Optional keyword translation. * @history 2006-10-01 Stuart Sides - Fixed bug with Optional keyword. * Non-optional keywords were being reported * instantly. * Non-optional keywords were being reported instantly. * @history 2006-11-16 Brendan George - Changed instances of "Foreign" to "Input" * and "Native" to "Output" * and "Native" to "Output". * @history 2007-06-22 Stuart Sides - Added ability to have more than one input location * keyword for a translation. The first one found * which contains the input keyword is used. * keyword for a translation. The first one found which contains * the input keyword is used. * @history 2008-05-09 Steven Lambright - Added ability to change input label without * re-reading the translation file. * @history 2008-07-10 Noah Hilt - Changed while loops to continue searching * other groups if a group has been found, but the keyword does not * exist in that group. * @history 2008-07-10 Steven Lambright - Changed to use new accessors * @history 2008-07-10 Noah Hilt - Changed while loops to continue searching other groups * if a group has been found, but the keyword does not exist in * that group. * @history 2008-07-10 Steven Lambright - Changed to use new accessors. * @history 2010-01-04 Steven Lambright - Added InputKeyword method and removed * InputSize, InputUnits, InputValue. * Renamed private Translate method to * DoTranslation to remove ambiguity * with a parent method, instead of * using a dummy parameter. * @history 2017-01-11 Jeannie Backer - Moved several methods to a generic * parent class, LabelTranslationManager. Fixes #4584. * InputSize, InputUnits, InputValue. Renamed private Translate() method * to DoTranslation() to remove ambiguity with a parent method, * instead of using a dummy parameter. * @history 2017-01-11 Jeannie Backer - Moved several methods to a generic parent class, * LabelTranslationManager. Fixes #4584. * @history 2017-06-13 Adam Paquette - Changed PvlTranslationManager file name to * PvlToPvlTranslationManager. Fixes #4901. * @history 2018-01-10 Christopher Combs - Changed ProcessDataFilePointer call to reflect * changes made to voy2isis. Fixes #4345, #4421. * @history 2018-04-16 Jeannie Backer - Fixed indentation of history comments and * brought code closer to coding standards. * @todo 2005-02-15 Stuart Sides - add coded example and implementation example * to class documentation, and finish * documentation * documentation. */ class PvlToPvlTranslationManager : public LabelTranslationManager { public: Loading @@ -97,24 +93,24 @@ namespace Isis { // Attempt to translate the requested output name to output value // using the input name and value/default value virtual QString Translate(QString nName, int findex = 0); virtual QString Translate(QString translationGroupName, int findex = 0); // Translate all translation table groups which contain "Auto" void Auto(Pvl &outputLabel); void Auto(Pvl &inputLabel, Pvl &outputLabel); // Return the ith input value associated with a output name virtual const PvlKeyword &InputKeyword(const QString nName) const; virtual const PvlKeyword &InputKeyword(const QString translationGroupName) const; // Return true if the input lable contains the translated group and key names virtual bool InputHasKeyword(const QString nName); virtual bool InputHasKeyword(const QString translationGroupName); void SetLabel(Pvl &inputLabel); protected: virtual PvlKeyword DoTranslation(const QString nName); virtual PvlKeyword DoTranslation(const QString translationGroupName); virtual const PvlContainer *GetContainer(const PvlKeyword &inputGroup) const; virtual PvlContainer *CreateContainer(const QString nName, Pvl &pvl); virtual PvlContainer *CreateContainer(const QString translationGroupName, Pvl &pvl); private: Pvl p_fLabel; //!< A Pvl object for the input label file }; Loading