diff options
| author | stuebinm | 2025-08-27 00:29:17 +0200 |
|---|---|---|
| committer | stuebinm | 2026-01-01 19:58:42 +0100 |
| commit | f4794955c23d337ca25f44b771d574cc0ce970be (patch) | |
| tree | 8e11c0e2cae5dc9b7329d24c3b81919422db7c83 /app/Util.hs | |
| parent | dabe335b06145f39ea36f4841459cbf5c213be14 (diff) | |
rnv.bahnhof.name: draft
Diffstat (limited to 'app/Util.hs')
| -rw-r--r-- | app/Util.hs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/Util.hs b/app/Util.hs index ce3dcbc..094f229 100644 --- a/app/Util.hs +++ b/app/Util.hs @@ -33,6 +33,7 @@ data StaticAppData = StaticAppData { ril100map :: DoubleMap Ril100 Text , leitpunktMap :: DoubleMap Ril100 Text , ril100set :: FuzzySet + , rnvMap :: DoubleMap RnvId Text } data DoubleMap code long = DoubleMap @@ -58,6 +59,8 @@ findStationName query set = case sorted of newtype Ril100 = Ril100 { unRil100 :: Text } deriving (Eq, Ord, Show) +newtype RnvId = RnvId { unRnv :: Text } + deriving (Eq, Ord, Show) lookupCode :: Ord code => code -> DoubleMap code long -> Maybe long lookupCode code maps = M.lookup code (there maps) @@ -83,11 +86,19 @@ readLeitpunktMap = do <&> decodeWith csvOptions HasHeader return $ mkDoubleMap $ fmap (\line -> (Ril100 (line !! 2), line !! 0)) leitpunkte +readRnvMap :: IO (DoubleMap RnvId Text) +readRnvMap = do + Right (rnv :: V.Vector [Text]) <- + LB.readFile "data/rnv.csv" + <&> decode NoHeader + return $ mkDoubleMap $ fmap (\line -> (RnvId (line !! 1), line !! 0)) rnv + readData :: IO StaticAppData readData = do putStrLn "Parsing input .csv files…" betriebsstellen <- readBetriebsstellen leitpunktMap <- readLeitpunktMap + rnvMap <- readRnvMap putStrLn "Static data ready." let betriebsstellenFiltered = betriebsstellen |
