Isis 3 Programmer Reference
Isis::ImportPdsTable Class Reference

Import a PDS table file with a label description. More...

#include <ImportPdsTable.h>

Collaboration diagram for Isis::ImportPdsTable:
Collaboration graph

Classes

struct  ColumnDescr
 

Public Member Functions

 ImportPdsTable ()
 Default constructor.
 
 ImportPdsTable (const QString &pdsLabFile, const QString &pdsTabFile="", const QString &pdsTableName="TABLE")
 This constructor automatically loads the given label and table files.
 
virtual ~ImportPdsTable ()
 Destructs the ImportPdsTable object.
 
QString name () const
 Return the name of the PDS table.
 
void setName (const QString &name="TABLE")
 Set the name of the PDS table object.
 
int columns () const
 Returns the number of columns in the table.
 
int rows () const
 Returns the number of rows in the table.
 
void load (const QString &pdsLabFile, const QString &pdsTabFile="", const QString &pdsTableName="TABLE")
 Loads a PDS table label and (optional) data file.
 
bool hasColumn (const QString &colName) const
 This method determines whether the PDS table has a column with the given name.
 
QString getColumnName (const unsigned int &index=0, const bool &formatted=true) const
 Returns the name of the specifed column.
 
QStringList getColumnNames (const bool &formatted=true) const
 Return the names of all the columns.
 
QString getFormattedName (const QString &colname) const
 Converts a column name to a camel-case after it has been cleansed.
 
QString getType (const QString &colName) const
 Get the type associated with the specified column.
 
bool setType (const QString &colName, const QString &dataType)
 Change the datatype for a column.
 
Table importTable (const QString &isisTableName)
 Populate a Table object with the PDS table and return it.
 
Table importTable (const QString &colNames, const QString &isisTableName)
 Populate ISIS Table with specified column(s) from ASCII table.
 
Table importTable (const QStringList &colNames, const QString &isisTableName)
 Populate ISIS Table with specific columns from ASCII table.
 

Protected Types

typedef QList< ColumnDescrColumnTypes
 
typedef QStringList Columns
 
typedef QList< ColumnsRows
 

Protected Member Functions

const ColumnDescrgetColumnDescriptor (const int &nth) const
 Retrieve a column description by index.
 
ColumnDescrfindColumn (const QString &colName)
 Searches internal column descriptors for a named column.
 
const ColumnDescrfindColumn (const QString &colName) const
 Searches internal column descriptors for a named column.
 
QString getColumnValue (const QString &tline, const ColumnDescr &cdesc, const QString &delimiter="") const
 Extracts a column from a QString based upon a description.
 
QStringList getColumnFields (const QString &tline, const ColumnDescr &cdesc, const QString &delimiter="") const
 Extracts column fields from a QString based upon a description.
 
QString getGenericType (const QString &ttype) const
 Determine generic data type of a column.
 
virtual bool processRow (const int &row, const QString &rowdata)
 Process a freshly read PDS table line of data.
 

Private Member Functions

void init ()
 Initialize object variables.
 
void loadLabel (const QString &labfile, QString &tblfile, const QString &tblname="")
 Loads the contents of a PDS table label description.
 
void loadTable (const QString &tabfile)
 Loads the contents of a PDS table data file.
 
ColumnDescr getColumnDescription (PvlObject &colobj, int nth) const
 Extract a column description from a COLUMN object.
 
TableRecord makeRecord (const ColumnTypes &ctypes)
 Creates a TableRecord for columns.
 
TableField makeField (const ColumnDescr &cdesc)
 Creates a TableField for the column type.
 
TableField makeFieldFromBinaryTable (const ColumnDescr &cdesc)
 Creates an empty TableField with the appropriate type from a binary PDS table column description.
 
void setPdsByteOrder (QString byteOrder)
 Sets the byte order for BINARY PDS table files.
 
TableFieldextract (const Columns &columns, const ColumnDescr &cdesc, TableField &field) const
 Extract a TableField from a PDS column in the text row.
 
TableRecordextract (const Columns &columns, const ColumnTypes &ctypes, TableRecord &record) const
 Extract a table record of columns from a row of columns.
 
TableRecord extractBinary (char *rowBuffer, TableRecord &record) const
 This method is used to set the field values for the given record.
 
void fillTable (Table &table, const ColumnTypes &columns, TableRecord &record) const
 Fill the ISIS Table object with PDS table data.
 

