module Data.Geo.OSM.NodeWayRelation(
NodeWayRelation,
foldNodeWayRelation,
way',
relation',
node',
isNode,
isWay,
isRelation
) where
import Text.XML.HXT.Arrow
import Text.XML.HXT.Extras
import Data.Geo.OSM.Node
import Data.Geo.OSM.Way
import Data.Geo.OSM.Relation
data NodeWayRelation = N Node | W Way | R Relation
deriving Eq
foldNodeWayRelation :: NodeWayRelation
-> (Node -> x)
-> (Way -> x)
-> (Relation -> x)
-> x
foldNodeWayRelation (N n) x _ _ = x n
foldNodeWayRelation (W w) _ x _ = x w
foldNodeWayRelation (R r) _ _ x = x r
instance XmlPickler NodeWayRelation where
xpickle = xpAlt (\r -> case r of N _ -> 0
W _ -> 1
R _ -> 2)
[xpWrap (N, \(N n) -> n) xpickle, xpWrap (W, \(W w) -> w) xpickle, xpWrap (R, \(R r) -> r) xpickle]
instance Show NodeWayRelation where
show = showPickled []
way' :: Way -> NodeWayRelation
way' = W
relation' :: Relation -> NodeWayRelation
relation' = R
node' :: Node -> NodeWayRelation
node' = N
isNode :: NodeWayRelation -> Bool
isNode (N _) = True
isNode _ = False
isWay :: NodeWayRelation -> Bool
isWay (W _) = True
isWay _ = False
isRelation :: NodeWayRelation -> Bool
isRelation (R _) = True
isRelation _ = False