Isis 3.0 Programmer Reference
Back | Home
ImportPdsTable.cpp
Go to the documentation of this file.
1 
22 #include "ImportPdsTable.h"
23 
24 #include <cctype>
25 #include <iomanip>
26 #include <iostream>
27 #include <sstream>
28 
29 #include <QDebug>
30 #include <QScopedPointer>
31 #include <QString>
32 
33 #include "EndianSwapper.h"
34 #include "FileName.h"
35 #include "IString.h"
36 #include "Pvl.h"
37 #include "PvlObject.h"
38 #include "Table.h"
39 #include "TableField.h"
40 #include "TableRecord.h"
41 #include "TextFile.h"
42 
43 
44 using namespace std;
45 
46 namespace Isis {
47 
48 
58  ImportPdsTable::ImportPdsTable() {
59  // just inititalize the member variables
60  init();
61  m_tableName = "TABLE";
62  }
63 
64 
88  ImportPdsTable::ImportPdsTable(const QString &pdsLabFile,
89  const QString &pdsTableFile,
90  const QString &pdsTableName) {
91  m_tableName = pdsTableName;
92  load(pdsLabFile, pdsTableFile, pdsTableName);
93  }
94 
95 
99  ImportPdsTable::~ImportPdsTable() {
100  }
101 
102 
104  QString ImportPdsTable::name() const {
105  return (m_tableName);
106  }
107 
113  void ImportPdsTable::setName(const QString &name) {
114  m_tableName = name;
115  return;
116  }
117 
118 
147  void ImportPdsTable::load(const QString &pdsLabFile,
148  const QString &pdsTableFile,
149  const QString &pdsTableName) {
150 
151  init();
152  QString tempTblFile;
153  loadLabel(pdsLabFile, tempTblFile, pdsTableName);
154  if (!pdsTableFile.isEmpty()) tempTblFile = pdsTableFile;
155  // Vet the table filename. Many PDS files record the filename in
156  // uppercase and in practice, the filename is in lowercase. Do this
157  // check here.
158  FileName tableFile(tempTblFile);
159  try {
160  int tableStartRecord = toInt(tableFile.baseName());
161  tempTblFile = pdsLabFile;
162  m_pdsTableStart = tableStartRecord;
163  }
164  catch (IException &e) {
165  // if we are unable to cast the table file value to an integer, it must be a
166  // file name, not a location in the label file.
167  if (!tableFile.fileExists()) {
168  // if the table file name doesn't exist, try lowercased version...
169  FileName tableFileLowercase(tableFile.path() + "/"
170  + tableFile.name().toLower());
171  if (!tableFileLowercase.fileExists()) {
172  IString msg = "Unable to import PDS table. Neither of the following "
173  "possible table files were found: ["
174  + tableFile.expanded() + "] or ["
175  + tableFileLowercase.expanded() + "]";
176  throw IException(e, IException::Unknown, msg, _FILEINFO_);
177  }
178  tableFile = tableFileLowercase.expanded();
179  tempTblFile = tableFile.expanded();
180  }
181  m_pdsTableStart = 1;
182  }
183  if (m_pdsTableType == "ASCII") {
184  loadTable(tempTblFile);
185  }
186  m_pdsTableFile = tempTblFile;
187  return;
188  }
189 
190 
201  bool ImportPdsTable::hasColumn(const QString &colName) const {
202  return (findColumn(colName) != 0);
203  }
204 
205 
226  QString ImportPdsTable::getColumnName(const unsigned int &index,
227  const bool &formatted) const {
228  if ((int) index >= columns() - 1) {
229  QString msg = "Unable to import the binary PDS table [" + m_tableName
230  + "] into Isis. The requested column index ["
231  + toString((int) index) + "] exceeds the last column index ["
232  + toString(columns() - 1) + "]";
233  throw IException(IException::Programmer, msg.toStdString(), _FILEINFO_);
234  }
235  QString name = m_coldesc[index].m_name;
236  if (formatted) name = getFormattedName(name);
237  return (name);
238  }
239 
240 
257  QStringList ImportPdsTable::getColumnNames(const bool &formatted) const {
258  QStringList colnames;
259  for (int i = 0 ; i < columns() ; i++) {
260  QString name = m_coldesc[i].m_name;
261  if (formatted) name = getFormattedName(name);
262  colnames.push_back(name);
263  }
264  return (colnames);
265  }
266 
267 
283  QString ImportPdsTable::getType(const QString &colName) const {
284  const ColumnDescr *column = findColumn(colName);
285  QString dtype("");
286  if (column != 0) {
287  dtype = column->m_dataType;
288  }
289  return (dtype);
290  }
291 
292 
310  bool ImportPdsTable::setType(const QString &colName,
311  const QString &dataType) {
312  ColumnDescr *column = findColumn(colName);
313  if (column != 0) {
314  column->m_dataType = dataType.toUpper();
315  }
316  return (column != 0);
317  }
318 
319 
333  Table ImportPdsTable::importTable(const QString &isisTableName) {
334  try {
335  TableRecord record = makeRecord(m_coldesc);
336  Table table(isisTableName, record);
337  fillTable(table, m_coldesc, record);
338  return (table);
339  }
340  catch (IException &e) {
341  QString msg = "Unable to import the PDS table [" + m_tableName
342  + "] from the PDS file [" + m_pdsTableFile + "] into Isis.";
343  throw IException(e, IException::Unknown, msg.toStdString(), _FILEINFO_);
344 
345  }
346  }
347 
348 
365  Table ImportPdsTable::importTable(const QString &colnames,
366  const QString &isisTableName) {
367  return (importTable(colnames.split(","), isisTableName));
368  }
369 
370 
388  Table ImportPdsTable::importTable(const QStringList &colnames,
389  const QString &isisTableName) {
390  ColumnTypes ctypes;
391  for (int i = 0 ; i < colnames.size() ; i++) {
392  const ColumnDescr *descr = findColumn(colnames[i]);
393  if (!descr) {
394  QString msg = "Unable to import the PDS table [" + m_tableName
395  + "] into Isis. The requested column name ["
396  + colnames[i] + "] does not "
397  "exist in table.";
398  throw IException(IException::Programmer, msg.toStdString(), _FILEINFO_);
399  }
400  ctypes.push_back(*descr);
401  }
402 
403  // Create and populate the table
404  TableRecord record = makeRecord(ctypes);
405  Table table(isisTableName, record);
406  fillTable(table, ctypes, record);
407  return (table);
408  }
409 
410 
416  void ImportPdsTable::init() {
417 
418  m_byteOrder = "";
419  m_trows = 0;
420  m_pdsTableStart = 0;
421  m_coldesc.clear();
422  m_rows.clear();
423  m_pdsTableType = "";
424  m_pdsTableFile = "";
425  return;
426  }
427 
428 
453  void ImportPdsTable::loadLabel(const QString &pdsLabFile,
454  QString &pdsTableFile,
455  const QString &tblname) {
456 
457  Isis::Pvl label(pdsLabFile);
458 
459  QString tableName = ( tblname.isEmpty() ) ? m_tableName : tblname;
460  if (!label.hasObject(tableName)) {
461  QString msg = "The PDS file " + pdsLabFile +
462  " does not have the required TABLE object, ["
463  + tableName +"]. The PDS label file is probably invalid";
464  throw IException(IException::Unknown, msg.toStdString(), _FILEINFO_);
465  }
466  // Get some pertinent information from the label
467  PvlObject &tabObj = label.findObject(tableName);
468  if (tabObj.hasKeyword("RECORD_BYTES")) {
469  m_recordBytes = (int) tabObj.findKeyword("RECORD_BYTES");
470  }
471  else {
472  m_recordBytes = (int) label.findKeyword("RECORD_BYTES");
473  }
474 
475  QString trueTableName;
476  PvlObject *tableDetails = &tabObj;
477  if (label.hasKeyword("^" + tableName)) {
478  trueTableName = tableName;
479  pdsTableFile = FileName(pdsLabFile).path() + "/"
480  + label["^" + tableName][0];
481  }
482  else if (tabObj.objects() == 1) {
483  trueTableName = tabObj.object(0).name();
484  tableDetails = &tabObj.object(0);
485  pdsTableFile = FileName(pdsLabFile).path() + "/"
486  + tabObj["^" + trueTableName][0];
487  }
488  m_trows = (int) tableDetails->findKeyword("ROWS");
489  int ncols = (int) tableDetails->findKeyword("COLUMNS");
490  m_pdsTableType = QString(tableDetails->findKeyword("INTERCHANGE_FORMAT"));
491  if (m_pdsTableType != "ASCII" && m_pdsTableType.toUpper() != "BINARY") {
492  QString msg = "Unable to import the PDS table [" + tableName
493  + "] from the PDS file ["
494  + pdsTableFile + "] into Isis. "
495  "The PDS INTERCHANGE_FORMAT [" + m_pdsTableType
496  + "] is not supported. Valid values are ASCII or BINARY.";
497  throw IException(IException::User, msg.toStdString(), _FILEINFO_);
498  }
499  m_rowBytes = tableDetails->findKeyword("ROW_BYTES");
500 
501  m_coldesc.clear();
502  PvlObject::PvlObjectIterator colobj = tableDetails->beginObject();
503  int icol(0);
504  while (colobj != tableDetails->endObject()) {
505  if (colobj->isNamed("COLUMN")) {
506  m_coldesc.push_back(getColumnDescription(*colobj, icol));
507  icol++;
508  }
509  ++colobj;
510  }
511 
512  // Test to ensure columns match the number listed in the label
513  if (ncols != columns()) {
514  ostringstream msg;
515  msg << "Number of columns in the COLUMNS label keyword (" << ncols
516  << ") does not match number of COLUMN objects found ("
517  << columns() << ")";
518  cout << msg.str() << endl;
519  }
520  return;
521  }
522 
523 
540  void ImportPdsTable::loadTable(const QString &pdsTableFile) {
541 
542  // Vet the filename. Many PDS files record the filename in uppercase and
543  // in practice, the filename is in lowercase. Do this check here.
544  QString tempTblFile(pdsTableFile);
545  TextFile tfile(tempTblFile);
546  QString tline;
547  m_rows.clear();
548  int irow(0);
549  while (tfile.GetLine(tline, false)) {
550  if (irow >= m_trows) break;
551 
552  (void) processRow(irow, tline);
553 
554  irow++;
555  }
556  return;
557  }
558 
559 
578  ImportPdsTable::getColumnDescription(PvlObject &colobj, int nth) const {
579  ColumnDescr cd;
580  cd.m_name = colobj["NAME"][0];
581  cd.m_colnum = nth; // 0-based indexing, will be COLUMN_NUM - 1
582 
583  if (m_pdsTableType == "ASCII") {
584  cd.m_dataType = getGenericType(colobj["DATA_TYPE"][0]).toUpper();
585  }
586  else {
587  cd.m_dataType = colobj["DATA_TYPE"][0].toUpper();
588  }
589 
590  cd.m_startByte = ((int) colobj["START_BYTE"]) - 1; // 0-based indexing
591  cd.m_numBytes = (int) colobj["BYTES"];
592 
593 
594  cd.m_itemBytes = cd.m_numBytes;
595  if ( colobj.hasKeyword("ITEM_BYTES") ) {
596  cd.m_itemBytes = (int) colobj["ITEM_BYTES"];
597  }
598 
599  cd.m_items = 1;
600  if ( colobj.hasKeyword("ITEMS") ) {
601  cd.m_items = (int) colobj["ITEMS"];
602  }
603 
604  return (cd);
605  }
606 
607 
620  const ImportPdsTable::ColumnDescr &ImportPdsTable::getColumnDescriptor(const int &nth) const {
621 
622  // Ensure the nrequested column is valid
623  if ( (nth >= columns()) || ( nth < 0) ) {
624  QString mess = "Index (" + QString::number(nth) +
625  ") into Columns invalid (max: " + QString::number(columns()) + ")";
626  throw IException(IException::Programmer, mess, _FILEINFO_);
627  }
628 
629  // All good, return the expected
630  return (m_coldesc[nth]);
631  }
632 
633 
648  ImportPdsTable::ColumnDescr *ImportPdsTable::findColumn(const QString &colName) {
649  QString cName = getFormattedName(colName);
650  ColumnTypes::iterator col = m_coldesc.begin();
651  while (col != m_coldesc.end()) {
652  QString c = getFormattedName(col->m_name);
653  if (c.toUpper() == cName.toUpper()) { return (&(*col)); }
654  col++;
655  }
656  return (0);
657  }
658 
659 
674  const ImportPdsTable::ColumnDescr *ImportPdsTable::findColumn(const QString &colName) const {
675  QString cName = getFormattedName(colName);
676  ColumnTypes::const_iterator col = m_coldesc.begin();
677  while (col != m_coldesc.end()) {
678  QString c = getFormattedName(col->m_name);
679  if (c.toUpper() == cName.toUpper()) { return (&(*col)); }
680  col++;
681  }
682  return (0);
683  }
684 
685 
696  QString ImportPdsTable::getColumnValue(const QString &tline,
697  const ColumnDescr &cdesc,
698  const QString &delimiter) const {
699  return (tline.mid(cdesc.m_startByte, cdesc.m_numBytes));
700  }
701 
702 
718  QStringList ImportPdsTable::getColumnFields(const QString &tline,
719  const ColumnDescr &cdesc,
720  const QString &delimiter) const {
721 
722  // If item count is 1, simply return the whole column
723  QString value = getColumnValue(tline, cdesc, delimiter);
724  if ( 1 == cdesc.m_items) return ( QStringList(value) );
725 
726  // If there is no item size specified, see if we should seperate with
727  // delimiter
728  if ( 0 == cdesc.m_itemBytes ) {
729  if ( delimiter.isEmpty() ) return ( QStringList(value));
730 
731  return ( value.split(delimiter, QString::SkipEmptyParts) );
732  }
733 
734  // Have an item size specified. Assume it has single character separator
735  QStringList fields;
736  int pos = 0;
737  for (int i = 0 ; i < cdesc.m_items ; i++) {
738  fields.push_back(value.mid(pos, cdesc.m_itemBytes));
739  pos += cdesc.m_itemBytes + 1;
740  }
741 
742  return (fields);
743  }
744 
745 
765  QString ImportPdsTable::getFormattedName(const QString &colname) const {
766  QString cname = QString(colname).replace(QRegExp("[(),]"), " ").simplified();
767 
768  bool uppercase = true;
769  QString oString;
770  for (int i = 0 ; i < cname.size() ; i++) {
771  if (uppercase) {
772  oString.push_back(cname[i].toUpper());
773  uppercase = false;
774  }
775  else if ( (cname[i] == ' ') || (cname[i] == '_') ) {
776  uppercase = true;
777  }
778  else {
779  oString.push_back(cname[i].toLower());
780  }
781  }
782 
783  return (oString);
784  }
785 
786 
804  QString ImportPdsTable::getGenericType(const QString &ttype) const {
805  return ttype.split("_").last();
806  }
807 
808 
826  TableField ImportPdsTable::makeField(const ColumnDescr &cdesc) {
827  QString dtype = cdesc.m_dataType;
828  QString name = getFormattedName(cdesc.m_name);
829  if (m_pdsTableType == "ASCII") {
830  if ( dtype == "INTEGER" ) {
831  return (TableField(name, TableField::Integer));
832  }
833  else if ( ((dtype == "DOUBLE")
834  || (dtype == "REAL")
835  || (dtype == "FLOAT")) ) {
836  return (TableField(name, TableField::Double));
837  }
838  else {
839  return (TableField(name, TableField::Text, cdesc.m_numBytes));
840  }
841  }
842  else {
843  return makeFieldFromBinaryTable(cdesc);
844  }
845  }
846 
847 
862  TableRecord ImportPdsTable::makeRecord(const ColumnTypes &ctypes) {
863  TableRecord rec;
864  for (int i = 0 ; i < ctypes.size() ; i++) {
865  TableField field = makeField(ctypes[i]);
866  rec += field;
867  }
868  return (rec);
869  }
870 
871 
888  TableField &ImportPdsTable::extract(const Columns &cols,
889  const ColumnDescr &cdesc,
890  TableField &tfield) const {
891  int ith = cdesc.m_colnum;
892  try {
893  IString data(cols[ith]);
894  if (tfield.isInteger()) {
895  data.Trim(" \t\r\n");
896  tfield = data.ToInteger();
897  }
898  else if (tfield.isDouble()) {
899  data.Trim(" \t\r\n");
900  tfield = data.ToDouble();
901  }
902  else { // Its a text field
903  QString str(tfield.size(), ' ');
904  str.insert(0, data.Trim(" \t\r\n").ToQt());
905  tfield = str;
906  }
907  }
908  catch (IException &e) {
909  QString msg = "Conversion failure of column " + cdesc.m_name;
910  throw IException(e, IException::Programmer, msg, _FILEINFO_);
911  }
912 
913  return (tfield);
914  }
915 
916 
931  TableRecord &ImportPdsTable::extract(const Columns &cols,
932  const ColumnTypes &ctypes,
933  TableRecord &record) const {
934  for (int i = 0 ; i < ctypes.size() ; i++) {
935  extract(cols, ctypes[i], record[i]);
936  }
937  return (record);
938  }
939 
940 
956  void ImportPdsTable::fillTable(Table &table,
957  const ColumnTypes &cols,
958  TableRecord &record) const {
959  if (m_pdsTableType == "ASCII") {
960  for (int i = 0 ; i < m_rows.size() ; i++) {
961  try {
962  table += extract(m_rows[i], cols, record);
963  }
964  catch (IException &e) {
965  QString msg = "Failed to convert data in row [" + toString((int) i) + "]";
966  throw IException(e, IException::Programmer, msg, _FILEINFO_);
967  }
968  }
969  }
970 
971  else {
972  QString tempTblFile = m_pdsTableFile;
973  ifstream pdsFileStream(tempTblFile.toLatin1().data(), ifstream::binary);
974 
975  if (!pdsFileStream) {
976  IString msg = "Unable to open file containing PDS table ["
977  + tempTblFile + "].";
978  throw IException(IException::Unknown, msg, _FILEINFO_);
979  }
980 
981  // read and discard the rows above the table data
982  QScopedPointer<char, QScopedPointerArrayDeleter<char> > rowBuffer(new char[m_recordBytes]);
983  for (int i = 1; i < m_pdsTableStart; i++) {
984  pdsFileStream.read(rowBuffer.data(), m_recordBytes);
985  }
986  // now, import and add the records to the table
987  for (int rowIndex = 0; rowIndex < m_trows; rowIndex++) {
988  pdsFileStream.read(rowBuffer.data(), m_recordBytes);
989  TableRecord rec = extractBinary(rowBuffer.data(), record);
990  table += rec;
991  }
992  }
993 
994  return;
995  }
996 
997 
1005  int ImportPdsTable::columns() const {
1006  return (m_coldesc.size());
1007  }
1008 
1009 
1017  int ImportPdsTable::rows() const {
1018  return (m_rows.size());
1019  }
1020 
1021 
1037  TableRecord ImportPdsTable::extractBinary(char *rowBuffer, TableRecord &record) const {
1038  // for each record loop through the columns to get field values
1039  for (int colIndex = 0; colIndex < columns(); colIndex++) {
1040  QString columnName = m_coldesc[colIndex].m_name;
1041  for (int fieldIndex = 0 ; fieldIndex < record.Fields() ; fieldIndex++) {
1042  QString fieldName = record[fieldIndex].name();
1043  if (fieldName == columnName) {
1044  int startByte = m_coldesc[colIndex].m_startByte;
1045  int numBytes = m_coldesc[colIndex].m_numBytes;
1046 
1047  if (record[fieldIndex].isInteger()) {
1048  int columnValue;
1049  memmove(&columnValue, &rowBuffer[startByte], numBytes);
1050  EndianSwapper endianSwap(m_byteOrder);
1051  int fieldValue = endianSwap.Int(&columnValue);
1052  record[fieldIndex] = fieldValue;
1053  }
1054 
1055  else if (record[fieldIndex].isDouble()) {
1056  EndianSwapper endianSwap(m_byteOrder);
1057  double columnValue;
1058  memmove(&columnValue, &rowBuffer[startByte], numBytes);
1059  double fieldValue = endianSwap.Double(&columnValue);
1060  record[fieldIndex] = fieldValue;
1061  }
1062 
1063  else if (record[fieldIndex].isReal()) {
1064  EndianSwapper endianSwap(m_byteOrder);
1065  float columnValue;
1066  memmove(&columnValue, &rowBuffer[startByte], numBytes);
1067  float fieldValue = endianSwap.Float(&columnValue);
1068  record[fieldIndex] = fieldValue;
1069  }
1070 
1071  else if (record[fieldIndex].isText()) {
1072  QString fieldValue(numBytes, '\0');
1073  for (int byte = 0; byte < numBytes; byte++) {
1074  fieldValue[byte] = rowBuffer[startByte + byte];
1075  }
1076  record[fieldIndex] = fieldValue;
1077  }
1078 
1079  }
1080  }
1081  }
1082  return record;
1083  }
1084 
1085 
1108  TableField ImportPdsTable::makeFieldFromBinaryTable(const ColumnDescr &cdesc){
1109  QString dataType = cdesc.m_dataType;
1110  // For binary tables, we will not reformat the name of the column
1111  QString name = cdesc.m_name;
1112  if (dataType == "MSB_INTEGER" || dataType == "INTEGER"
1113  || dataType == "SUN_INTEGER" || dataType == "MAC_INTEGER") {
1114  if (cdesc.m_numBytes != 4) {
1115  QString msg = "Only 4 byte integer values are supported in Isis. "
1116  "PDS Column [" + cdesc.m_name
1117  + "] has an integer DATA_TYPE with [BYTES = "
1118  + toString(cdesc.m_numBytes) + "].";
1119  throw IException(IException::Unknown, msg, _FILEINFO_);
1120  }
1121  setPdsByteOrder("MSB");
1122  return TableField(name, TableField::Integer);
1123  }
1124  else if (dataType == "LSB_INTEGER" || dataType == "VAX_INTEGER"
1125  || dataType == "PC_INTEGER" ) {
1126  if (cdesc.m_numBytes != 4) {
1127  QString msg = "Only 4 byte integer values are supported in Isis. "
1128  "PDS Column [" + cdesc.m_name
1129  + "] has an integer DATA_TYPE with [BYTES = "
1130  + toString(cdesc.m_numBytes) + "].";
1131  throw IException(IException::Unknown, msg, _FILEINFO_);
1132  }
1133  setPdsByteOrder("LSB");
1134  return TableField(name, TableField::Integer);
1135  }
1136  else if (dataType == "FLOAT" //IEEE_REAL alias (MSB)
1137  || dataType == "REAL" //IEEE_REAL alias (MSB)
1138  || dataType == "SUN_REAL" //IEEE_REAL alias (MSB)
1139  || dataType == "MAC_REAL" //IEEE_REAL alias (MSB)
1140  || dataType == "IEEE_REAL" ) {
1141  setPdsByteOrder("MSB");
1142  if (cdesc.m_numBytes == 8) {
1143  return TableField(name, TableField::Double);
1144  }
1145  else if (cdesc.m_numBytes == 4) {
1146  return TableField(name, TableField::Real);
1147  }
1148  else {
1149  IString msg = "Only 4 byte or 8 byte real values are supported in Isis. "
1150  "PDS Column [" + cdesc.m_name
1151  + "] has a real DATA_TYPE with [BYTES = "
1152  + toString(cdesc.m_numBytes) + "].";
1153  throw IException(IException::Unknown, msg, _FILEINFO_);
1154  }
1155  }
1156  else if (dataType == "PC_REAL") {
1157  setPdsByteOrder("LSB");
1158  if (cdesc.m_numBytes == 8) {
1159  return TableField(name, TableField::Double);
1160  }
1161  else if (cdesc.m_numBytes == 4) {
1162  return TableField(name, TableField::Real);
1163  }
1164  else {
1165  QString msg = "Only 4 byte or 8 byte real values are supported in Isis. "
1166  "PDS Column [" + cdesc.m_name
1167  + "] has a real DATA_TYPE with [BYTES = "
1168  + toString(cdesc.m_numBytes) + "].";
1169  throw IException(IException::Unknown, msg, _FILEINFO_);
1170  }
1171  }
1172  else if (dataType.contains("CHARACTER")
1173  || dataType.contains("ASCII")
1174  || dataType == "DATE" || dataType == "TIME" ) {
1175  return TableField(name, TableField::Text, cdesc.m_numBytes);
1176  }
1177  // Isis3 tables currently don't support any of the following PDS DATA_TYPE:
1178  // BIT_STRING, COMPLEX, N/A, BOOLEAN, UNSIGNED_INTEGER, IBM types, some VAX types
1179  IString msg = "PDS Column [" + cdesc.m_name
1180  + "] has an unsupported DATA_TYPE ["
1181  + dataType + "].";
1182  throw IException(IException::Unknown, msg, _FILEINFO_);
1183  }
1184 
1185 
1197  void ImportPdsTable::setPdsByteOrder(QString byteOrder) {
1198  if (!m_byteOrder.isEmpty() && m_byteOrder != byteOrder) {
1199  QString msg = "Unable to import the binary PDS table [" + m_tableName
1200  + "]. The column DATA_TYPE values indicate differing byte "
1201  "orders. ";
1202  throw IException(IException::Unknown, msg.toStdString(), _FILEINFO_);
1203  }
1204  m_byteOrder = byteOrder;
1205  }
1206 
1207 
1218  bool ImportPdsTable::processRow(const int &row, const QString &rowdata) {
1219  Columns cols;
1220  for (int i = 0 ; i < columns() ; i++) {
1221  cols.push_back(getColumnValue(rowdata, m_coldesc[i]));
1222  }
1223  m_rows.append(cols);
1224 
1225  return (true);
1226  }
1227 
1228 } // namespace Isis
PvlObject & object(const int index)
Return the object at the specified index.
Definition: PvlObject.cpp:460
float Float(void *buf)
Swaps a floating point value.
void clear()
Clears all values and units for this PvlKeyword object.
Definition: PvlKeyword.cpp:307
PvlObjectIterator endObject()
Returns the index of the ending object.
Definition: PvlObject.h:265
QString ToQt() const
Retuns the object string as a QString.
Definition: IString.cpp:884
File name manipulation and expansion.
Definition: FileName.h:111
double ToDouble() const
Returns the floating point value the IString represents.
Definition: IString.cpp:814
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
Definition: PvlObject.h:286
int m_itemBytes
Number bytes per item.
int toInt(const QString &string)
Global function to convert from a string to an integer.
Definition: IString.cpp:108
QString m_name
Name of column.
int ToInteger() const
Returns the object string as an integer.
Definition: IString.cpp:733
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:226
bool hasKeyword(const QString &kname, FindOptions opts) const
See if a keyword is in the current PvlObject, or deeper inside other PvlObjects and Pvlgroups within ...
Definition: PvlObject.cpp:207
QList< PvlObject >::iterator PvlObjectIterator
The counter for objects.
Definition: PvlObject.h:239
int Fields() const
Returns the number of fields that are currently in the record.
Definition: TableRecord.cpp:94
PvlKeyword & findKeyword(const QString &kname, FindOptions opts)
Finds a keyword in the current PvlObject, or deeper inside other PvlObjects and Pvlgroups within this...
Definition: PvlObject.cpp:148
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:38
double Double(void *buf)
Swaps a double precision value.
bool isInteger() const
Determines whether the field type is Integer.
Definition: TableField.cpp:138
int objects() const
Returns the number of objects.
Definition: PvlObject.h:231
Byte swapper.
Definition: EndianSwapper.h:54
bool isDouble() const
Determines whether the field type is Double.
Definition: TableField.cpp:148
bool GetLine(QString &line, const bool skipComments=true)
Gets next line from file.
Definition: TextFile.cpp:427
Container for cube-like labels.
Definition: Pvl.h:135
int m_items
Number of items in column.
Provides access to sequential ASCII stream I/O.
Definition: TextFile.h:54
bool hasObject(const QString &name) const
Returns a boolean value based on whether the object exists in the current PvlObject or not...
Definition: PvlObject.h:335
Class for storing Table blobs information.
Definition: Table.h:74
int size() const
Returns the number of values stored for the field at each record.
Definition: TableField.cpp:184
int m_startByte
Starting byte of data.
Isis exception class.
Definition: IException.h:99
Adds specific functionality to C++ strings.
Definition: IString.h:179
Class for storing an Isis::Table&#39;s field information.
Definition: TableField.h:63
int m_numBytes
Number bytes in column.
QString m_dataType
PDS table DATA_TYPE of column.
Contains Pvl Groups and Pvl Objects.
Definition: PvlObject.h:74
PvlObjectIterator beginObject()
Returns the index of the beginning object.
Definition: PvlObject.h:247
QString path() const
Returns the path.
Definition: FileName.cpp:88
QString name() const
Returns the container name.
Definition: PvlContainer.h:78
IString Trim(const std::string &chars)
Removes characters from the beginning and end of the IString.
Definition: IString.cpp:540
int Int(void *buf)
Swaps a 4 byte integer value.

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:20:26