Private Attributes

int m_trows
 Number rows in table according to label.
 
ColumnTypes m_coldesc
 Column descriptions.
 
Rows m_rows
 Table data.
 
QString m_pdsTableType
 The INTERCHANGE_FORMAT value for the table.
 
int m_rowBytes
 The number of bytes for one PDS table row.
 
int m_recordBytes
 The number of bytes for one Isis table record.
 
QString m_tableName
 The name of the PDS table object.
 
QString m_pdsTableFile
 The name of the file containing the table data.
 
int m_pdsTableStart
 The start byte of the PDS table data.
 
QString m_byteOrder
 The byte order of the PDS table file, if binary.
 

Detailed Description

Import a PDS table file with a label description.

This class ingests a PDS table and converts it to an ISIS Table object. This class can handle importing PDS tables whose data is BINARY or ASCII format.

The PDS label file should completely define the contents of a PDS table with ASCII data or BINARY data. The location of the table data is determined from a label keyword, ^TABLE (or ^NAME_TABLE). This keyword will indicate the name of the file containing the table data and the start record value where the table data begins. If the keyword only gives the start record, the table is attached to the file that contains the label. If the keyword only gives a file name, that file only contains the data for the indicated table. PDS table files have the extension *.TAB if the table data is ASCII format and *.DAT if the data is BINARY. When constructing an ImportPdsTable object, programmers can provide a different name for the PDS table file.

NOTE: Depending on the INTERCHANGE_FORMAT value, programmers should choose the appropriate methods from this class.

Example of PDS ASCII table import. Construct the ImportPdsTable object with a label name, set the data type for the specified PDS columns, and import the PDS table to an Isis table with the comma separtated column names. ImportPdsTable pdsTable(labelFileName, tableFileName); pdsTable.setType("ScetTimeClock", "CHARACTER"); pdsTable.setType("ShutterStatus", "CHARACTER"); pdsTable.setType("MirrorSin", "DOUBLE"); pdsTable.setType("MirrorCos", "DOUBLE"); Table isisTable = pdsTable.importTable("ScetTimeClock,ShutterStatus,MirrorSin,MirrorCos", "VIRHouseKeeping"); Example of PDS BINARY table import. If the default constructor is used, the load method must be called to pass in the label file name. The PDS table can then be imported and an Isis Table object is returned. ImportPdsTable pdsTable; load(labelFileName, "", pdsTableName); Table isisTable = pdsTable.importTable(isisTableName);

Author
2011-07-20 Kris Becker
History

2011-08-02 Kris Becker - Modified to ensure the proper size of strings are exported to the TableRecord

2012-10-04 Jeannie Backer - Changed references to TableField methods to lower camel case. Added and ordered includes. Moved method implementation to cpp. References #1169.

2012-11-21 Jeannie Backer - Added implementation for importing binary PDS tables. Changed method name from "exportAsTable" to "importTable". Improved unitTest coverage. References #700.

2015-07-17 Kris Becker - Declare destructor as virtual to make it iheritable. Reorganized to support interception of storage methods for derived class use.

2016-02-24 Ian Humphrey - Updated documentation and unit test. Added edrindex.lbl and edrindex.tab files to data directory (for tests). Fixes #2397.

2016-03-10 Jeannie Backer - Removed non-UTF8 character. References #2397.

2018-02-12 Stuart Sides - Added detached table capabilities for label files without a "RECORD_BYTES" keyword. References #5525.

Todo
The binary table import methods were written after the ascii table import. The class should be better organized so that the programmer does not need to know which methods to call based on INTERCHANGE_FORMAT. The program should take care of this internally.

Definition at line 101 of file ImportPdsTable.h.

Member Typedef Documentation

◆ Columns

Definition at line 147 of file ImportPdsTable.h.

◆ ColumnTypes

Definition at line 146 of file ImportPdsTable.h.

◆ Rows

Definition at line 148 of file ImportPdsTable.h.

Constructor & Destructor Documentation

◆ ImportPdsTable() [1/2]

Isis::ImportPdsTable::ImportPdsTable ( )

Default constructor.

This constructor initializes the PDS table name to TABLE.

If this constructor is used, the load() method will need to be called to set the PDS label file.

This constructor may be used for ASCII or BINARY PDS tables.

Definition at line 43 of file ImportPdsTable.cpp.

References init(), and m_tableName.

◆ ImportPdsTable() [2/2]

