Skip to content

Commit abe3e9b

Browse files
committed
Update pds2hideal to update the table labels before adding them to the Cube
1 parent 43968bf commit abe3e9b

1 file changed

Lines changed: 38 additions & 82 deletions

File tree

isis/src/mro/apps/pds2hideal/main.cpp

Lines changed: 38 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ find files of those names at the top level of this repository. **/
1515
#include "FileName.h"
1616
#include "ProcessImportPds.h"
1717
#include "Pvl.h"
18+
#include "PvlContainer.h"
1819
#include "PvlKeyword.h"
1920
#include "PvlGroup.h"
21+
#include "Table.h"
2022
#include "UserInterface.h"
2123

2224
using namespace Isis;
2325
using namespace std;
2426

25-
void addTableKeywords(Pvl *isisLabel, Pvl pdsLabelPvl);
27+
void addTableKeywords(PvlObject &tableLabel, PvlObject pdsTableLabel);
2628

2729
void IsisMain() {
2830
// Get user interface
@@ -48,10 +50,18 @@ void IsisMain() {
4850
// translate the band bin and archive groups to this pvl
4951
p.TranslatePdsLabels(otherGroups);
5052

51-
p.ImportTable("INSTRUMENT_POINTING_TABLE");
52-
p.ImportTable("INSTRUMENT_POSITION_TABLE");
53-
p.ImportTable("SUN_POSITION_TABLE");
54-
p.ImportTable("BODY_ROTATION_TABLE");
53+
// Import the requested tables
54+
std::vector<QString> tables = {"INSTRUMENT_POINTING_TABLE",
55+
"INSTRUMENT_POSITION_TABLE",
56+
"SUN_POSITION_TABLE",
57+
"BODY_ROTATION_TABLE"};
58+
for (QString table : tables) {
59+
Table &instrumentPointingTable = p.ImportTable(table);
60+
PvlObject &isisTableLabel = instrumentPointingTable.Label();
61+
PvlObject pdsTableLabel = pdsLabelPvl.findObject(table);
62+
addTableKeywords(isisTableLabel, pdsTableLabel);
63+
}
64+
5565
p.StartProcess();
5666

5767
// add translated values from band bin and archive groups to the output cube
@@ -112,88 +122,34 @@ void IsisMain() {
112122
isisCubeObject += alphaCube;
113123
}
114124

115-
addTableKeywords(isisLabel, pdsLabelPvl);
125+
// addTableKeywords(isisLabel, pdsLabelPvl);
116126
p.EndProcess();
117127
}
118128

119129
/**
120-
* This method will add the appropriate keywords from the TABLE objects of the
121-
* input labels to the Table objects in output Isis labels.
130+
* This method will add the appropriate keywords from the TABLE object of the
131+
* input labels to the Table object in output Isis labels.
122132
*
123-
* @param isisLabel Pointer to the output file's label
124-
* @param pdsLabelPvl A Pvl containing the input pds file's label.
133+
* @param tableLabel Reference to the output file's table label
134+
* @param pdsTableLabel A PvlObject containing the input pds file's table label.
125135
*
126136
*/
127-
void addTableKeywords(Pvl *isisLabel, Pvl pdsLabelPvl) {
128-
// add keywords to appropriate tables
129-
for (int i = 0; i < isisLabel->objects(); i++) {
130-
if (isisLabel->object(i).name() == "Table") {
131-
PvlKeyword keyword;
132-
if (QString(isisLabel->object(i)["Name"]) == "InstrumentPointing") {
133-
keyword = pdsLabelPvl.findObject("INSTRUMENT_POINTING_TABLE")["TIME_DEPENDENT_FRAMES"];
134-
keyword.setName("TimeDependentFrames");
135-
isisLabel->object(i) += keyword;
136-
keyword = pdsLabelPvl.findObject("INSTRUMENT_POINTING_TABLE")["CONSTANT_FRAMES"];
137-
keyword.setName("ConstantFrames");
138-
isisLabel->object(i) += keyword;
139-
keyword = pdsLabelPvl.findObject("INSTRUMENT_POINTING_TABLE")["CONSTANT_ROTATION"];
140-
keyword.setName("ConstantRotation");
141-
isisLabel->object(i) += keyword;
142-
keyword = pdsLabelPvl.findObject("INSTRUMENT_POINTING_TABLE")["CK_TABLE_START_TIME"];
143-
keyword.setName("CkTableStartTime");
144-
isisLabel->object(i) += keyword;
145-
keyword = pdsLabelPvl.findObject("INSTRUMENT_POINTING_TABLE")["CK_TABLE_END_TIME"];
146-
keyword.setName("CkTableEndTime");
147-
isisLabel->object(i) += keyword;
148-
keyword = pdsLabelPvl.findObject("INSTRUMENT_POINTING_TABLE")["CK_TABLE_ORIGINAL_SIZE"];
149-
keyword.setName("CkTableOriginalSize");
150-
isisLabel->object(i) += keyword;
151-
}
152-
if (QString(isisLabel->object(i)["Name"]) == "InstrumentPosition") {
153-
keyword = pdsLabelPvl.findObject("INSTRUMENT_POSITION_TABLE")["CACHE_TYPE"];
154-
keyword.setName("CacheType");
155-
isisLabel->object(i) += keyword;
156-
keyword = pdsLabelPvl.findObject("INSTRUMENT_POSITION_TABLE")["SPK_TABLE_START_TIME"];
157-
keyword.setName("SpkTableStartTime");
158-
isisLabel->object(i) += keyword;
159-
keyword = pdsLabelPvl.findObject("INSTRUMENT_POSITION_TABLE")["SPK_TABLE_END_TIME"];
160-
keyword.setName("SpkTableEndTime");
161-
isisLabel->object(i) += keyword;
162-
keyword = pdsLabelPvl.findObject("INSTRUMENT_POSITION_TABLE")["SPK_TABLE_ORIGINAL_SIZE"];
163-
keyword.setName("SpkTableOriginalSize");
164-
isisLabel->object(i) += keyword;
165-
}
166-
if (QString(isisLabel->object(i)["Name"]) == "BodyRotation") {
167-
keyword = pdsLabelPvl.findObject("BODY_ROTATION_TABLE")["TIME_DEPENDENT_FRAMES"];
168-
keyword.setName("TimeDependentFrames");
169-
isisLabel->object(i) += keyword;
170-
keyword = pdsLabelPvl.findObject("BODY_ROTATION_TABLE")["CK_TABLE_START_TIME"];
171-
keyword.setName("CkTableStartTime");
172-
isisLabel->object(i) += keyword;
173-
keyword = pdsLabelPvl.findObject("BODY_ROTATION_TABLE")["CK_TABLE_END_TIME"];
174-
keyword.setName("CkTableEndTime");
175-
isisLabel->object(i) += keyword;
176-
keyword = pdsLabelPvl.findObject("BODY_ROTATION_TABLE")["CK_TABLE_ORIGINAL_SIZE"];
177-
keyword.setName("CkTableOriginalSize");
178-
isisLabel->object(i) += keyword;
179-
keyword = pdsLabelPvl.findObject("BODY_ROTATION_TABLE")["SOLAR_LONGITUDE"];
180-
keyword.setName("SolarLongitude");
181-
isisLabel->object(i) += keyword;
182-
}
183-
if (QString(isisLabel->object(i)["Name"]) == "SunPosition") {
184-
keyword = pdsLabelPvl.findObject("SUN_POSITION_TABLE")["CACHE_TYPE"];
185-
keyword.setName("CacheType");
186-
isisLabel->object(i) += keyword;
187-
keyword = pdsLabelPvl.findObject("SUN_POSITION_TABLE")["SPK_TABLE_START_TIME"];
188-
keyword.setName("SpkTableStartTime");
189-
isisLabel->object(i) += keyword;
190-
keyword = pdsLabelPvl.findObject("SUN_POSITION_TABLE")["SPK_TABLE_END_TIME"];
191-
keyword.setName("SpkTableEndTime");
192-
isisLabel->object(i) += keyword;
193-
keyword = pdsLabelPvl.findObject("SUN_POSITION_TABLE")["SPK_TABLE_ORIGINAL_SIZE"];
194-
keyword.setName("SpkTableOriginalSize");
195-
isisLabel->object(i) += keyword;
196-
}
197-
}
198-
}
137+
void addTableKeywords(PvlObject &tableLabel, PvlObject pdsTableLabel) {
138+
QStringList ingnoredKeywords = {"INTERCHANGE_FORMAT", "ROWS", "COLUMNS", "ROW_BYTES", "ROW_SUFFIX_BYTES"};
139+
for (PvlContainer::ConstPvlKeywordIterator keywordIt = pdsTableLabel.begin(); keywordIt != pdsTableLabel.end(); keywordIt++) {
140+
if (ingnoredKeywords.contains(keywordIt->name())) {
141+
continue;
142+
}
143+
PvlKeyword newKeyword(*keywordIt);
144+
QString keywordName = newKeyword.name();
145+
146+
QString upperCamelCaseName;
147+
QStringList parts = keywordName.split('_', Qt::SkipEmptyParts);
148+
for (QString part : parts) {
149+
upperCamelCaseName += part.at(0).toUpper() + part.mid(1).toLower();
150+
}
151+
152+
newKeyword.setName(upperCamelCaseName);
153+
tableLabel += newKeyword;
154+
}
199155
}

0 commit comments

Comments
 (0)