{-# 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.GPSCoordinates
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Pinpoint.Types.GPSCoordinates where

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

-- | Specifies the GPS coordinates of a location.
--
-- /See:/ 'newGPSCoordinates' smart constructor.
data GPSCoordinates = GPSCoordinates'
  { -- | The latitude coordinate of the location.
    GPSCoordinates -> Double
latitude :: Prelude.Double,
    -- | The longitude coordinate of the location.
    GPSCoordinates -> Double
longitude :: Prelude.Double
  }
  deriving (GPSCoordinates -> GPSCoordinates -> Bool
(GPSCoordinates -> GPSCoordinates -> Bool)
-> (GPSCoordinates -> GPSCoordinates -> Bool) -> Eq GPSCoordinates
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GPSCoordinates -> GPSCoordinates -> Bool
$c/= :: GPSCoordinates -> GPSCoordinates -> Bool
== :: GPSCoordinates -> GPSCoordinates -> Bool
$c== :: GPSCoordinates -> GPSCoordinates -> Bool
Prelude.Eq, ReadPrec [GPSCoordinates]
ReadPrec GPSCoordinates
Int -> ReadS GPSCoordinates
ReadS [GPSCoordinates]
(Int -> ReadS GPSCoordinates)
-> ReadS [GPSCoordinates]
-> ReadPrec GPSCoordinates
-> ReadPrec [GPSCoordinates]
-> Read GPSCoordinates
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GPSCoordinates]
$creadListPrec :: ReadPrec [GPSCoordinates]
readPrec :: ReadPrec GPSCoordinates
$creadPrec :: ReadPrec GPSCoordinates
readList :: ReadS [GPSCoordinates]
$creadList :: ReadS [GPSCoordinates]
readsPrec :: Int -> ReadS GPSCoordinates
$creadsPrec :: Int -> ReadS GPSCoordinates
Prelude.Read, Int -> GPSCoordinates -> ShowS
[GPSCoordinates] -> ShowS
GPSCoordinates -> String
(Int -> GPSCoordinates -> ShowS)
-> (GPSCoordinates -> String)
-> ([GPSCoordinates] -> ShowS)
-> Show GPSCoordinates
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GPSCoordinates] -> ShowS
$cshowList :: [GPSCoordinates] -> ShowS
show :: GPSCoordinates -> String
$cshow :: GPSCoordinates -> String
showsPrec :: Int -> GPSCoordinates -> ShowS
$cshowsPrec :: Int -> GPSCoordinates -> ShowS
Prelude.Show, (forall x. GPSCoordinates -> Rep GPSCoordinates x)
-> (forall x. Rep GPSCoordinates x -> GPSCoordinates)
-> Generic GPSCoordinates
forall x. Rep GPSCoordinates x -> GPSCoordinates
forall x. GPSCoordinates -> Rep GPSCoordinates x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GPSCoordinates x -> GPSCoordinates
$cfrom :: forall x. GPSCoordinates -> Rep GPSCoordinates x
Prelude.Generic)

-- |
-- Create a value of 'GPSCoordinates' 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:
--
-- 'latitude', 'gPSCoordinates_latitude' - The latitude coordinate of the location.
--
-- 'longitude', 'gPSCoordinates_longitude' - The longitude coordinate of the location.
newGPSCoordinates ::
  -- | 'latitude'
  Prelude.Double ->
  -- | 'longitude'
  Prelude.Double ->
  GPSCoordinates
newGPSCoordinates :: Double -> Double -> GPSCoordinates
newGPSCoordinates Double
pLatitude_ Double
pLongitude_ =
  GPSCoordinates' :: Double -> Double -> GPSCoordinates
GPSCoordinates'
    { $sel:latitude:GPSCoordinates' :: Double
latitude = Double
pLatitude_,
      $sel:longitude:GPSCoordinates' :: Double
longitude = Double
pLongitude_
    }

-- | The latitude coordinate of the location.
gPSCoordinates_latitude :: Lens.Lens' GPSCoordinates Prelude.Double
gPSCoordinates_latitude :: (Double -> f Double) -> GPSCoordinates -> f GPSCoordinates
gPSCoordinates_latitude = (GPSCoordinates -> Double)
-> (GPSCoordinates -> Double -> GPSCoordinates)
-> Lens GPSCoordinates GPSCoordinates Double Double
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GPSCoordinates' {Double
latitude :: Double
$sel:latitude:GPSCoordinates' :: GPSCoordinates -> Double
latitude} -> Double
latitude) (\s :: GPSCoordinates
s@GPSCoordinates' {} Double
a -> GPSCoordinates
s {$sel:latitude:GPSCoordinates' :: Double
latitude = Double
a} :: GPSCoordinates)

-- | The longitude coordinate of the location.
gPSCoordinates_longitude :: Lens.Lens' GPSCoordinates Prelude.Double
gPSCoordinates_longitude :: (Double -> f Double) -> GPSCoordinates -> f GPSCoordinates
gPSCoordinates_longitude = (GPSCoordinates -> Double)
-> (GPSCoordinates -> Double -> GPSCoordinates)
-> Lens GPSCoordinates GPSCoordinates Double Double
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GPSCoordinates' {Double
longitude :: Double
$sel:longitude:GPSCoordinates' :: GPSCoordinates -> Double
longitude} -> Double
longitude) (\s :: GPSCoordinates
s@GPSCoordinates' {} Double
a -> GPSCoordinates
s {$sel:longitude:GPSCoordinates' :: Double
longitude = Double
a} :: GPSCoordinates)

instance Core.FromJSON GPSCoordinates where
  parseJSON :: Value -> Parser GPSCoordinates
parseJSON =
    String
-> (Object -> Parser GPSCoordinates)
-> Value
-> Parser GPSCoordinates
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"GPSCoordinates"
      ( \Object
x ->
          Double -> Double -> GPSCoordinates
GPSCoordinates'
            (Double -> Double -> GPSCoordinates)
-> Parser Double -> Parser (Double -> GPSCoordinates)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Double
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Latitude")
            Parser (Double -> GPSCoordinates)
-> Parser Double -> Parser GPSCoordinates
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Double
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Longitude")
      )

instance Prelude.Hashable GPSCoordinates

instance Prelude.NFData GPSCoordinates

instance Core.ToJSON GPSCoordinates where
  toJSON :: GPSCoordinates -> Value
toJSON GPSCoordinates' {Double
longitude :: Double
latitude :: Double
$sel:longitude:GPSCoordinates' :: GPSCoordinates -> Double
$sel:latitude:GPSCoordinates' :: GPSCoordinates -> Double
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Latitude" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Double
latitude),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Longitude" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Double
longitude)
          ]
      )