diff options
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 |
