aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatarLarge Libravatar memdmp <memdmpestrogenzone>2025-07-11 12:31:21 +0200
committerLibravatarLarge Libravatar memdmp <memdmpestrogenzone>2025-07-11 12:31:21 +0200
commitedeb3dfc7a02717b08dbd3118d9b0c932df3fcd8 (patch)
tree45a0a46eee438efb05c44e42e467e8b79cb72666
parent34ab1e0c3573aa9b79fc02f934fdf82c0acd9c9b (diff)
downloaduic-parse-edeb3dfc7a02717b08dbd3118d9b0c932df3fcd8.tar.gz
uic-parse-edeb3dfc7a02717b08dbd3118d9b0c932df3fcd8.tar.bz2
uic-parse-edeb3dfc7a02717b08dbd3118d9b0c932df3fcd8.tar.lz
uic-parse-edeb3dfc7a02717b08dbd3118d9b0c932df3fcd8.zip

fix: for switzerland, vehicleFamily is only split for EMUs

-rw-r--r--lib.ts7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib.ts b/lib.ts
index e05e937..a573fa6 100644
--- a/lib.ts
+++ b/lib.ts
@@ -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 {