{-# 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.Step
-- 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.Step where

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

-- | Represents an element of a leg within a route. A step contains
-- instructions for how to move to the next step in the leg.
--
-- /See:/ 'newStep' smart constructor.
data Step = Step'
  { -- | Represents the start position, or index, in a sequence of steps within
    -- the leg\'s line string geometry. For example, the index of the first
    -- step in a leg geometry is @0@.
    --
    -- Included in the response for queries that set @IncludeLegGeometry@ to
    -- @True@.
    Step -> Maybe Natural
geometryOffset :: Prelude.Maybe Prelude.Natural,
    -- | The travel distance between the step\'s @StartPosition@ and
    -- @EndPosition@.
    Step -> Double
distance :: Prelude.Double,
    -- | The estimated travel time, in seconds, from the step\'s @StartPosition@
    -- to the @EndPosition@. . The travel mode and departure time that you
    -- specify in the request determines the calculated time.
    Step -> Double
durationSeconds :: Prelude.Double,
    -- | The end position of a step. If the position the last step in the leg,
    -- this position is the same as the end position of the leg.
    Step -> Sensitive (NonEmpty Double)
endPosition :: Core.Sensitive (Prelude.NonEmpty Prelude.Double),
    -- | The starting position of a step. If the position is the first step in
    -- the leg, this position is the same as the start position of the leg.
    Step -> Sensitive (NonEmpty Double)
startPosition :: Core.Sensitive (Prelude.NonEmpty Prelude.Double)
  }
  deriving (Step -> Step -> Bool
(Step -> Step -> Bool) -> (Step -> Step -> Bool) -> Eq Step
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Step -> Step -> Bool
$c/= :: Step -> Step -> Bool
== :: Step -> Step -> Bool
$c== :: Step -> Step -> Bool
Prelude.Eq, Int -> Step -> ShowS
[Step] -> ShowS
Step -> String
(Int -> Step -> ShowS)
-> (Step -> String) -> ([Step] -> ShowS) -> Show Step
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Step] -> ShowS
$cshowList :: [Step] -> ShowS
show :: Step -> String
$cshow :: Step -> String
showsPrec :: Int -> Step -> ShowS
$cshowsPrec :: Int -> Step -> ShowS
Prelude.Show, (forall x. Step -> Rep Step x)
-> (forall x. Rep Step x -> Step) -> Generic Step
forall x. Rep Step x -> Step
forall x. Step -> Rep Step x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Step x -> Step
$cfrom :: forall x. Step -> Rep Step x
Prelude.Generic)

-- |
-- Create a value of 'Step' 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:
--
-- 'geometryOffset', 'step_geometryOffset' - Represents the start position, or index, in a sequence of steps within
-- the leg\'s line string geometry. For example, the index of the first
-- step in a leg geometry is @0@.
--
-- Included in the response for queries that set @IncludeLegGeometry@ to
-- @True@.
--
-- 'distance', 'step_distance' - The travel distance between the step\'s @StartPosition@ and
-- @EndPosition@.
--
-- 'durationSeconds', 'step_durationSeconds' - The estimated travel time, in seconds, from the step\'s @StartPosition@
-- to the @EndPosition@. . The travel mode and departure time that you
-- specify in the request determines the calculated time.
--
-- 'endPosition', 'step_endPosition' - The end position of a step. If the position the last step in the leg,
-- this position is the same as the end position of the leg.
--
-- 'startPosition', 'step_startPosition' - The starting position of a step. If the position is the first step in
-- the leg, this position is the same as the start position of the leg.
newStep ::
  -- | 'distance'
  Prelude.Double ->
  -- | 'durationSeconds'
  Prelude.Double ->
  -- | 'endPosition'
  Prelude.NonEmpty Prelude.Double ->
  -- | 'startPosition'
  Prelude.NonEmpty Prelude.Double ->
  Step
newStep :: Double -> Double -> NonEmpty Double -> NonEmpty Double -> Step
newStep
  Double
pDistance_
  Double
pDurationSeconds_
  NonEmpty Double
pEndPosition_
  NonEmpty Double
pStartPosition_ =
    Step' :: Maybe Natural
-> Double
-> Double
-> Sensitive (NonEmpty Double)
-> Sensitive (NonEmpty Double)
-> Step
Step'
      { $sel:geometryOffset:Step' :: Maybe Natural
geometryOffset = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
        $sel:distance:Step' :: Double
distance = Double
pDistance_,
        $sel:durationSeconds:Step' :: Double
durationSeconds = Double
pDurationSeconds_,
        $sel:endPosition:Step' :: Sensitive (NonEmpty Double)
endPosition =
          Tagged (NonEmpty Double) (Identity (NonEmpty Double))
-> Tagged
     (Sensitive (NonEmpty Double))
     (Identity (Sensitive (NonEmpty Double)))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged (NonEmpty Double) (Identity (NonEmpty Double))
 -> Tagged
      (Sensitive (NonEmpty Double))
      (Identity (Sensitive (NonEmpty Double))))