Isis::ImportPdsTable::ImportPdsTable ( const QString & pdsLabFile,
const QString & pdsTableFile = "",
const QString & pdsTableName = "TABLE" )

This constructor automatically loads the given label and table files.

This constructor takes the name of the label file describing the PDS table, the table data file name, and the name of the PDS table object. It will extract the description of the columns and read the contents of the table data file.

If no table file is given or an empty QString is given for the table file, the table location will be read from the label file.

If no table name is given, the default name for the object is TABLE.

This constructor may be used for ASCII or BINARY PDS tables.

Parameters
pdsLabFileName of table label file
pdsTableFileName of table data file
pdsTableNameThe name of the table object in the PDS file.
History
2016-02-24 Ian Humphrey - pdsTableName param is now being passed to load method. References #2397.

Definition at line 73 of file ImportPdsTable.cpp.

References load(), and m_tableName.

◆ ~ImportPdsTable()

Isis::ImportPdsTable::~ImportPdsTable ( )
virtual

Destructs the ImportPdsTable object.

Definition at line 84 of file ImportPdsTable.cpp.

Member Function Documentation

◆ columns()

int Isis::ImportPdsTable::columns ( ) const

Returns the number of columns in the table.

This method can be called for ASCII or BINARY PDS tables.

Returns
int The number of columns.

Definition at line 999 of file ImportPdsTable.cpp.

References m_coldesc.

Referenced by extractBinary(), getColumnDescriptor(), getColumnName(), getColumnNames(), loadLabel(), and processRow().

◆ extract() [1/2]

TableField & Isis::ImportPdsTable::extract ( const Columns & cols,
const ColumnDescr & cdesc,
TableField & tfield ) const
private

Extract a TableField from a PDS column in the text row.

This routine will extract the column and convert to a TableField with the appropriate type to contain the field.

This method is only called for ASCII PDS tables.

Parameters
colsColumns for a given row
cdescColumn description used to create TableField
tfieldIsis TableField used to determine the data type to be imported.
Returns
TableField Returns the TableField with the value from the column
Exceptions
IException::Programmer"Conversion failure of column [column name]"

Definition at line 882 of file ImportPdsTable.cpp.

References Isis::IException::Programmer, Isis::IString::ToDouble(), Isis::IString::ToInteger(), Isis::IString::ToQt(), and Isis::IString::Trim().

Referenced by extract(), and fillTable().

◆ extract() [2/2]

TableRecord & Isis::ImportPdsTable::extract ( const Columns & cols,
const ColumnTypes & ctypes,
TableRecord & record ) const
private

Extract a table record of columns from a row of columns.

This method will create a TableRecord from a list of columns. The columns are selected from the list of column descriptions parameter.

This method is only called for ASCII PDS tables.

Parameters
colsRow of column data
ctypesList of columns to extract
recordTableRecord with fields to populate
Returns
TableRecord Record containing extract fields from columns

Definition at line 925 of file ImportPdsTable.cpp.

References extract().

◆ extractBinary()

TableRecord Isis::ImportPdsTable::extractBinary ( char * rowBuffer,
TableRecord & record ) const
private

This method is used to set the field values for the given record.

These values are extracted from the given binary buffer containing the PDS table data for the corresponding row.

This method is only called for BINARY PDS tables.

Parameters
rowBufferBuffer containing the binary information for one row of the table.
recordThe TableRecord containing fields with correct names and types but no values. The field values will be set by this method.
Returns
TableRecord TableRecord containing the field values extracted from the row buffer.

Definition at line 1031 of file ImportPdsTable.cpp.

References columns(), Isis::TableRecord::Fields(), m_byteOrder, and m_coldesc.

Referenced by fillTable().

◆ fillTable()

void Isis::ImportPdsTable::fillTable ( Table & table,
const ColumnTypes & cols,
TableRecord & record ) const
private

Fill the ISIS Table object with PDS table data.

This method populates the ISIS Table object with selected PDS table data fields.

This method is used for ASCII or BINARY PDS tables.

Parameters
tableISIS Table object to populate
colsPDS Column map to extract data
recordISIS TableRecord with fields to contain PDS columns
Exceptions
IException::Programmer"Failed to convert data in row [row number]"
IException::Unknown"Unable to open file containing PDS table [table file]."

Definition at line 950 of file ImportPdsTable.cpp.

