{-# LANGUAGE TemplateHaskell #-}
module Data.Geospatial.Internal.Geometry.GeoPolygon (
GeoPolygon(..)
, unGeoPolygon
) where
import Data.Geospatial.Internal.BasicTypes
import Data.Geospatial.Internal.Geometry.Aeson
import Data.LinearRing
import Control.Lens (makeLenses)
import Control.Monad (mzero)
import Data.Aeson (FromJSON (..),
ToJSON (..),
Value (..))
newtype GeoPolygon = GeoPolygon { _unGeoPolygon :: [LinearRing GeoPositionWithoutCRS] } deriving (Show, Eq)
makeLenses ''GeoPolygon
instance ToJSON GeoPolygon where
toJSON = makeGeometryGeoAeson "Polygon" . _unGeoPolygon
instance FromJSON GeoPolygon where
parseJSON (Object o) = readGeometryGeoAeson "Polygon" GeoPolygon o
parseJSON _ = mzero