-> (Tagged (NonEmpty Double) (Identity (NonEmpty Double))
    -> Tagged (NonEmpty Double) (Identity (NonEmpty Double)))
-> Tagged (NonEmpty Double) (Identity (NonEmpty Double))
-> Tagged
     (Sensitive (NonEmpty Double))
     (Identity (Sensitive (NonEmpty Double)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Tagged (NonEmpty Double) (Identity (NonEmpty Double))
-> Tagged (NonEmpty Double) (Identity (NonEmpty Double))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
            (Tagged (NonEmpty Double) (Identity (NonEmpty Double))
 -> Tagged
      (Sensitive (NonEmpty Double))
      (Identity (Sensitive (NonEmpty Double))))
-> NonEmpty Double -> Sensitive (NonEmpty Double)
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Double
pEndPosition_,
        $sel:startPosition:Step' :: Sensitive (NonEmpty Double)
startPosition =
          Tagged (NonEmpty Double) (Identity (NonEmpty Double))
-> Tagged
     (Sensitive (NonEmpty Double))
     (Identity (Sensitive (NonEmpty Double)))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged (NonEmpty Double) (Identity (NonEmpty Double))
 -> Tagged
      (Sensitive (NonEmpty Double))
      (Identity (Sensitive (NonEmpty Double))))
-> (Tagged (NonEmpty Double) (Identity (NonEmpty Double))
    -> Tagged (NonEmpty Double) (Identity (NonEmpty Double)))
-> Tagged (NonEmpty Double) (Identity (NonEmpty Double))
-> Tagged
     (Sensitive (NonEmpty Double))
     (Identity (Sensitive (NonEmpty Double)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Tagged (NonEmpty Double) (Identity (NonEmpty Double))
-> Tagged (NonEmpty Double) (Identity (NonEmpty Double))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
            (Tagged (NonEmpty Double) (Identity (NonEmpty Double))
 -> Tagged
      (Sensitive (NonEmpty Double))
      (Identity (Sensitive (NonEmpty Double))))
-> NonEmpty Double -> Sensitive (NonEmpty Double)
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Double
pStartPosition_
      }

-- | Represents the start position, or index, in a sequence of steps within
-- the leg\'s line string geometry. For example, the index of the first
-- step in a leg geometry is @0@.
--
-- Included in the response for queries that set @IncludeLegGeometry@ to
-- @True@.
step_geometryOffset :: Lens.Lens' Step (Prelude.Maybe Prelude.Natural)
step_geometryOffset :: (Maybe Natural -> f (Maybe Natural)) -> Step -> f Step
step_geometryOffset = (Step -> Maybe Natural)
-> (Step -> Maybe Natural -> Step)
-> Lens Step Step (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Step' {Maybe Natural
geometryOffset :: Maybe Natural
$sel:geometryOffset:Step' :: Step -> Maybe Natural
geometryOffset} -> Maybe Natural
geometryOffset) (\s :: Step
s@Step' {} Maybe Natural
a -> Step
s {$sel:geometryOffset:Step' :: Maybe Natural
geometryOffset = Maybe Natural
a} :: Step)

-- | The travel distance between the step\'s @StartPosition@ and
-- @EndPosition@.
step_distance :: Lens.Lens' Step Prelude.Double
step_distance :: (Double -> f Double) -> Step -> f Step
step_distance = (Step -> Double)
-> (Step -> Double -> Step) -> Lens Step Step Double Double
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Step' {Double
distance :: Double
$sel:distance:Step' :: Step -> Double
distance} -> Double
distance) (\s :: Step
s@Step' {} Double
a -> Step
s {$sel:distance:Step' :: Double
distance = Double
a} :: Step)

-- | The estimated travel time, in seconds, from the step\'s @StartPosition@
-- to the @EndPosition@. . The travel mode and departure time that you
-- specify in the request determines the calculated time.
step_durationSeconds :: Lens.Lens' Step Prelude.Double
step_durationSeconds :: (Double -> f Double) -> Step -> f Step
step_durationSeconds = (Step -> Double)
-> (Step -> Double -> Step) -> Lens Step Step Double Double
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Step' {Double
durationSeconds :: Double
$sel:durationSeconds:Step' :: Step -> Double
durationSeconds} -> Double
durationSeconds) (\s :: Step
s@Step' {} Double
a -> Step
s {$sel:durationSeconds:Step' :: Double
durationSeconds = Double
a} :: Step)

-- | The end position of a step. If the position the last step in the leg,
-- this position is the same as the end position of the leg.
step_endPosition :: Lens.Lens' Step (Prelude.NonEmpty Prelude.Double)
step_endPosition :: (NonEmpty Double -> f (NonEmpty Double)) -> Step -> f Step
step_endPosition = (Step -> Sensitive (NonEmpty Double))
-> (Step -> Sensitive (NonEmpty Double) -> Step)
-> Lens
     Step
     Step
     (Sensitive (NonEmpty Double))
     (Sensitive (NonEmpty Double))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Step' {Sensitive (NonEmpty Double)
