{-# 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.PrivateNetworks.Types.Position
-- 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.PrivateNetworks.Types.Position 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
import Amazonka.PrivateNetworks.Types.ElevationReference
import Amazonka.PrivateNetworks.Types.ElevationUnit

-- | Information about a position.
--
-- /See:/ 'newPosition' smart constructor.
data Position = Position'
  { -- | The elevation of the equipment at this position.
    Position -> Maybe Double
elevation :: Prelude.Maybe Prelude.Double,
    -- | The reference point from which elevation is reported.
    Position -> Maybe ElevationReference
elevationReference :: Prelude.Maybe ElevationReference,
    -- | The units used to measure the elevation of the position.
    Position -> Maybe ElevationUnit
elevationUnit :: Prelude.Maybe ElevationUnit,
    -- | The latitude of the position.
    Position -> Maybe Double
latitude :: Prelude.Maybe Prelude.Double,
    -- | The longitude of the position.
    Position -> Maybe Double
longitude :: Prelude.Maybe Prelude.Double
  }
  deriving (Position -> Position -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Position -> Position -> Bool
$c/= :: Position -> Position -> Bool
== :: Position -> Position -> Bool
$c== :: Position -> Position -> Bool
Prelude.Eq, ReadPrec [Position]
ReadPrec Position
Int -> ReadS Position
ReadS [Position]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Position]
$creadListPrec :: ReadPrec [Position]
readPrec :: ReadPrec Position
$creadPrec :: ReadPrec Position
readList :: ReadS [Position]
$creadList :: ReadS [Position]
readsPrec :: Int -> ReadS Position
$creadsPrec :: Int -> ReadS Position
Prelude.Read, Int -> Position -> ShowS
[Position] -> ShowS
Position -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Position] -> ShowS
$cshowList :: [Position] -> ShowS
show :: Position -> String
$cshow :: Position -> String
showsPrec :: Int -> Position -> ShowS
$cshowsPrec :: Int -> Position -> ShowS
Prelude.Show, forall x. Rep Position x -> Position
forall x. Position -> Rep Position x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Position x -> Position
$cfrom :: forall x. Position -> Rep Position x
Prelude.Generic)

-- |
-- Create a value of 'Position' 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:
--
-- 'elevation', 'position_elevation' - The elevation of the equipment at this position.
--
-- 'elevationReference', 'position_elevationReference' - The reference point from which elevation is reported.
--
-- 'elevationUnit', 'position_elevationUnit' - The units used to measure the elevation of the position.
--
-- 'latitude', 'position_latitude' - The latitude of the position.
--
-- 'longitude', 'position_longitude' - The longitude of the position.
newPosition ::
  Position
newPosition :: Position
newPosition =
  Position'
    { $sel:elevation:Position' :: Maybe Double
elevation = forall a. Maybe a
Prelude.Nothing,
      $sel:elevationReference:Position' :: Maybe ElevationReference
elevationReference = forall a. Maybe a
Prelude.Nothing,
      $sel:elevationUnit:Position' :: Maybe ElevationUnit
elevationUnit = forall a. Maybe a
Prelude.Nothing,
      $sel:latitude:Position' :: Maybe Double
latitude = forall a. Maybe a
Prelude.Nothing,
      $sel:longitude:Position' :: Maybe Double
longitude = forall a. Maybe a
Prelude.Nothing
    }

-- | The elevation of the equipment at this position.
position_elevation :: Lens.Lens' Position (Prelude.Maybe Prelude.Double)
position_elevation :: Lens' Position (Maybe Double)
position_elevation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Position' {Maybe Double
elevation :: Maybe Double
$sel:elevation:Position' :: Position -> Maybe Double
elevation} -> Maybe Double
elevation) (\s :: Position
s@Position' {} Maybe Double
a -> Position
s {$sel:elevation:Position' :: Maybe Double
elevation = Maybe Double
a} :: Position)

-- | The reference point from which elevation is reported.
position_elevationReference :: Lens.Lens' Position (Prelude.Maybe ElevationReference)
position_elevationReference :: Lens' Position (Maybe ElevationReference)
position_elevationReference = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Position' {Maybe ElevationReference
elevationReference :: Maybe ElevationReference
$sel:elevationReference:Position' :: Position -> Maybe ElevationReference
elevationReference} -> Maybe ElevationReference
elevationReference) (\s :: Position
s@Position' {} Maybe ElevationReference
a -> Position
s {$sel:elevationReference:Position' :: Maybe ElevationReference
elevationReference = Maybe ElevationReference
a} :: Position)

