{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# 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.DeepSeq
import Control.Lens (makeLenses)
import Control.Monad (mzero)
import Data.Aeson (FromJSON (..),
ToJSON (..),
Value (..))
import qualified Data.Sequence as Sequence
import GHC.Generics (Generic)
newtype GeoMultiLine = GeoMultiLine { _unGeoMultiLine :: Sequence.Seq(LineString GeoPositionWithoutCRS) } deriving (Show, Eq, Generic, NFData)
makeLenses ''GeoMultiLine
splitGeoMultiLine:: GeoMultiLine -> Sequence.Seq GeoLine
splitGeoMultiLine = fmap GeoLine . _unGeoMultiLine
mergeGeoLines :: Sequence.Seq GeoLine -> GeoMultiLine
mergeGeoLines = GeoMultiLine . fmap _unGeoLine
instance ToJSON GeoMultiLine where
toJSON = makeGeometryGeoAeson "MultiLineString" . _unGeoMultiLine
instance FromJSON GeoMultiLine where
parseJSON (Object o) = readGeometryGeoAeson "MultiLineString" GeoMultiLine o
parseJSON _ = mzero