{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TemplateHaskell #-}
module Data.Geospatial.Internal.Geometry.GeoMultiPoint (
GeoMultiPoint(..)
, unGeoMultiPoint
, splitGeoMultiPoint, mergeGeoPoints
) where
import Data.Geospatial.Internal.BasicTypes
import Data.Geospatial.Internal.Geometry.Aeson
import Data.Geospatial.Internal.Geometry.GeoPoint
import Control.DeepSeq
import Control.Lens (makeLenses)
import Control.Monad (mzero)
import qualified Data.Aeson as Aeson
import qualified Data.Sequence as Sequence
import GHC.Generics (Generic)
newtype GeoMultiPoint = GeoMultiPoint { _unGeoMultiPoint :: Sequence.Seq GeoPositionWithoutCRS } deriving (Show, Eq, Generic, NFData)
makeLenses ''GeoMultiPoint
splitGeoMultiPoint:: GeoMultiPoint -> Sequence.Seq GeoPoint
splitGeoMultiPoint = fmap GeoPoint . _unGeoMultiPoint
mergeGeoPoints :: Sequence.Seq GeoPoint -> GeoMultiPoint
mergeGeoPoints = GeoMultiPoint . fmap _unGeoPoint
instance Aeson.ToJSON GeoMultiPoint where
toJSON = makeGeometryGeoAeson "MultiPoint" . _unGeoMultiPoint
instance Aeson.FromJSON GeoMultiPoint where
parseJSON (Aeson.Object o) = readGeometryGeoAeson "MultiPoint" GeoMultiPoint o
parseJSON _ = mzero