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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 (Core.Sensitive (Prelude.NonEmpty Prelude.Double)))
  }
  deriving (LegGeometry -> LegGeometry -> Bool
(LegGeometry -> LegGeometry -> Bool)
-> (LegGeometry -> LegGeometry -> Bool) -> Eq LegGeometry
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
(Int -> LegGeometry -> ShowS)
-> (LegGeometry -> String)
-> ([LegGeometry] -> ShowS)
-> Show LegGeometry
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. LegGeometry -> Rep LegGeometry x)
-> (forall x. Rep LegGeometry x -> LegGeometry)
-> Generic LegGeometry
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' :: Maybe (NonEmpty (Sensitive (NonEmpty Double))) -> LegGeometry
LegGeometry' {$sel:lineString:LegGeometry' :: Maybe (NonEmpty (Sensitive (NonEmpty Double)))
lineString = Maybe (NonEmpty (Sensitive (NonEmpty Double)))
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 :: (Maybe (NonEmpty (NonEmpty Double))
 -> f (Maybe (NonEmpty (NonEmpty Double))))
-> LegGeometry -> f LegGeometry
legGeometry_lineString = (LegGeometry -> Maybe (NonEmpty (Sensitive (NonEmpty Double))))
-> (LegGeometry
    -> Maybe (NonEmpty (Sensitive (NonEmpty Double))) -> LegGeometry)
-> Lens
     LegGeometry
     LegGeometry
     (Maybe (NonEmpty (Sensitive (NonEmpty Double))))
     (Maybe (NonEmpty (Sensitive (NonEmpty Double))))
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) ((Maybe (NonEmpty (Sensitive (NonEmpty Double)))
  -> f (Maybe (NonEmpty (Sensitive (NonEmpty Double)))))
 -> LegGeometry -> f LegGeometry)
-> ((Maybe (NonEmpty (NonEmpty Double))
     -> f (Maybe (NonEmpty (NonEmpty Double))))
    -> Maybe (NonEmpty (Sensitive (NonEmpty Double)))
    -> f (Maybe (NonEmpty (Sensitive (NonEmpty Double)))))
-> (Maybe (NonEmpty (NonEmpty Double))
    -> f (Maybe (NonEmpty (NonEmpty Double))))
-> LegGeometry
-> f LegGeometry
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty (Sensitive (NonEmpty Double)))
  (NonEmpty (Sensitive (NonEmpty Double)))
  (NonEmpty (NonEmpty Double))
  (NonEmpty (NonEmpty Double))
-> Iso
     (Maybe (NonEmpty (Sensitive (NonEmpty Double))))
     (Maybe (NonEmpty (Sensitive (NonEmpty Double))))
     (Maybe (NonEmpty (NonEmpty Double)))
     (Maybe (NonEmpty (NonEmpty Double)))
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 AnIso
  (NonEmpty (Sensitive (NonEmpty Double)))
  (NonEmpty (Sensitive (NonEmpty Double)))
  (NonEmpty (NonEmpty Double))
  (NonEmpty (NonEmpty Double))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON LegGeometry where
  parseJSON :: Value -> Parser LegGeometry
parseJSON =
    String
-> (Object -> Parser LegGeometry) -> Value -> Parser LegGeometry
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LegGeometry"
      ( \Object
x ->
          Maybe (NonEmpty (Sensitive (NonEmpty Double))) -> LegGeometry
LegGeometry' (Maybe (NonEmpty (Sensitive (NonEmpty Double))) -> LegGeometry)
-> Parser (Maybe (NonEmpty (Sensitive (NonEmpty Double))))
-> Parser LegGeometry
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text -> Parser (Maybe (NonEmpty (Sensitive (NonEmpty Double))))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LineString")
      )

instance Prelude.Hashable LegGeometry

instance Prelude.NFData LegGeometry