diff options
fix: for switzerland, vehicleFamily is only split for EMUs
-rw-r--r-- | lib.ts | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -139,10 +139,13 @@ export default class UICVehicle<Operator extends string | null, Country extends return UICVehicle.getSelfCheckDigit(this.vehicleType + (this.country?.uicIdentifier ?? this.countryCode) + this.vehicleFamily + this.serialNumber).toString() as Digit } public toString() { - // Separation of first character of vehicleFamily is typically done in Switzerland for SBB and BLS (although not Thurbo?) - and not in germany, unsure about elsewhere const cc = this.country?.uicIdentifier ?? this.countryCode; const ccstr = (this.country?.treatyShort ?? UICCountry.countryMaps.byUICIdentificationNumber.get(this.countryCode!)?.treatyShort ?? null) - return `${this.vehicleType} ${cc} ${cc === '85' ? `${this.vehicleFamily.charAt(1) + ' ' + this.vehicleFamily.substring(1)}` : this.vehicleFamily} ${this.serialNumber} ${this.getSelfCheckDigit()}${ccstr && this.operator ? ` ${ccstr}-${this.operator}` : ''}` + // Separation of first character of vehicleFamily for is typically done in Switzerland for SBB and BLS (although not Thurbo?) for their EMUs (first digit often signifying wagon, 0 for entire vehicle) - and not in germany, unsure about elsewhere + return `${this.vehicleType} ${cc} ${cc === '85' && [ + // TODO: figure out if 5 is a reserved prefix (if so, where is it specified) for EMUs + '500', '501', '502', '503', '510', '511', '512', '514', '515', '520', '521', '522', '523', '524', '525', '526', '528', '535', '565', '566' + ].includes(this.vehicleFamily.substring(1)) ? `${this.vehicleFamily.charAt(1) + ' ' + this.vehicleFamily.substring(1)}` : this.vehicleFamily} ${this.serialNumber} ${this.getSelfCheckDigit()}${ccstr && this.operator ? ` ${ccstr}-${this.operator}` : ''}` } public toJSON() { return { |