The Generate Tool leverages Apache Velocity Templates to provide a robust, generic method of creating PDS4 Labels. The labels can be generated from an existing PDS3 label (attached or detached) or some other defined data object. This section contains the various scenarios that the base version of the tool handles. Scenarios, in this context, can be defined as the specific types of problems a user may come across when attempting to develop a PDS4 label. These will be extended as the the data objects and PDS4 standard become more refined.
This section contains the following information:
Each scenario described below will follow a format in order to provide a tutorial-like experience when developing a PDS4 label. The progression through a scenario will include a problem description, PDS3 label input (if applicable), the desired PDS4 output, and the Velocity Template solution.
PDS3 (if applicable) (pds3_example.lbl)PDS3 Label Input
PDS4 XML Output
Velocity Template Solution
The scenarios provided are some of the problems elicited from translating from data objects, specifically PDS3 standard, into PDS4. They are by no means all inclusive. These solutions are NOT PDS4-compliant, they are simply proof-of-concept examples to prove the functionality of the tool and how they can be applied to PDS4-compliant labels.
Allows the user to specify default values for a tag.
PDS4<Product_Array_2D_Image> <Data_Standards> <dd_version_id>0311B_20110709</dd_version_id> </Data_Standards> </Product_Array_2D_Image>
<Product_Array_2D_Image> <Data_Standards> <dd_version_id>0311B_20110709</dd_version_id> </Data_Standards> </Product_Array_2D_Image>
Provides a mechanism for translating base elements from PDS3 to PDS4. A base element in a PDS3 label is a KEYWORD-VALUE that is not a part of an OBJECT or GROUP. Often seen flush up against the left side of the label file.
PDS3TARGET_NAME = "DEIMOS"
<Subject_Area> <target_name>DEIMOS</target_name> </Subject_Area>
<Subject_Area> <target_name>$label.TARGET_NAME</target_name> </Subject_Area>
Provides a mechanism for translating sub-elements from PDS3 to PDS4. A sub-element in a PDS3 label is a KEYWORD-VALUE that is included within an OBJECT or GROUP.
PDS3OBJECT = IMAGE MEAN = 8.6319 MEDIAN = 8 MINIMUM = 8 END_OBJECT = IMAGE
<Object_Statistics> <mean>8.6319</maximum> <median>8</mean> <minimum>8</median> </Object_Statistics>
<Object_Statistics> <mean>$label.IMAGE.MEAN</mean> <median>$label.IMAGE.MEDIAN</median> <minimum>$label.IMAGE.MINIMUM</minimum> </Object_Statistics>
Note: For keywords within nested OBJECTs/GROUPs, simply continue the dot notation, i.e. $label.OBJECT1.OBJECT2.KEYWORD
Provides a mechanism for translating PDS3 Keywords with an array of values into multiple instances of a PDS4 class.
PDS3GROUP = BAND_BIN BANDS = 4 BAND_BIN_UNIT = MICROMETER CENTER = (0.374, 0.384, 0.394, 0.404) WIDTH = (0.0155, 0.0115, 0.0114, 0.0112) END_GROUP = BAND_BIN
<Band_Bin_Set> <Band_Bin> <center>0.374</center> <width>0.0155</width> </Band_Bin> <Band_Bin> <center>0.384</center> <width>0.0115</width> </Band_Bin> <Band_Bin> <center>0.394</center> <width>0.0114</width> </Band_Bin> <Band_Bin> <center>0.404</center> <width>0.0112</width> </Band_Bin> </Band_Bin_Set>
<!-- Scenario 4 - Multiple Instances --> <Band_Bin_Set> <!-- Get size of one of the arrays from the PDS3 Label --> #set($length = $label.BAND_BIN.CENTER.size()) <!-- Loop through the length of the array --> #foreach ( $i in [1..$length] ) <Band_Bin> <center>$label.BAND_BIN.CENTER.get($foreach.index)</center> <width>$label.BAND_BIN.WIDTH.get($foreach.index)</width> </Band_Bin> #end </Band_Bin_Set>
Provides a mechanism for translating multiple KEYWORD-VALUE combinations into multiple instances of the same class.
PDS3OBJECT = IMAGE INTERCHANGE_FORMAT = BINARY LINES = 192 LINE_SAMPLES = 320 END_OBJECT = IMAGE
<Array_Axis> <name>SAMPLES</name> <elements>320</elements> <sequence_number>1</sequence_number> </Array_Axis> <Array_Axis> <name>LINES</name> <elements>192</elements> <sequence_number>2</sequence_number> </Array_Axis>
<Array_Axis> <name>SAMPLES</name> <elements>$label.IMAGE.LINE_SAMPLES</elements> <sequence_number>1</sequence_number> </Array_Axis> <Array_Axis> <name>LINES</name> <elements>$label.IMAGE.LINES</elements> <sequence_number>2</sequence_number> </Array_Axis>
Provides a mechanism for translating a PDS3 KEYWORD-VALUE along with its units into PDS4 standard.
PDS3INST_AZIMUTH = 114.0210 <deg>
<Geometry_Parameters> <azimuth units="deg">114.0210</azimuth> </Geometry_Parameters>
<Geometry_Parameters> <azimuth units="$label.getUnits('INST_AZIMUTH')">$label.INST_AZIMUTH</azimuth> </Geometry_Parameters>
Provides a mechanism for generating values of keywords from known algorithms. This aspect of the software can be extended, if necessary.
PDS4<File_Area> <md5_checksum>2a6f0be7f63d0aa032457f1f29d3e51d</md5_checksum> </File_Area>
<File_Area> <md5_checksum>$generate.md5_checksum</md5_checksum> </File_Area>
Note: The currently available generated values include:
The following examples are NOT finished products or follow PDS4 standards. They are merely proof-of-concept.
<generated-node>Object Not Found</generated-node>
When a node is populated with the text "Object Not Found", it means that the keyword specified was not found. This error applies to generated values and often means that either the mapping was not specified in the generated-mappings.xml, or the class was never created to generate that value
See the Velocity User Guide for more detailed documentation on leveraging the Java objects represented by the variables noted above (label, bandBinList, etc.).