HiRISE
 PDS_JP2

Public Member Functions | Static Public Attributes | Protected Member Functions

Generic_PDS_Converter Class Reference

A Generic_PDS_Converter is used to convert a generic image data product PDS label between its attached PDS form and its detached PDS/JP2 form. More...

#include <Generic_PDS_Converter.hh>

Inheritance diagram for Generic_PDS_Converter:
Inheritance graph
[legend]
Collaboration diagram for Generic_PDS_Converter:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Generic_PDS_Converter ()
 Constructs an empty Generic_PDS_Converter.
 Generic_PDS_Converter (const std::string &pathname, const char **excluded_names=NULL, const char **image_names=NULL)
 Constructs a Generic_PDS_Converter from a named file.
std::string product_names () const
 Get the name of the product types that this converter is intended to process.
bool label_recognized () const
 Test whether the label parameters are recognized by this converter.
void write_PDS_JP2_label (const std::string &PDS_label_pathname, const std::string &JP2_pathname, const char **removed_parameter_names=NULL, PDS_Data *additional_parameters=NULL)
 Write a detached PDS/JP2 label file.
void write_PDS_label (const std::string &PDS_label_pathname, const Rectangle *image_region=NULL, unsigned int resolution_level=1, const char **removed_parameter_names=NULL, PDS_Data *additional_parameters=NULL)
 Write a PDS label for image data to be appended.

Static Public Attributes

static const char *const ID = "UA::HiRISE::Generic_PDS_Converter (1.11 2009/10/01 06:05:35)"
 Class identification name with source code version and date.
static const char * PRODUCT_TYPE = "generic"
 The PDS product type name.
static const char * DATA_POINTER_PARAMETER_UNITS = "BYTES"
 Units of parameters pointing to data blocks.
static const char * REMOVED_PDS_PARAMETER_NAMES []
 Names of parameters to be removed from the copy of the source PDS label when generating the converted PDS/JP2 label.
static const char * REMOVED_PDS_JP2_PARAMETER_NAMES []
 Names of parameters to be removed from the copy of the source PDS/JP2 label when generating the converted PDS label.
static const int DEFAULT_PDS_LABEL_SIZE = 2048
 Default size (bytes) of an attached PDS label.

Protected Member Functions

Parameterparameter_of (idaeim::PVL::Aggregate &parameters, const char *name, bool throw_unless_found=true)
 Convenience parameter finder function that may throw an exception on failure.

Detailed Description

A Generic_PDS_Converter is used to convert a generic image data product PDS label between its attached PDS form and its detached PDS/JP2 form.

N.B.: Only the IMAGE description is modified; no product-specific modfications are made. Thus this class is intended as a catch-all PDS_Converter implementation.

Author:
Bradford Castalia, UA/HiROC
Version:
1.9
See also:
PDS_Converter

Constructor & Destructor Documentation

Constructs an empty Generic_PDS_Converter.

Generic_PDS_Converter ( const std::string &  pathname,
const char **  excluded_names = NULL,
const char **  image_names = NULL 
) [explicit]

Constructs a Generic_PDS_Converter from a named file.

The PDS file may contain an attached PDS label or be a detached PDS/JP2 label file. Either the write_PDS_label or write_PDS_JP2_label methods can be used to convert either source, respectively.

Parameters:
pathnameThe pathname to the source file containing the PDS label.
excluded_namesThe NULL-terminated array of character strings naming data blocks to be excluded from conversion consideration. May be NULL.
image_namesThe NULL-terminated array of character strings naming data blocks that describe image data. N.B.: The PDS_Data::IMAGE_DATA_BLOCK_NAME is always implicitly included. May be NULL.

Member Function Documentation

string product_names (  ) const [virtual]

Get the name of the product types that this converter is intended to process.

Returns:
Always returns the "generic".

Reimplemented from PDS_Converter.

Reimplemented in HiPrecision_PDS_Converter, and HiRISE_PDS_Converter.

bool label_recognized (  ) const [virtual]

Test whether the label parameters are recognized by this converter.

The test will succeed if an image data block is found in the source file label.

Returns:
true if the label parameters are recognized by this converter; false otherwise.

Implements PDS_Converter.

Reimplemented in HiPrecision_PDS_Converter, and HiRISE_PDS_Converter.

void write_PDS_JP2_label ( const std::string &  PDS_label_pathname,
const std::string &  JP2_pathname,
const char **  removed_parameter_names = NULL,
PDS_Data additional_parameters = NULL 
) [virtual]

Write a detached PDS/JP2 label file.

A copy is made of the source label represented by the Parameter Aggregate of the PDS_Converter base class. The parameters with the REMOVED_PDS_PARAMETER_NAMES are removed from the new label parameters. If a removed_parameter_names list is provided these additional parameters are also removed. In addition, any data block groups are removed. N.B.: If applied to a HiRISE EDR data product all the binary data blocks will be dropped; this may not be what is desired.

The new image file parameter groups are then added to the label, after any Image_Data_Block::LINE_PREFIX_BYTES_PARAMETER_NAME or Image_Data_Block::LINE_SUFFIX_BYTES_PARAMETER_NAME parameters have been removed (N.B.: This assumes that the JP2_Encoder does not include line prefix or suffix bytes when processing the image data block). These parameters replace the original image data block parameters.

The new PDS label file is then written with PDS standard label formatting applied.

Parameters:
PDS_label_pathnameThe pathname for the detached label file.
JP2_pathnameThe name of the JP2 image data file referened by the label file.
removed_parameter_namesA NULL terminated array of character strings that are the names of parameters to be removed from the source label before being written. May be NULL.
additional_parametersA pointer to PDS_Data that contains additional parameters with product-specific label conversion information. May be NULL.
Exceptions:
ios::failureIf the label file could no be created.

