{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TemplateHaskell #-}
module Data.Geospatial.Internal.Geometry.GeoPoint (
GeoPoint(..)
, unGeoPoint
, retrieveXY
) 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 GHC.Generics (Generic)
newtype GeoPoint = GeoPoint { _unGeoPoint :: GeoPositionWithoutCRS } deriving (Show, Eq, Generic, NFData)
makeLenses ''GeoPoint
instance Aeson.ToJSON GeoPoint where
toJSON = makeGeometryGeoAeson "Point" . _unGeoPoint
instance Aeson.FromJSON GeoPoint where
parseJSON (Aeson.Object o) = readGeometryGeoAeson "Point" GeoPoint o
parseJSON _ = mzero