Add string handling for position

This commit is contained in:
2025-09-17 14:52:25 +02:00
parent 16e202e841
commit 6d30e25daa

View File

@@ -92,7 +92,16 @@ class MeasurementContainer {
if (!this._currentVariant) { if (!this._currentVariant) {
throw new Error('Variant must be specified before position'); throw new Error('Variant must be specified before position');
} }
// Turn string positions into numeric values
if (typeof positionValue == "string") {
positionValue = positionValue == "upstream" ? Number.NEGATIVE_INFINITY : positionValue;
positionValue = positionValue == "atEquipment" ? 0.0 : positionValue;
positionValue = positionValue == "downstream" ? Number.POSITIVE_INFINITY : positionValue;
}
this._currentPosition = positionValue; this._currentPosition = positionValue;
return this; return this;
} }