Implements PDS_Converter.

Reimplemented in HiPrecision_PDS_Converter, and HiRISE_PDS_Converter.

References UA::HiRISE::absolute_pathname(), Aggregate::move_in(), Parameter::name(), Parameter::pathname(), and PDS_Data::remove_parameter().

void write_PDS_label ( const std::string &  PDS_label_pathname,
const Rectangle image_region = NULL,
unsigned int  resolution_level = 1,
const char **  removed_parameter_names = NULL,
PDS_Data additional_parameters = NULL 
) [virtual]

Write a PDS label for image data to be appended.

A copy is made of the source label represented by the Parameter Aggregate of the PDS_Converter base class. The parameters with the REMOVED_PDS_JP2_PARAMETER_NAMES are removed from the new label parameters. If a removed_parameter_names list is provided these additional parameters are also removed.

Immediately following the PDS_Data::PDS_ID_PARAMETER_NAME parameter a PDS_Data::RECORD_TYPE_PARAMETER_NAME parameter with the BYTE_RECORD_TYPE value is inserted. This is followed by a PDS_Data::LABEL_RECORDS_PARAMETER_NAME parameter with the DEFAULT_PDS_LABEL_SIZE value. Next a PDS_Data::IMAGE_DATA_BLOCK_NAME parameter with a PDS_Data::RECORD_POINTER_PARAMETER_MARKER prefix with a value of DEFAULT_PDS_LABEL_SIZE + 1 is inserted.

The original image data block parameters are copied and the Image_Data_Block::IMAGE_WIDTH_PARAMETER_NAME and Image_Data_Block::IMAGE_HEIGHT_PARAMETER_NAME parameter values are changed to the image width and image height values, respectively. The modified image data block parameters are then appended to the modified label parameters.

The new PDS label file is then written with PDS standard label formatting applied. The file is appended with space characters to pad out the DEFAULT_PDS_LABEL_SIZE. If the size of the label is greater than the DEFAULT_PDS_LABEL_SIZE, then it is rewritten with a size expanded to the next 2K byte increment and the PDS_Data::LABEL_RECORDS_PARAMETER_NAME and Image_Data_Block::IMAGE_HEIGHT_PARAMETER_NAME pointer parameter values adjusted accordingly.

Parameters:
PDS_label_pathnameThe pathname for the file that begins with the converted PDS label.
image_regionA Rectangle pointer that specifies a region within the image that was rendered. N.B.: The rendered image region is specifed after any resolution change has been applied (don't just shift the full resolution image region by the resolution level, which may be inaccurate, get the rendered image size from the JP2 decoder). If NULL, the entire image was selected.
resolution_levelThe resolution level at which the image is rendereed from the JP2 codestream is rendered. 1 is full resolution, 2 is half resolution, 3 is quarter resolution, etc.; i.e. the rendering scale is 1 / (2**(L - 1)).
removed_parameter_namesA NULL terminated array of character strings that are the names of parameters to be removed from the source label before being written. May be NULL.
additional_parametersA pointer to PDS_Data that contains additional parameters with product-specific label conversion information. May be NULL.
Exceptions:
runtime_errorIf the source label does not contain the expected parameters required to achieve the conversion.
ios::failureIf the label file could no be created.

Implements PDS_Converter.

Reimplemented in HiPrecision_PDS_Converter, and HiRISE_PDS_Converter.

References UA::HiRISE::absolute_pathname(), Aggregate::add(), Vectal< T >::begin(), Vectal< T >::end(), Size_2D::Height, ID, Vectal< T >::insert(), UA::HiRISE::label_lister(), Parameter::name(), Parameter::pathname(), PDS_Data::remove_parameter(), Lister::total(), Parameter::value(), Size_2D::Width, Point_2D::X, and Point_2D::Y.

Parameter * parameter_of ( idaeim::PVL::Aggregate parameters,
const char *  name,
bool  throw_unless_found = true 
) [protected]

Convenience parameter finder function that may throw an exception on failure.

Parameters:
parametersAn Aggregate reference that contains the parameters to be searched.
nameThe name of the parameter to find. The first parameter with a case insensitive matching name is selected.
throw_unless_foundIf true, a runtime_error will be thrown if a matching parameter name is not found; otherwise a NULL value will be returned in this case.
Returns:
A pointer to the Parameter that was found. This will be NULL if a matching parameter name was not found and throw_unless_found is false.
Exceptions:
runtime_errorIf a matching parameter name was not found and throw_unless_found is true.

References UA::HiRISE::find_parameter(), ID, and Parameter::name().


Member Data Documentation

const char *const ID = "UA::HiRISE::Generic_PDS_Converter (1.11 2009/10/01 06:05:35)" [static]

Class identification name with source code version and date.

Reimplemented from PDS_Converter.

Reimplemented in HiPrecision_PDS_Converter, and HiRISE_PDS_Converter.

const char * PRODUCT_TYPE = "generic" [static]

The PDS product type name.

const char * DATA_POINTER_PARAMETER_UNITS = "BYTES" [static]

Units of parameters pointing to data blocks.

const char * REMOVED_PDS_PARAMETER_NAMES [static]
Initial value:

Names of parameters to be removed from the copy of the source PDS label when generating the converted PDS/JP2 label.

const char * REMOVED_PDS_JP2_PARAMETER_NAMES [static]
Initial value:

Names of parameters to be removed from the copy of the source PDS/JP2 label when generating the converted PDS label.

const int DEFAULT_PDS_LABEL_SIZE = 2048 [static]

Default size (bytes) of an attached PDS label.

Reimplemented in HiPrecision_PDS_Converter, and HiRISE_PDS_Converter.


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