aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/aliases.ts
diff options
context:
space:
mode:
authorLibravatarLarge Libravatar memdmp <memdmpestrogenzone>2025-09-14 18:12:53 +0200
committerLibravatarLarge Libravatar memdmp <memdmpestrogenzone>2025-09-14 18:12:53 +0200
commit75c9e412287ace0801d752ce731824243d7c8b53 (patch)
tree3e0361f64f277ef3978725a9fdf4b8632c231ca0 /src/lib/aliases.ts
parent53e3544effa012d36f3b0d732a922ca219b7692a (diff)
downloadfahrplan-75c9e412287ace0801d752ce731824243d7c8b53.tar.gz
fahrplan-75c9e412287ace0801d752ce731824243d7c8b53.tar.bz2
fahrplan-75c9e412287ace0801d752ce731824243d7c8b53.tar.lz
fahrplan-75c9e412287ace0801d752ce731824243d7c8b53.zip

feat: small changes

Diffstat (limited to 'src/lib/aliases.ts')
-rw-r--r--src/lib/aliases.ts26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/lib/aliases.ts b/src/lib/aliases.ts
index c954f56..7308315 100644
--- a/src/lib/aliases.ts
+++ b/src/lib/aliases.ts
@@ -1,5 +1,6 @@
import { m } from './paraglide/messages';
+// #region Stations
export const placeNameMap = new Map<string, string>();
for (const [v1, v2] of [
['Freiburg(Brsg)', 'Freiburg(Breisgau) Hbf'],
@@ -15,8 +16,32 @@ for (const [v1, v2] of [
['Freiburg Hauptbahnhof', 'Freiburg(Breisgau) Hbf'],
['S+U Berlin Hauptbahnhof', 'Berlin Hbf'],
['Berlin Hauptbahnhof', 'Berlin Hbf'],
+ ['Hauptbahnhof (oben)', 'Stuttgart Hbf (oben)'], // probably
+ ['de-DELFI_de:08111:6115:1:1', 'Stuttgart Hbf (oben)'],
])
placeNameMap.set(v1.toLowerCase(), v2);
+
+export const normaliseGermanUmlauts = (n: string) => {
+ return n
+ .replace(/ü/gu, 'ue')
+ .replace(/Ü/gu, 'UE')
+ .replace(/ä/gu, 'ae')
+ .replace(/Ä/gu, 'AE')
+ .replace(/ö/gu, 'oe')
+ .replace(/ß/gu, 'ss');
+};
+export const normalisePlaceName = (name: string, id?: string) =>
+ placeNameMap.has(name.toLowerCase())
+ ? placeNameMap.get(name.toLowerCase())!
+ : id && placeNameMap.has(id)
+ ? placeNameMap.get(id)!
+ : name;
+export const arePlacenamesEqual = (n1: string, n2: string) =>
+ normalisePlaceName(normaliseGermanUmlauts(n1).toUpperCase()).toUpperCase() ===
+ normalisePlaceName(normaliseGermanUmlauts(n2)).toUpperCase();
+// #endregion
+
+// #region Operators
export const operators = new Map<string, string>();
operators.set('Schweizerische Bundesbahnen SBB', m.operator_sbb());
operators.set('SBB', m.operator_sbb());
@@ -37,3 +62,4 @@ operators.set('Verkehrsbetriebe Glattal', m.operator_vbg());
operators.set('OEBB Personenverkehr AG Kundenservice', m.operator_oebb());
operators.set('Österreichische Bundesbahnen', m.operator_oebb());
+// #endregion