References extract(), extractBinary(), m_pdsTableFile, m_pdsTableStart, m_pdsTableType, m_recordBytes, m_rows, m_trows, Isis::IException::Programmer, Isis::toString(), and Isis::IException::Unknown.

Referenced by importTable(), and importTable().

◆ findColumn() [1/2]

ImportPdsTable::ColumnDescr * Isis::ImportPdsTable::findColumn ( const QString & colName)
protected

Searches internal column descriptors for a named column.

This method converts the column names to a formatted name for consistency and then checks for the given name - with case insensitivity. If found, a pointer to the column description is returned, otherwise NULL.

This method can be called for ASCII or BINARY PDS tables.

Parameters
colNameName of column to find
Returns
ImportPdsTable::ColumnDescr* Pointer to column description is returned if found otherwise, NULL is returned.

Definition at line 642 of file ImportPdsTable.cpp.

References getFormattedName(), and m_coldesc.

Referenced by getType(), hasColumn(), importTable(), and setType().

◆ findColumn() [2/2]

const ImportPdsTable::ColumnDescr * Isis::ImportPdsTable::findColumn ( const QString & colName) const
protected

Searches internal column descriptors for a named column.

This method converts the column names to a formatted name for consistency and then checks for the given name - with case insensitivity. If found, a pointer to the column description is returned, otherwise NULL.

This method can be called for ASCII or BINARY PDS tables.

Parameters
colNameName of column to find
Returns
const ImportPdsTable::ColumnDescr* Const pointer to column description is returned if found otherwise, NULL is returned.

Definition at line 668 of file ImportPdsTable.cpp.

References getFormattedName(), and m_coldesc.

◆ getColumnDescription()

ImportPdsTable::ColumnDescr Isis::ImportPdsTable::getColumnDescription ( PvlObject & colobj,
int nth ) const
private

Extract a column description from a COLUMN object.

This method will extract a column description from a COLUMN object. This object will typically be contained in a Pvl PDS compatable file that accompanies the table data file.

The keywords NAME, DATA_TYPE, START_BYTE and BYTES must exist.

This method is used for ASCII or BINARY PDS tables.

Parameters
colobjPvl Object containing column description
nthCurrent column counter
Returns
ImportPdsTable::ColumnType Returns internal struct of column description

Definition at line 572 of file ImportPdsTable.cpp.

References getGenericType(), Isis::ImportPdsTable::ColumnDescr::m_name, and m_pdsTableType.

Referenced by loadLabel().

◆ getColumnDescriptor()

const ImportPdsTable::ColumnDescr & Isis::ImportPdsTable::getColumnDescriptor ( const int & nth) const
protected

Retrieve a column description by index.

Author
2015-07-17 Kris Becker
Parameters
nthIndex of column description to retrieve, starting at 0
Returns
const ImportPdsTable::ColumnDescr& Reference to requested column description
Exceptions
IException::Programmer"Index ([nth]) into Columns invalid (max: [columns])"

Definition at line 614 of file ImportPdsTable.cpp.

References columns(), m_coldesc, and Isis::IException::Programmer.

◆ getColumnFields()

QStringList Isis::ImportPdsTable::getColumnFields ( const QString & tline,
const ColumnDescr & cdesc,
const QString & delimiter = "" ) const
protected

Extracts column fields from a QString based upon a description.

This method should not be called for BINARY PDS tables.

Parameters
tlineRow from table data
cdescColumn description
delimiterDelimiter used to delimit column fields (optional)
Returns
QStringList Returns the extracted column fields as a QStringList
History
2016-02-24 Ian Humphrey - Modified logic to correctly determine when item size is not specified. References #2397.

Definition at line 712 of file ImportPdsTable.cpp.

References getColumnValue().

◆ getColumnName()

QString Isis::ImportPdsTable::getColumnName ( const unsigned int & index = 0,
const bool & formatted = true ) const

Returns the name of the specifed column.

This method will return the name of a specified column by index. It also has the option to format the column name to Camel-Case. This will remove all left and right parens, convert white space to spaces, compress consecutive spaces to only one space. It then removes the spaces converting the next character to uppercase.

This method can be called for ASCII or BINARY PDS tables.

Parameters
indexIndex of colunm name to get.
formattedSpecifies to convert the name to Camel-Case if true, otherwise leave as is in the PDS table.
Returns
QString Returns the column name as requested
Exceptions
IException::Programmer"Unable to import the binary PDS table into Isis. The requested column index exceeds the last column index."

