{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TemplateHaskell #-}
module Data.Geospatial.Internal.Geometry.GeoPolygon (
GeoPolygon(..)
, unGeoPolygon
) where
import Control.DeepSeq
import Control.Lens (makeLenses)
import Control.Monad (mzero)
import qualified Data.Aeson as Aeson
import Data.Geospatial.Internal.BasicTypes
import Data.Geospatial.Internal.Geometry.Aeson
import qualified Data.LinearRing as LinearRing
import qualified Data.Sequence as Sequence
import GHC.Generics (Generic)
newtype GeoPolygon = GeoPolygon { _unGeoPolygon :: Sequence.Seq (LinearRing.LinearRing GeoPositionWithoutCRS) } deriving (Show, Eq, Generic, NFData)
makeLenses ''GeoPolygon
instance Aeson.ToJSON GeoPolygon where
toJSON = makeGeometryGeoAeson "Polygon" . _unGeoPolygon
instance Aeson.FromJSON GeoPolygon where
parseJSON (Aeson.Object o) = readGeometryGeoAeson "Polygon" GeoPolygon o
parseJSON _ = mzero