{-# 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.Pinpoint.Types.GPSPointDimension
-- 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.Pinpoint.Types.GPSPointDimension where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Pinpoint.Types.GPSCoordinates
import qualified Amazonka.Prelude as Prelude

-- | Specifies GPS-based criteria for including or excluding endpoints from a
-- segment.
--
-- /See:/ 'newGPSPointDimension' smart constructor.
data GPSPointDimension = GPSPointDimension'
  { -- | The range, in kilometers, from the GPS coordinates.
    GPSPointDimension -> Maybe Double
rangeInKilometers :: Prelude.Maybe Prelude.Double,
    -- | The GPS coordinates to measure distance from.
    GPSPointDimension -> GPSCoordinates
coordinates :: GPSCoordinates
  }
  deriving (GPSPointDimension -> GPSPointDimension -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GPSPointDimension -> GPSPointDimension -> Bool
$c/= :: GPSPointDimension -> GPSPointDimension -> Bool
== :: GPSPointDimension -> GPSPointDimension -> Bool
$c== :: GPSPointDimension -> GPSPointDimension -> Bool
Prelude.Eq, ReadPrec [GPSPointDimension]
ReadPrec GPSPointDimension
Int -> ReadS GPSPointDimension
ReadS [GPSPointDimension]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GPSPointDimension]
$creadListPrec :: ReadPrec [GPSPointDimension]
readPrec :: ReadPrec GPSPointDimension
$creadPrec :: ReadPrec GPSPointDimension
readList :: ReadS [GPSPointDimension]
$creadList :: ReadS [GPSPointDimension]
readsPrec :: Int -> ReadS GPSPointDimension
$creadsPrec :: Int -> ReadS GPSPointDimension
Prelude.Read, Int -> GPSPointDimension -> ShowS
[GPSPointDimension] -> ShowS
GPSPointDimension -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GPSPointDimension] -> ShowS
$cshowList :: [GPSPointDimension] -> ShowS
show :: GPSPointDimension -> String
$cshow :: GPSPointDimension -> String
showsPrec :: Int -> GPSPointDimension -> ShowS
$cshowsPrec :: Int -> GPSPointDimension -> ShowS
Prelude.Show, forall x. Rep GPSPointDimension x -> GPSPointDimension
forall x. GPSPointDimension -> Rep GPSPointDimension x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GPSPointDimension x -> GPSPointDimension
$cfrom :: forall x. GPSPointDimension -> Rep GPSPointDimension x
Prelude.Generic)

-- |
-- Create a value of 'GPSPointDimension' 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:
--
-- 'rangeInKilometers', 'gPSPointDimension_rangeInKilometers' - The range, in kilometers, from the GPS coordinates.
--
-- 'coordinates', 'gPSPointDimension_coordinates' - The GPS coordinates to measure distance from.
newGPSPointDimension ::
  -- | 'coordinates'
  GPSCoordinates ->
  GPSPointDimension
newGPSPointDimension :: GPSCoordinates -> GPSPointDimension
newGPSPointDimension GPSCoordinates
pCoordinates_ =
  GPSPointDimension'
    { $sel:rangeInKilometers:GPSPointDimension' :: Maybe Double
rangeInKilometers =
        forall a. Maybe a
Prelude.Nothing,
      $sel:coordinates:GPSPointDimension' :: GPSCoordinates
coordinates = GPSCoordinates
pCoordinates_
    }

-- | The range, in kilometers, from the GPS coordinates.
gPSPointDimension_rangeInKilometers :: Lens.Lens' GPSPointDimension (Prelude.Maybe Prelude.Double)
gPSPointDimension_rangeInKilometers :: Lens' GPSPointDimension (Maybe Double)
gPSPointDimension_rangeInKilometers = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GPSPointDimension' {Maybe Double
rangeInKilometers :: Maybe Double
$sel:rangeInKilometers:GPSPointDimension' :: GPSPointDimension -> Maybe Double
rangeInKilometers} -> Maybe Double
rangeInKilometers) (\s :: GPSPointDimension
s@GPSPointDimension' {} Maybe Double
a -> GPSPointDimension
s {$sel:rangeInKilometers:GPSPointDimension' :: Maybe Double
rangeInKilometers = Maybe Double
a} :: GPSPointDimension)

-- | The GPS coordinates to measure distance from.
gPSPointDimension_coordinates :: Lens.Lens' GPSPointDimension GPSCoordinates
gPSPointDimension_coordinates :: Lens' GPSPointDimension GPSCoordinates
gPSPointDimension_coordinates = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GPSPointDimension' {GPSCoordinates
coordinates :: GPSCoordinates
$sel:coordinates:GPSPointDimension' :: GPSPointDimension -> GPSCoordinates
coordinates} -> GPSCoordinates
coordinates) (\s :: GPSPointDimension
s@GPSPointDimension' {} GPSCoordinates
a -> GPSPointDimension
s {$sel:coordinates:GPSPointDimension' :: GPSCoordinates
coordinates = GPSCoordinates
a} :: GPSPointDimension)

instance Data.FromJSON GPSPointDimension where
  parseJSON :: Value -> Parser GPSPointDimension
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"GPSPointDimension"
      ( \Object
x ->
          Maybe Double -> GPSCoordinates -> GPSPointDimension
GPSPointDimension'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"RangeInKilometers")
            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
"Coordinates")
      )

instance Prelude.Hashable GPSPointDimension where
  hashWithSalt :: Int -> GPSPointDimension -> Int
hashWithSalt Int
_salt GPSPointDimension' {Maybe Double
GPSCoordinates
coordinates :: GPSCoordinates
rangeInKilometers :: Maybe Double
$sel:coordinates:GPSPointDimension' :: GPSPointDimension -> GPSCoordinates
$sel:rangeInKilometers:GPSPointDimension' :: GPSPointDimension -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
rangeInKilometers
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` GPSCoordinates
coordinates

instance Prelude.NFData GPSPointDimension where
  rnf :: GPSPointDimension -> ()
rnf GPSPointDimension' {Maybe Double
GPSCoordinates
coordinates :: GPSCoordinates
rangeInKilometers :: Maybe Double
$sel:coordinates:GPSPointDimension' :: GPSPointDimension -> GPSCoordinates
$sel:rangeInKilometers:GPSPointDimension' :: GPSPointDimension -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
rangeInKilometers
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf GPSCoordinates
coordinates

instance Data.ToJSON GPSPointDimension where
  toJSON :: GPSPointDimension -> Value
toJSON GPSPointDimension' {Maybe Double
GPSCoordinates
coordinates :: GPSCoordinates
rangeInKilometers :: Maybe Double
$sel:coordinates:GPSPointDimension' :: GPSPointDimension -> GPSCoordinates
$sel:rangeInKilometers:GPSPointDimension' :: GPSPointDimension -> Maybe Double
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"RangeInKilometers" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
rangeInKilometers,
            forall a. a -> Maybe a
Prelude.Just (Key
"Coordinates" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= GPSCoordinates
coordinates)
          ]
      )