{-# 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.LegGeometry
-- 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.LegGeometry 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

-- | Contains the geometry details for each path between a pair of positions.
-- Used in plotting a route leg on a map.
--
-- /See:/ 'newLegGeometry' smart constructor.
data LegGeometry = LegGeometry'
  { -- | An ordered list of positions used to plot a route on a map.
    --
    -- The first position is closest to the start position for the leg, and the
    -- last position is the closest to the end position for the leg.
    --
    -- -   For example,
    --     @[[-123.117, 49.284],[-123.115, 49.285],[-123.115, 49.285]]@
    LegGeometry -> Maybe (NonEmpty (Sensitive (NonEmpty Double)))
lineString :: Prelude.Maybe (Prelude.NonEmpty (Data.Sensitive (Prelude.NonEmpty Prelude.Double)))
  }
  deriving (LegGeometry -> LegGeometry -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LegGeometry -> LegGeometry -> Bool
$c/= :: LegGeometry -> LegGeometry -> Bool
== :: LegGeometry -> LegGeometry -> Bool
$c== :: LegGeometry -> LegGeometry -> Bool
Prelude.Eq, Int -> LegGeometry -> ShowS
[LegGeometry] -> ShowS
LegGeometry -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LegGeometry] -> ShowS
$cshowList :: [LegGeometry] -> ShowS
show :: LegGeometry -> String
$cshow :: LegGeometry -> String
showsPrec :: Int -> LegGeometry -> ShowS
$cshowsPrec :: Int -> LegGeometry -> ShowS
Prelude.Show, forall x. Rep LegGeometry x -> LegGeometry
forall x. LegGeometry -> Rep LegGeometry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LegGeometry x -> LegGeometry
$cfrom :: forall x. LegGeometry -> Rep LegGeometry x
Prelude.Generic)

-- |
-- Create a value of 'LegGeometry' 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:
--
-- 'lineString', 'legGeometry_lineString' - An ordered list of positions used to plot a route on a map.
--
-- The first position is closest to the start position for the leg, and the
-- last position is the closest to the end position for the leg.
--
-- -   For example,
--     @[[-123.117, 49.284],[-123.115, 49.285],[-123.115, 49.285]]@
newLegGeometry ::
  LegGeometry
newLegGeometry :: LegGeometry
newLegGeometry =
  LegGeometry' {$sel:lineString:LegGeometry' :: Maybe (NonEmpty (Sensitive (NonEmpty Double)))
lineString = forall a. Maybe a
Prelude.Nothing}

-- | An ordered list of positions used to plot a route on a map.
--
-- The first position is closest to the start position for the leg, and the
-- last position is the closest to the end position for the leg.
--
-- -   For example,
--     @[[-123.117, 49.284],[-123.115, 49.285],[-123.115, 49.285]]@
legGeometry_lineString :: Lens.Lens' LegGeometry (Prelude.Maybe (Prelude.NonEmpty (Prelude.NonEmpty Prelude.Double)))
legGeometry_lineString :: Lens' LegGeometry (Maybe (NonEmpty (NonEmpty Double)))
legGeometry_lineString = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LegGeometry' {Maybe (NonEmpty (Sensitive (NonEmpty Double)))
lineString :: Maybe (NonEmpty (Sensitive (NonEmpty Double)))
$sel:lineString:LegGeometry' :: LegGeometry -> Maybe (NonEmpty (Sensitive (NonEmpty Double)))
lineString} -> Maybe (NonEmpty (Sensitive (NonEmpty Double)))
lineString) (\s :: LegGeometry
s@LegGeometry' {} Maybe (NonEmpty (Sensitive (NonEmpty Double)))
a -> LegGeometry
s {$sel:lineString:LegGeometry' :: Maybe (NonEmpty (Sensitive (NonEmpty Double)))
lineString = Maybe (NonEmpty (Sensitive (NonEmpty Double)))
a} :: LegGeometry) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON LegGeometry where
  parseJSON :: Value -> Parser LegGeometry
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"LegGeometry"
      ( \Object
x ->
          Maybe (NonEmpty (Sensitive (NonEmpty Double))) -> LegGeometry
LegGeometry' 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
"LineString")
      )

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

instance Prelude.NFData LegGeometry where
  rnf :: LegGeometry -> ()
rnf LegGeometry' {Maybe (NonEmpty (Sensitive (NonEmpty Double)))
lineString :: Maybe (NonEmpty (Sensitive (NonEmpty Double)))
$sel:lineString:LegGeometry' :: LegGeometry -> Maybe (NonEmpty (Sensitive (NonEmpty Double)))
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty (Sensitive (NonEmpty Double)))
lineString