-- | The units used to measure the elevation of the position.
position_elevationUnit :: Lens.Lens' Position (Prelude.Maybe ElevationUnit)
position_elevationUnit :: Lens' Position (Maybe ElevationUnit)
position_elevationUnit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Position' {Maybe ElevationUnit
elevationUnit :: Maybe ElevationUnit
$sel:elevationUnit:Position' :: Position -> Maybe ElevationUnit
elevationUnit} -> Maybe ElevationUnit
elevationUnit) (\s :: Position
s@Position' {} Maybe ElevationUnit
a -> Position
s {$sel:elevationUnit:Position' :: Maybe ElevationUnit
elevationUnit = Maybe ElevationUnit
a} :: Position)

-- | The latitude of the position.
position_latitude :: Lens.Lens' Position (Prelude.Maybe Prelude.Double)
position_latitude :: Lens' Position (Maybe Double)
position_latitude = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Position' {Maybe Double
latitude :: Maybe Double
$sel:latitude:Position' :: Position -> Maybe Double
latitude} -> Maybe Double
latitude) (\s :: Position
s@Position' {} Maybe Double
a -> Position
s {$sel:latitude:Position' :: Maybe Double
latitude = Maybe Double
a} :: Position)

-- | The longitude of the position.
position_longitude :: Lens.Lens' Position (Prelude.Maybe Prelude.Double)
position_longitude :: Lens' Position (Maybe Double)
position_longitude = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Position' {Maybe Double
longitude :: Maybe Double
$sel:longitude:Position' :: Position -> Maybe Double
longitude} -> Maybe Double
longitude) (\s :: Position
s@Position' {} Maybe Double
a -> Position
s {$sel:longitude:Position' :: Maybe Double
longitude = Maybe Double
a} :: Position)

instance Data.FromJSON Position where
  parseJSON :: Value -> Parser Position
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Position"
      ( \Object
x ->
          Maybe Double
-> Maybe ElevationReference
-> Maybe ElevationUnit
-> Maybe Double
-> Maybe Double
-> Position
Position'
            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
"elevation")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"elevationReference")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"elevationUnit")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"latitude")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"longitude")
      )

instance Prelude.Hashable Position where
  hashWithSalt :: Int -> Position -> Int
hashWithSalt Int
_salt Position' {Maybe Double
Maybe ElevationReference
Maybe ElevationUnit
longitude :: Maybe Double
latitude :: Maybe Double
elevationUnit :: Maybe ElevationUnit
elevationReference :: Maybe ElevationReference
elevation :: Maybe Double
$sel:longitude:Position' :: Position -> Maybe Double
$sel:latitude:Position' :: Position -> Maybe Double
$sel:elevationUnit:Position' :: Position -> Maybe ElevationUnit
$sel:elevationReference:Position' :: Position -> Maybe ElevationReference
$sel:elevation:Position' :: Position -> Maybe Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
elevation
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ElevationReference
elevationReference
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ElevationUnit
elevationUnit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
latitude
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
longitude

instance Prelude.NFData Position where
  rnf :: Position -> ()
rnf Position' {Maybe Double
Maybe ElevationReference
Maybe ElevationUnit
longitude :: Maybe Double
latitude :: Maybe Double
elevationUnit :: Maybe ElevationUnit
elevationReference :: Maybe ElevationReference
elevation :: Maybe Double
$sel:longitude:Position' :: Position -> Maybe Double
$sel:latitude:Position' :: Position -> Maybe Double
$sel:elevationUnit:Position' :: Position -> Maybe ElevationUnit
$sel:elevationReference:Position' :: Position -> Maybe ElevationReference
$sel:elevation:Position' :: Position -> Maybe Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
elevation
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ElevationReference
elevationReference
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ElevationUnit
elevationUnit
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
latitude
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
longitude

instance Data.ToJSON Position where
  toJSON :: Position -> Value
toJSON Position' {Maybe Double
Maybe ElevationReference
Maybe ElevationUnit
longitude :: Maybe Double
latitude :: Maybe Double
elevationUnit :: Maybe ElevationUnit
elevationReference :: Maybe ElevationReference
elevation :: Maybe Double
$sel:longitude:Position' :: Position -> Maybe Double
$sel:latitude:Position' :: Position -> Maybe Double
$sel:elevationUnit:Position' :: Position -> Maybe ElevationUnit
$sel:elevationReference:Position' :: Position -> Maybe ElevationReference
$sel:elevation:Position' :: Position -> Maybe Double
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"elevation" 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
elevation,
            (Key
"elevationReference" 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 ElevationReference
elevationReference,
            (Key
"elevationUnit" 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 ElevationUnit
elevationUnit,
            (Key
"latitude" 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
latitude,
            (Key
"longitude" 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
longitude
          ]
      )