|
Project Information
|
This project has moved to github https://github.com/tonymorris/geo-osmA library for parsing OpenStreetMap files using HXT into data structures. Download from hackage at http://hackage.haskell.org/package/OSM or install by cabal-install. > cabal install OSM ExampleExtract Camp SitesThis example returns all nodes tagged as camp-sites (tourism=camp_site) in the given OSM file. import Data.Geo.OSM
campSites :: FilePath -> IO [Node]
campSites f = let p = filter ("tourism" `hasTagValue` "camp_site") . (nodes =<<)
in fmap p (readOsmFile f)ExampleFix way tagsUpdates the given OSM file with a new OSM file by replacing specific suffixes of ways tagged with "name". e.g. A way such as name="George St" will become name="George Street" and name="Wickham Tce" will become name="Wickham Terrace". import Data.Geo.OSM
import Data.List
wayTags :: FilePath -> FilePath -> IO ()
wayTags = interactsOSM [" St" ==> " Street",
" Pl" ==> " Place",
" Tce" ==> " Terrace",
" Cct" ==> " Circuit"]
-- Updates the a given name suffix with a new suffix
(==>) :: (NodeWayRelations a)
=> String -- The suffix to fix with the new suffix.
-> String -- The new suffix.
-> a -- The OSM value.
-> a -- The new OSM value.
(==>) x = usingWay . usingTag' . (\y (k, v) ->
let v' = reverse v
in (k, if k == "name" && reverse x `isPrefixOf` v'
then reverse (reverse y ++ drop (length x) v')
else v))Links |