Definition at line 211 of file ImportPdsTable.cpp.

References columns(), getFormattedName(), m_coldesc, m_tableName, name(), Isis::IException::Programmer, and Isis::toString().

◆ getColumnNames()

QStringList Isis::ImportPdsTable::getColumnNames ( const bool & formatted = true) const

Return the names of all the columns.

This method will return the names of all columns. It also has the option to format the column name to Camel-Case. This will remove all left and right parens, convert white space to spaces, compress consecutive spaces to only one space. It then removes the spaces converting the next character to uppercase.

This method can be called for ASCII or BINARY PDS tables.

Parameters
formattedSpecifies to convert the name to Camel-Case if true, otherwise leave as is in the PDS table.
Returns
QStringList List of all column names.

Definition at line 242 of file ImportPdsTable.cpp.

References columns(), getFormattedName(), m_coldesc, and name().

◆ getColumnValue()

QString Isis::ImportPdsTable::getColumnValue ( const QString & tline,
const ColumnDescr & cdesc,
const QString & delimiter = "" ) const
protected

Extracts a column from a QString based upon a description.

This method should not be called for BINARY PDS tables.

Parameters
tlineRow from table data
cdescColumn description
Returns
QString Returns the extracted column as a QString

Definition at line 690 of file ImportPdsTable.cpp.

Referenced by getColumnFields(), and processRow().

◆ getFormattedName()

QString Isis::ImportPdsTable::getFormattedName ( const QString & colname) const

Converts a column name to a camel-case after it has been cleansed.

This method will convert a column name to camel-case after some character cleaning is performed. All white space characters as defined by the IString class are converted to spaces. Spaces are then compressed to one space. Any left/right parens are removed. Then the conversion to camel-case is performed.

Camel case always converts the first character in a QString to uppercase. Any space or '_' character are removed and the following character is converted to uppercase. All other characters are converted to lowercase.

This method can be called for ASCII or BINARY PDS tables.

Parameters
colnameColumn name to converty
Returns
QString Returns the formatted keyword

Definition at line 759 of file ImportPdsTable.cpp.

Referenced by findColumn(), findColumn(), getColumnName(), getColumnNames(), and makeField().

◆ getGenericType()

QString Isis::ImportPdsTable::getGenericType ( const QString & ttype) const
protected

Determine generic data type of a column.

This method will determine the generic type of a column. In general, PDS table descriptions contain types that have some prepended qualifiers to column data types. This routine removes those qualifiers and only returns the generic type.

For example, if the incoming type is MSB_INTEGER, only INTEGER will be returned.

This method is used for ASCII or BINARY PDS tables.

Parameters
ttypePDS data type to convert
Returns
QString Generic type found in the data type.

Definition at line 798 of file ImportPdsTable.cpp.

Referenced by getColumnDescription().

◆ getType()

QString Isis::ImportPdsTable::getType ( const QString & colName) const

Get the type associated with the specified column.

This method returns the datatype associated with the specfied column. If the column does not exist, an empty QString is returned.

This method can be called for ASCII or BINARY PDS tables.

Author
2011-06-27 Kris Becker
Parameters
colNameName of column to get type for.
Returns
QString Returns the type of the column. If the column does not exist, an empty QString is returned.

Definition at line 268 of file ImportPdsTable.cpp.

References findColumn(), and Isis::ImportPdsTable::ColumnDescr::m_dataType.

◆ hasColumn()

bool Isis::ImportPdsTable::hasColumn ( const QString & colName) const

This method determines whether the PDS table has a column with the given name.

This method can be called for ASCII or BINARY PDS tables.

Parameters
colNameA QString containing the column name.
Returns
bool Indicates whether the table has the given column.

Definition at line 186 of file ImportPdsTable.cpp.

References findColumn().

◆ importTable() [1/3]

Table Isis::ImportPdsTable::importTable ( const QString & colnames,
const QString & isisTableName )

Populate ISIS Table with specified column(s) from ASCII table.

This method extracts columns specified by the caller in a QString. It is typically used for a single column, but any number of columns can be provided. colnames is a comma delimited QString that contains the name of the columns that will be exported in the table.

This method should only be called for ASCII PDS tables. If needed for BINARY tables, implementation should be added and tested.

Parameters
colNamesString containing comma delimited column names to export
isisTableNameName of table to create
Returns
Table Table containing the specified columns

Definition at line 350 of file ImportPdsTable.cpp.

