From f4794955c23d337ca25f44b771d574cc0ce970be Mon Sep 17 00:00:00 2001 From: stuebinm Date: Wed, 27 Aug 2025 00:29:17 +0200 Subject: rnv.bahnhof.name: draft --- app/Util.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'app/Util.hs') 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 -- cgit v1.2.3