PDS_JP2
|
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>
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.13 2020/05/22 20:59:29)" |
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 | |
Parameter * | parameter_of (idaeim::PVL::Aggregate ¶meters, const char *name, bool throw_unless_found=true) |
Convenience parameter finder function that may throw an exception on failure. |
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.
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.
pathname | The pathname to the source file containing the PDS label. |
excluded_names | The NULL-terminated array of character strings naming data blocks to be excluded from conversion consideration. May be NULL. |
image_names | The 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. |
string product_names | ( | ) | const [virtual] |
Get the name of the product types that this converter is intended to process.
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.
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.
PDS_label_pathname | The pathname for the detached label file. |
JP2_pathname | The name of the JP2 image data file referened by the label file. |
removed_parameter_names | A 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_parameters | A pointer to PDS_Data that contains additional parameters with product-specific label conversion information. May be NULL. |
ios::failure | If 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.
PDS_label_pathname | The pathname for the file that begins with the converted PDS label. |
image_region | A 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_level | The 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_names | A 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_parameters | A pointer to PDS_Data that contains additional parameters with product-specific label conversion information. May be NULL. |
runtime_error | If the source label does not contain the expected parameters required to achieve the conversion. |
ios::failure | If 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 | An Aggregate reference that contains the parameters to be searched. |
name | The name of the parameter to find. The first parameter with a case insensitive matching name is selected. |
throw_unless_found | If 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. |
runtime_error | If a matching parameter name was not found and throw_unless_found is true. |
References UA::HiRISE::find_parameter(), ID, and Parameter::name().
const char *const ID = "UA::HiRISE::Generic_PDS_Converter (1.13 2020/05/22 20:59:29)" [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] |
{ RECORD_TYPE_PARAMETER_NAME, LABEL_RECORDS_PARAMETER_NAME, RECORD_BYTES_PARAMETER_NAME, FILE_RECORDS_PARAMETER_NAME, INTERCHANGE_FORMAT_PARAMETER_NAME, 0 }
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] |
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.