ProParser Class
Snowpack PRO file parser. A PRO file is parsed line by line in a single pass (supports streamed data).
Constructor
ProParser
()
Item Index
Methods
Methods
check
-
against
against
.
Parameters:
-
against
String
Returns:
convert
-
id
-
value
Looks up the converter for type of id
and converts
the value; throws an error if there is no
suitable converter available.
end
()
chainable
getcodes
()
Object
static
Get the conversion table which is a key/value object, key being the PRO file code and the value being the property name used within niViz.
Returns:
next
()
String | Undefined
Returns:
parse
-
[callback]
end
and error
events.
Parameters:
-
[callback]
Function optional
Returns:
parse_data
()
private
chainable
Parses profile data and adds it to the station.
This method consumes lines until a property id repeats or the following line does not start with an id.
parse_header
-
id
-
type
-
description
Parses a profile header line and registers the
property and the corresponding value converter
function in properties
.
Note: Since header definitions can span multiple lines, this method peeks ahead and consumes subsequent indented lines!
parse_line
-
line
Lexically analyses a line and parses it accordingly.
Note: When strict parsing is active (default), this method will reject out-of-section lines even if they are syntactically correct (e.g., header definitions outside of a header section).
Parameters:
-
line
String
parse_parameter
()
private
chainable
pause
()
restrict
-
mode
Ensure that the current mode is mode
; throws
an Error otherwise.
Note: Does not throw if .strict
is set to false.
Parameters:
-
mode
String
Returns:
Whether or not mode
is current.
sanitize
-
tops
Take all the layer tops and create three arrays: one with all the layer bottoms, one with all the tops above ground, and one with all the bottoms above ground.
Parameters:
-
tops
ArrayThe layer tops
Returns:
Object with three arrays: bottoms, above0 and bottoms0
skip
-
[until]
Returns the next line that is not a blank line
or comment; if given, the next line that starts
with until
is treated like EOD.
Parameters:
-
[until]
String optional
Returns:
The next line.
verify
()
chainable
Properties
_parse
Unknown
codes
Config
static
Default conversion table for PRO property codes to names used by Niviz. Editable by the user.
dates
ArrayA list of date/time formats recognized by the parser.
mode
String
The current parsing mode. The mode corresponds to the different sections in a PRO file:
- 'station_parameters'
- 'header'
- 'data'
station
Station
The snow station instance; the instance should be populated by the parsing methods and represents the parse result.
trim
String
types
ArrayA list of all known data value types.
For each type, there is a corresponding
parser/converter in .converters
.