{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Location.Types.Circle
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Location.Types.Circle where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | A circle on the earth, as defined by a center point and a radius.
--
-- /See:/ 'newCircle' smart constructor.
data Circle = Circle'
  { -- | A single point geometry, specifying the center of the circle, using
    -- <https://gisgeography.com/wgs84-world-geodetic-system/ WGS 84>
    -- coordinates, in the form @[longitude, latitude]@.
    Circle -> Sensitive (NonEmpty Double)
center :: Data.Sensitive (Prelude.NonEmpty Prelude.Double),
    -- | The radius of the circle in meters. Must be greater than zero and no
    -- larger than 100,000 (100 kilometers).
    Circle -> Double
radius :: Prelude.Double
  }
  deriving (Circle -> Circle -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Circle -> Circle -> Bool
$c/= :: Circle -> Circle -> Bool
== :: Circle -> Circle -> Bool
$c== :: Circle -> Circle -> Bool
Prelude.Eq, Int -> Circle -> ShowS
[Circle] -> ShowS
Circle -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Circle] -> ShowS
$cshowList :: [Circle] -> ShowS
show :: Circle -> String
$cshow :: Circle -> String
showsPrec :: Int -> Circle -> ShowS
$cshowsPrec :: Int -> Circle -> ShowS
Prelude.Show, forall x. Rep Circle x -> Circle
forall x. Circle -> Rep Circle x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Circle x -> Circle
$cfrom :: forall x. Circle -> Rep Circle x
Prelude.Generic)

-- |
-- Create a value of 'Circle' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'center', 'circle_center' - A single point geometry, specifying the center of the circle, using
-- <https://gisgeography.com/wgs84-world-geodetic-system/ WGS 84>
-- coordinates, in the form @[longitude, latitude]@.
--
-- 'radius', 'circle_radius' - The radius of the circle in meters. Must be greater than zero and no
-- larger than 100,000 (100 kilometers).
newCircle ::
  -- | 'center'
  Prelude.NonEmpty Prelude.Double ->
  -- | 'radius'
  Prelude.Double ->
  Circle
newCircle :: NonEmpty Double -> Double -> Circle
newCircle NonEmpty Double
pCenter_ Double
pRadius_ =
  Circle'
    { $sel:center:Circle' :: Sensitive (NonEmpty Double)
center =
        forall a. Iso' (Sensitive a) a
Data._Sensitive
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
          forall t b. AReview t b -> b -> t
Lens.# NonEmpty Double
pCenter_,
      $sel:radius:Circle' :: Double
radius = Double
pRadius_
    }

-- | A single point geometry, specifying the center of the circle, using
-- <https://gisgeography.com/wgs84-world-geodetic-system/ WGS 84>
-- coordinates, in the form @[longitude, latitude]@.
circle_center :: Lens.Lens' Circle (Prelude.NonEmpty Prelude.Double)
circle_center :: Lens' Circle (NonEmpty Double)
circle_center = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Circle' {Sensitive (NonEmpty Double)
center :: Sensitive (NonEmpty Double)
$sel:center:Circle' :: Circle -> Sensitive (NonEmpty Double)
center} -> Sensitive (NonEmpty Double)
center) (\s :: Circle
s@Circle' {} Sensitive (NonEmpty Double)
a -> Circle
s {$sel:center:Circle' :: Sensitive (NonEmpty Double)
center = Sensitive (NonEmpty Double)
a} :: Circle) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The radius of the circle in meters. Must be greater than zero and no
-- larger than 100,000 (100 kilometers).
circle_radius :: Lens.Lens' Circle Prelude.Double
circle_radius :: Lens' Circle Double
circle_radius = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Circle' {Double
radius :: Double
$sel:radius:Circle' :: Circle -> Double
radius} -> Double
radius) (\s :: Circle
s@Circle' {} Double
a -> Circle
s {$sel:radius:Circle' :: Double
radius = Double
a} :: Circle)

instance Data.FromJSON Circle where
  parseJSON :: Value -> Parser Circle
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Circle"
      ( \Object
x ->
          Sensitive (NonEmpty Double) -> Double -> Circle
Circle'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Center")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Radius")
      )

instance Prelude.Hashable Circle where
  hashWithSalt :: Int -> Circle -> Int
hashWithSalt Int
_salt Circle' {Double
Sensitive (NonEmpty Double)
radius :: Double
center :: Sensitive (NonEmpty Double)
$sel:radius:Circle' :: Circle -> Double
$sel:center:Circle' :: Circle -> Sensitive (NonEmpty Double)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive (NonEmpty Double)
center
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Double
radius

instance Prelude.NFData Circle where
  rnf :: Circle -> ()
rnf Circle' {Double
Sensitive (NonEmpty Double)
radius :: Double
center :: Sensitive (NonEmpty Double)
$sel:radius:Circle' :: Circle -> Double
$sel:center:Circle' :: Circle -> Sensitive (NonEmpty Double)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Sensitive (NonEmpty Double)
center seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Double
radius

instance Data.ToJSON Circle where
  toJSON :: Circle -> Value
toJSON Circle' {Double
Sensitive (NonEmpty Double)
radius :: Double
center :: Sensitive (NonEmpty Double)
$sel:radius:Circle' :: Circle -> Double
$sel:center:Circle' :: Circle -> Sensitive (NonEmpty Double)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Center" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Sensitive (NonEmpty Double)
center),
            forall a. a -> Maybe a
Prelude.Just (Key
"Radius" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Double
radius)
          ]
      )