References importTable().

◆ importTable() [2/3]

Table Isis::ImportPdsTable::importTable ( const QString & isisTableName)

Populate a Table object with the PDS table and return it.

This method converts PDS table data to an ISIS table.

This method can be called to import ASCII or BINARY PDS tables.

Parameters
isisTableNameName of table
Returns
Table Table containing PDS table data
Exceptions
IException::Unknown"Unable to import the PDS table from the PDS file into Isis."

Definition at line 318 of file ImportPdsTable.cpp.

References fillTable(), m_coldesc, m_pdsTableFile, m_tableName, makeRecord(), and Isis::IException::Unknown.

Referenced by importTable().

◆ importTable() [3/3]

Table Isis::ImportPdsTable::importTable ( const QStringList & colnames,
const QString & isisTableName )

Populate ISIS Table with specific columns from ASCII table.

This method extracts columns specified by the caller. If the requested column does not exist, an exception is thrown.

This method should only be called for ASCII PDS tables. If needed for BINARY tables, implementation should be added and tested.

Parameters
colNamesQStringList of column names to convert to a table.
isisTableNameName of the table to create.
Returns
Table Table containing the specified columns
Exceptions
IException::Programmer"Unable to import the PDS table into Isis. The requested column name does not exist in table."

Definition at line 373 of file ImportPdsTable.cpp.

References fillTable(), findColumn(), m_tableName, makeRecord(), and Isis::IException::Programmer.

◆ init()

void Isis::ImportPdsTable::init ( )
private

Initialize object variables.

This method is used for ASCII or BINARY PDS tables.

Definition at line 401 of file ImportPdsTable.cpp.

References m_byteOrder, m_coldesc, m_pdsTableFile, m_pdsTableStart, m_pdsTableType, m_rows, and m_trows.

Referenced by ImportPdsTable(), and load().

◆ load()

void Isis::ImportPdsTable::load ( const QString & pdsLabFile,
const QString & pdsTableFile = "",
const QString & pdsTableName = "TABLE" )

Loads a PDS table label and (optional) data file.

This method will load a PDS table dataset using a label file describing the contents of the table data. The caller can provide the table data file, otherwise, the location of the table data is extracted from the ^TABLE_NAME keyword in the provided labels. The table data is then loaded.

This method needs to be called if the default constructor is used. Otherwise, it is invoked in the constructor that takes the label, table file, and table name. This method may be used to overwrite the label and table file used. When it is invoked, the current contents of the object are discarded.

This method is used for ASCII or BINARY PDS tables.

Parameters
pdsLabFileName of PDS table label file
pdsTableFileName of PDS table data file to be imported into Isis (optional)
pdsTableNameName of the table object in the PDS file (optional)
Exceptions
IException::Unknown"Unable to import PDS table. Neither of the possible table values were found."
History
2016-02-24 Ian Humphrey - pdsTableName is now being passed to loadLabel. References #2397.

Definition at line 132 of file ImportPdsTable.cpp.

References init(), loadLabel(), loadTable(), m_pdsTableFile, m_pdsTableStart, m_pdsTableType, Isis::toInt(), and Isis::IException::Unknown.

Referenced by ImportPdsTable().

◆ loadLabel()

void Isis::ImportPdsTable::loadLabel ( const QString & pdsLabFile,
QString & pdsTableFile,
const QString & tblname = "" )
private

Loads the contents of a PDS table label description.

The pdsLabFile parameter contains the name of a PDS label describing the contents of a PDS table data file. The label will be loaded and parsed by this method. The name of the table data file is returned in the pdsTableFile parameter. The table data file is not loaded.

If the tblname parameter is not provided or is empty, the table's name set during construction or with the setName() method will be used to find the table object in the PDS label file.

This method is used for ASCII or BINARY PDS tables.

Parameters
pdsLabFileName of PDS table label description file
pdsTableFileReturns the name of the PDS table data
tblnameName of the table object in the PDS file (optional)
Exceptions
IException::Unknown"The PDS file does not have the required TABLE object. The PDS label file is probably invalid"
IException::User"Unable to import the PDS table from the PDS file into Isis. The PDS INTERCHANGE_FORMAT is not supported. Valid values are ASCII or BINARY."

Definition at line 438 of file ImportPdsTable.cpp.