endPosition :: Sensitive (NonEmpty Double)
$sel:endPosition:Step' :: Step -> Sensitive (NonEmpty Double)
endPosition} -> Sensitive (NonEmpty Double)
endPosition) (\s :: Step
s@Step' {} Sensitive (NonEmpty Double)
a -> Step
s {$sel:endPosition:Step' :: Sensitive (NonEmpty Double)
endPosition = Sensitive (NonEmpty Double)
a} :: Step) ((Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double)))
 -> Step -> f Step)
-> ((NonEmpty Double -> f (NonEmpty Double))
    -> Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double)))
-> (NonEmpty Double -> f (NonEmpty Double))
-> Step
-> f Step
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Double -> f (NonEmpty Double))
-> Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double))
forall a. Iso' (Sensitive a) a
Core._Sensitive ((NonEmpty Double -> f (NonEmpty Double))
 -> Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double)))
-> ((NonEmpty Double -> f (NonEmpty Double))
    -> NonEmpty Double -> f (NonEmpty Double))
-> (NonEmpty Double -> f (NonEmpty Double))
-> Sensitive (NonEmpty Double)
-> f (Sensitive (NonEmpty Double))
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Double -> f (NonEmpty Double))
-> NonEmpty Double -> f (NonEmpty Double)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The starting position of a step. If the position is the first step in
-- the leg, this position is the same as the start position of the leg.
step_startPosition :: Lens.Lens' Step (Prelude.NonEmpty Prelude.Double)
step_startPosition :: (NonEmpty Double -> f (NonEmpty Double)) -> Step -> f Step
step_startPosition = (Step -> Sensitive (NonEmpty Double))
-> (Step -> Sensitive (NonEmpty Double) -> Step)
-> Lens
     Step
     Step
     (Sensitive (NonEmpty Double))
     (Sensitive (NonEmpty Double))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Step' {Sensitive (NonEmpty Double)
startPosition :: Sensitive (NonEmpty Double)
$sel:startPosition:Step' :: Step -> Sensitive (NonEmpty Double)
startPosition} -> Sensitive (NonEmpty Double)
startPosition) (\s :: Step
s@Step' {} Sensitive (NonEmpty Double)
a -> Step
s {$sel:startPosition:Step' :: Sensitive (NonEmpty Double)
startPosition = Sensitive (NonEmpty Double)
a} :: Step) ((Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double)))
 -> Step -> f Step)
-> ((NonEmpty Double -> f (NonEmpty Double))
    -> Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double)))
-> (NonEmpty Double -> f (NonEmpty Double))
-> Step
-> f Step
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Double -> f (NonEmpty Double))
-> Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double))
forall a. Iso' (Sensitive a) a
Core._Sensitive ((NonEmpty Double -> f (NonEmpty Double))
 -> Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double)))
-> ((NonEmpty Double -> f (NonEmpty Double))
    -> NonEmpty Double -> f (NonEmpty Double))
-> (NonEmpty Double -> f (NonEmpty Double))
-> Sensitive (NonEmpty Double)
-> f (Sensitive (NonEmpty Double))
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Double -> f (NonEmpty Double))
-> NonEmpty Double -> f (NonEmpty Double)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON Step where
  parseJSON :: Value -> Parser Step
parseJSON =
    String -> (Object -> Parser Step) -> Value -> Parser Step
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Step"
      ( \Object
x ->
          Maybe Natural
-> Double
-> Double
-> Sensitive (NonEmpty Double)
-> Sensitive (NonEmpty Double)
-> Step
Step'
            (Maybe Natural
 -> Double
 -> Double
 -> Sensitive (NonEmpty Double)
 -> Sensitive (NonEmpty Double)
 -> Step)
-> Parser (Maybe Natural)
-> Parser
     (Double
      -> Double
      -> Sensitive (NonEmpty Double)
      -> Sensitive (NonEmpty Double)
      -> Step)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"GeometryOffset")
            Parser
  (Double
   -> Double
   -> Sensitive (NonEmpty Double)
   -> Sensitive (NonEmpty Double)
   -> Step)
-> Parser Double
-> Parser
     (Double
      -> Sensitive (NonEmpty Double)
      -> Sensitive (NonEmpty Double)
      -> Step)
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
"Distance")
            Parser
  (Double
   -> Sensitive (NonEmpty Double)
   -> Sensitive (NonEmpty Double)
   -> Step)
-> Parser Double
-> Parser
     (Sensitive (NonEmpty Double)
      -> Sensitive (NonEmpty Double) -> Step)
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
"DurationSeconds")
            Parser
  (Sensitive (NonEmpty Double)
   -> Sensitive (NonEmpty Double) -> Step)
-> Parser (Sensitive (NonEmpty Double))
-> Parser (Sensitive (NonEmpty Double) -> Step)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Sensitive (NonEmpty Double))
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"EndPosition")
            Parser (Sensitive (NonEmpty Double) -> Step)
-> Parser (Sensitive (NonEmpty Double)) -> Parser Step
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Sensitive (NonEmpty Double))
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"StartPosition")
      )

instance Prelude.Hashable Step

instance Prelude.NFData Step