MetarSeaState constructor
MetarSeaState(
- String? code,
- RegExpMatch? match
Implementation
MetarSeaState(super.code, RegExpMatch? match) {
if (match != null) {
final sign = match.namedGroup('sign');
final temp = match.namedGroup('temp');
final state = match.namedGroup('state');
final height = match.namedGroup('height');
if (<String>['M', '-'].contains(sign)) {
_temperature = Temperature('-$temp');
} else {
_temperature = Temperature(temp);
}
_state = seaState[state];
late final double? heightAsDouble;
try {
heightAsDouble = int.parse('$height') / 10;
} catch (e) {
heightAsDouble = null;
} finally {
_height = Distance('$heightAsDouble');
}
}
}