References columns(), Isis::PvlObject::findKeyword(), Isis::PvlObject::findObject(), getColumnDescription(), Isis::PvlObject::hasKeyword(), Isis::PvlObject::hasObject(), m_coldesc, m_pdsTableType, m_recordBytes, m_rowBytes, m_tableName, m_trows, Isis::PvlContainer::name(), Isis::PvlObject::object(), Isis::FileName::path(), Isis::IException::Unknown, and Isis::IException::User.

Referenced by load().

◆ loadTable()

void Isis::ImportPdsTable::loadTable ( const QString & pdsTableFile)
private

Loads the contents of a PDS table data file.

This method opens and reads the contents of a PDS table data file. Values for each column are extracted from each row according to the label description. The entire table contents are stored internally.

Note that the table label description must already be loaded in this object.

This method is called by the load() method if the PDS file is ASCII.

See also
loadLabel().
Parameters
pdsTableFileName of PDS table data file

Definition at line 534 of file ImportPdsTable.cpp.

References m_rows, m_trows, and processRow().

Referenced by load().

◆ makeField()

TableField Isis::ImportPdsTable::makeField ( const ColumnDescr & cdesc)
private

Creates a TableField for the column type.

This method generates a TableField with the appropriate type to contain the PDS coulumn data. It will only create three different types: Integer, Double or Text.

All PDS data types that have INTEGER in their type are stored as an Integer field type. PDS columns with DOUBLE, REAL or FLOAT are stored as Doubles. All other types are Text types.

This method is called for ASCII or BINARY PDS tables.

Parameters
cdescColumn description to create the TableField from
Returns
TableField Returns a TableField for the column type

Definition at line 820 of file ImportPdsTable.cpp.

References Isis::TableField::Double, getFormattedName(), Isis::TableField::Integer, m_pdsTableType, makeFieldFromBinaryTable(), name(), and Isis::TableField::Text.

Referenced by makeRecord().

◆ makeFieldFromBinaryTable()

TableField Isis::ImportPdsTable::makeFieldFromBinaryTable ( const ColumnDescr & cdesc)
private

Creates an empty TableField with the appropriate type from a binary PDS table column description.

This method also determines whether the pds table has byte order LSB or MSB.

This method is only called for BINARY PDS tables.

Parameters
cdescThe ColumnDescr reference used to determine the column keyword values NAME, BYTES, and DATA_TYPE from the PDS file.
Returns
TableField object with the correct field name and field type, but no value.
Exceptions
IException::Unknown"Only 4 byte integer values are supported in Isis. PDS column [column name] has an integer DATA_TYPE with [BYTES = column's number of bytes]."
IException::Unknown"Only 4 byte or 8 byte real values are supported in Isis. PDS column [column name] has a real DATA_TYPE with [BYTES = column's number of bytes]. @throws IException::Unknown "PDS column [column name] has an unsupported DATA_TYPE [data type]."

Definition at line 1102 of file ImportPdsTable.cpp.

References Isis::TableField::Double, Isis::TableField::Integer, name(), Isis::TableField::Real, setPdsByteOrder(), Isis::TableField::Text, Isis::toString(), and Isis::IException::Unknown.

Referenced by makeField().

◆ makeRecord()

TableRecord Isis::ImportPdsTable::makeRecord ( const ColumnTypes & ctypes)
private

Creates a TableRecord for columns.

This method creates a TableRecord for each column in the table. This record should be provided when creating the ISIS Table object. It can also be used to populate the table. TableFields are added in the order provided in ctypes.

This method is called for ASCII or BINARY PDS tables.

Parameters
ctypesColumns to create fields for and add to record
Returns
TableRecord Returns TableRecord of columns/fields

Definition at line 856 of file ImportPdsTable.cpp.

References makeField().

Referenced by importTable(), and importTable().

◆ name()

QString Isis::ImportPdsTable::name ( ) const

Return the name of the PDS table.

Definition at line 89 of file ImportPdsTable.cpp.

References m_tableName.

Referenced by getColumnName(), getColumnNames(), makeField(), makeFieldFromBinaryTable(), and setName().

◆ processRow()

bool Isis::ImportPdsTable::processRow ( const int & row,
const QString & rowdata )
protectedvirtual

Process a freshly read PDS table line of data.

Author
2015-07-17 Kris Becker
Parameters
rowRow number being processed
rowdataCharacter line of data
Returns
bool True if succssful, false if error

Definition at line 1212 of file ImportPdsTable.cpp.

References columns(), getColumnValue(), m_coldesc, and m_rows.

