{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TemplateHaskell #-}
module Data.Geospatial.Internal.Geometry.GeoLine (
GeoLine(..)
, unGeoLine
) where
import Data.Geospatial.Internal.BasicTypes
import Data.Geospatial.Internal.Geometry.Aeson
import Data.LineString
import Control.DeepSeq
import Control.Lens (makeLenses)
import Control.Monad (mzero)
import Data.Aeson (FromJSON (..),
ToJSON (..),
Value (..))
import GHC.Generics (Generic)
newtype GeoLine = GeoLine { _unGeoLine :: LineString GeoPositionWithoutCRS } deriving (Show, Eq, Generic, NFData)
makeLenses ''GeoLine
instance ToJSON GeoLine where
toJSON = makeGeometryGeoAeson "LineString" . _unGeoLine
instance FromJSON GeoLine where
parseJSON (Object o) = readGeometryGeoAeson "LineString" GeoLine o
parseJSON _ = mzero