{-# LANGUAGE TemplateHaskell #-}
module Data.Geospatial.Internal.Geometry.GeoMultiLine (
GeoMultiLine(..)
, unGeoMultiLine
, splitGeoMultiLine, mergeGeoLines
) where
import Data.Geospatial.Internal.BasicTypes
import Data.Geospatial.Internal.Geometry.Aeson
import Data.Geospatial.Internal.Geometry.GeoLine
import Data.LineString
import Control.Lens (makeLenses)
import Control.Monad (mzero)
import Data.Aeson (FromJSON (..),
ToJSON (..),
Value (..))
newtype GeoMultiLine = GeoMultiLine { _unGeoMultiLine :: [LineString GeoPositionWithoutCRS] } deriving (Show, Eq)
makeLenses ''GeoMultiLine
splitGeoMultiLine:: GeoMultiLine -> [GeoLine]
splitGeoMultiLine = map GeoLine . _unGeoMultiLine
mergeGeoLines :: [GeoLine] -> GeoMultiLine
mergeGeoLines = GeoMultiLine . map _unGeoLine
instance ToJSON GeoMultiLine where
toJSON = makeGeometryGeoAeson "MultiLineString" . _unGeoMultiLine
instance FromJSON GeoMultiLine where
parseJSON (Object o) = readGeometryGeoAeson "MultiLineString" GeoMultiLine o
parseJSON _ = mzero