Name

DumpCurves — Extract curves from a ForestModel XML file, and saves the values in CSV format.

Synopsis

Synopsis

ca.spatial.tracks.builder.DumpCurves {xml} {selectExpr} {labelExpr} {output}
      

Arguments

NameTypeDefault
xml The name of the ForestModel XML input file containing the curve data to be extracted None
selectExpr An XPath query that identifies the set of curves to be extracted. This query must return a true or false value. None
labelExpr An XPath query that identifies the labels to be used to identify the selected curves. This query must return strings that will be used as column headings in the CSV file. None
output The name of the output file to store the result None

Description

This program reads a ForestModel XML file, selects specified curve definitions, and writes the values to a CSV file in table format. This program is useful for extracting the original data from an already built model, when the original source documents are not available.

The curves to extract and the labels to be used for each curve are defined using XPath queries. XPath is a flexible and concise query language designed specifically for dealing with XML. Consult the authoratitive documentation on the web for a full explanation of the capabilities of the XPath query language.

Processing Notes

There will be a row in the output table for every unique X values found in all of the sets of curves. Cell values are only written when the curve has a y-value defined at that x-value, otherwise, the cell is left empty.

Examples

Assume that the following XML file is provided as input (only part of the file is shown for brevity). The elipses indicate portions of the file that may have been omitted.

<ForestModel ...>
  ...

  <attributes id="Seral.D" >
    <attribute label = "%f.Seral.%m.Estab">
      <curve>
        <point x="1" y="1"/>
        <point x="10" y="1"/>
        <point x="11" y="0"/>
      </curve>
    </attribute>
    <attribute label = "%f.Seral.%m.Overmat">
      <curve>
        <point x="0" y="0"/>
        <point x="100" y="0"/>
        <point x="101" y="1"/>
      </curve>
    </attribute>
  </attributes>

  <attributes id="Yield.AW_COMP">
    <attribute label="%f.Volume.%m.Conif">
      <curve>
        <point x="0" y="0.0" />
        ...
      </curve>
    </attribute>
    <attribute label="%f.Volume.%m.Decid">
      <curve>
        <point x="5" y="0.8929" />
        ...
      </curve>
    </attribute>
  </attributes>
  ...

</ForestModel>
    

Given this input, the following command may be run

java -jar patchworks.jar ca.spatial.tracks.builder.DumpCurves  \
        ForestModel.xml \
        //attributes[starts-with(@id,"Yield")]//curve \
        concat(substring-after(../../@id,"."),substring(../@label,13)) \
        output.csv
    

In this example the reselect expression identifies all curve elements where the enclosing attributes section has an id value that starts with "Yield". The label expression makes a concatenation of second part of the parent element (the "attribute" element) id (everything after the first "." character) with everything after the 13th character of the grandparent element (the "attributes" element) label value. The output file created for this example is as follows:

Age,AW_COMP.Conif,AW_COMP.Decid
0,0,
5,,0.8929
    

The above example shows the command line usage for the tool. More typically the tool will be invoke using a wizard that will prompt for parameters.