{-# 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.Lens (makeLenses)
import Control.Monad (mzero)
import Data.Aeson (FromJSON (..),
ToJSON (..),
Value (..))
newtype GeoMultiPoint = GeoMultiPoint { _unGeoMultiPoint :: [GeoPositionWithoutCRS] } deriving (Show, Eq)
makeLenses ''GeoMultiPoint
splitGeoMultiPoint:: GeoMultiPoint -> [GeoPoint]
splitGeoMultiPoint = map GeoPoint . _unGeoMultiPoint
mergeGeoPoints :: [GeoPoint] -> GeoMultiPoint
mergeGeoPoints = GeoMultiPoint . map _unGeoPoint
instance ToJSON GeoMultiPoint where
toJSON = makeGeometryGeoAeson "MultiPoint" . _unGeoMultiPoint
instance FromJSON GeoMultiPoint where
parseJSON (Object o) = readGeometryGeoAeson "MultiPoint" GeoMultiPoint o
parseJSON _ = mzero