getField method
dynamic
getField(})
getField() Return requested field as a double (function return value) or as a text string (*pstr) in the units requested (eUnit). Set 'bStrUnits' to true to have units appended to text string.
Note: numeric return values are cached; asking for the same field more than once incurs minimal overhead.
Implementation
dynamic getField(
eField fld, {
eUnits units: eUnits.U_NATIVE,
/* = U_NATIVE */
String? pstr /* = NULL */,
bool bStrUnits: false /* = false */,
}) {
assert((eField.FLD_NORADNUM.index <= fld.index) &&
(fld.index < eField.FLD_LAST.index));
assert((eUnits.U_RAD.index <= units.index) &&
(units.index < eUnits.U_LAST.index));
if (pstr != null) {
// Return requested field in string form.
pstr = field[fld.index];
if (bStrUnits) {
pstr += getUnits(fld)!;
}
return pstr;
} else {
// Return requested field in floating-point form.
// Return cache contents if it exists, else populate cache
int key = Key(units, fld);
if (!mapCache.containsKey(key)) {
// Value not in cache; add it
double valNative = double.tryParse(field[fld.index])!;
double valConv = convertUnits(valNative, fld, units);
mapCache[key] = valConv;
return valConv;
} else {
// return cached value
return mapCache[key];
}
}
}