Referenced by loadTable().

◆ rows()

int Isis::ImportPdsTable::rows ( ) const

Returns the number of rows in the table.

This method can be called for ASCII or BINARY PDS tables.

Returns
int The number of rows.

Definition at line 1011 of file ImportPdsTable.cpp.

References m_rows.

◆ setName()

void Isis::ImportPdsTable::setName ( const QString & name = "TABLE")

Set the name of the PDS table object.

Parameters
nameNew name for the PDS table object

Definition at line 98 of file ImportPdsTable.cpp.

References m_tableName, and name().

◆ setPdsByteOrder()

void Isis::ImportPdsTable::setPdsByteOrder ( QString byteOrder)
private

Sets the byte order for BINARY PDS table files.

This method is only used for BINARY PDS tables.

Parameters
byteOrderThe byte order of the PDS binary table. Valid values are "LSB" or "MSB".
Exceptions
IException::Unknown"Unable to import the binary PDS table [table name]. The column DATA_TYPE values indicate differing byte orders."

Definition at line 1191 of file ImportPdsTable.cpp.

References m_byteOrder, m_tableName, and Isis::IException::Unknown.

Referenced by makeFieldFromBinaryTable().

◆ setType()

bool Isis::ImportPdsTable::setType ( const QString & colName,
const QString & dataType )

Change the datatype for a column.

This method changes the data type the specified column. If the column can not be found, false is returned (indicating an unsuccessful change).

This method can be called for ASCII or BINARY PDS tables.

Author
2011-06-27 Kris Becker
Parameters
colNameName of column to change.
dtypeNew type of column. Support types are DOUBLE, REAL, INTEGER and CHARACTER. Unsupported/unknown types are treated as CHARACTER.
Returns
bool Indicates if the change was successful.

Definition at line 295 of file ImportPdsTable.cpp.

References findColumn(), and Isis::ImportPdsTable::ColumnDescr::m_dataType.

Member Data Documentation

◆ m_byteOrder

QString Isis::ImportPdsTable::m_byteOrder
private

The byte order of the PDS table file, if binary.

Valid values are "MSB" or "LSB".

Definition at line 201 of file ImportPdsTable.h.

Referenced by extractBinary(), init(), and setPdsByteOrder().

◆ m_coldesc

ColumnTypes Isis::ImportPdsTable::m_coldesc
private

◆ m_pdsTableFile

QString Isis::ImportPdsTable::m_pdsTableFile
private

The name of the file containing the table data.

Definition at line 199 of file ImportPdsTable.h.

Referenced by fillTable(), importTable(), init(), and load().

◆ m_pdsTableStart

int Isis::ImportPdsTable::m_pdsTableStart
private

The start byte of the PDS table data.

Definition at line 200 of file ImportPdsTable.h.

Referenced by fillTable(), init(), and load().

◆ m_pdsTableType

QString Isis::ImportPdsTable::m_pdsTableType
private

The INTERCHANGE_FORMAT value for the table.

Definition at line 195 of file ImportPdsTable.h.

Referenced by fillTable(), getColumnDescription(), init(), load(), loadLabel(), and makeField().

◆ m_recordBytes

int Isis::ImportPdsTable::m_recordBytes
private

The number of bytes for one Isis table record.

Definition at line 197 of file ImportPdsTable.h.

Referenced by fillTable(), and loadLabel().

◆ m_rowBytes

int Isis::ImportPdsTable::m_rowBytes
private

The number of bytes for one PDS table row.

Definition at line 196 of file ImportPdsTable.h.

Referenced by loadLabel().

◆ m_rows

Rows Isis::ImportPdsTable::m_rows
private

Table data.

Definition at line 194 of file ImportPdsTable.h.

Referenced by fillTable(), init(), loadTable(), processRow(), and rows().

◆ m_tableName

QString Isis::ImportPdsTable::m_tableName
private

The name of the PDS table object.

Definition at line 198 of file ImportPdsTable.h.

Referenced by getColumnName(), ImportPdsTable(), ImportPdsTable(), importTable(), importTable(), loadLabel(), name(), setName(), and setPdsByteOrder().

◆ m_trows

int Isis::ImportPdsTable::m_trows
private

Number rows in table according to label.

Definition at line 192 of file ImportPdsTable.h.

Referenced by fillTable(), init(), loadLabel(), and loadTable().


The documentation for this class was generated from the following files: