{-# 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.Leg -- 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.Leg where import qualified Amazonka.Core as Core import qualified Amazonka.Lens as Lens import Amazonka.Location.Types.LegGeometry import Amazonka.Location.Types.Step import qualified Amazonka.Prelude as Prelude -- | Contains the calculated route\'s details for each path between a pair of -- positions. The number of legs returned corresponds to one fewer than the -- total number of positions in the request. -- -- For example, a route with a departure position and destination position -- returns one leg with the positions -- <https://docs.aws.amazon.com/location/latest/developerguide/calculate-route.html#snap-to-nearby-road snapped to a nearby road>: -- -- - The @StartPosition@ is the departure position. -- -- - The @EndPosition@ is the destination position. -- -- A route with a waypoint between the departure and destination position -- returns two legs with the positions snapped to a nearby road: -- -- - Leg 1: The @StartPosition@ is the departure position . The -- @EndPosition@ is the waypoint positon. -- -- - Leg 2: The @StartPosition@ is the waypoint position. The -- @EndPosition@ is the destination position. -- -- /See:/ 'newLeg' smart constructor. data Leg = Leg' { -- | Contains the calculated route\'s path as a linestring geometry. Leg -> Maybe LegGeometry geometry :: Prelude.Maybe LegGeometry, -- | The distance between the leg\'s @StartPosition@ and @EndPosition@ along -- a calculated route. -- -- - The default measurement is @Kilometers@ unless the request specifies -- a @DistanceUnit@ of @Miles@. Leg -> Double distance :: Prelude.Double, -- | The estimated travel time between the leg\'s @StartPosition@ and -- @EndPosition@. The travel mode and departure time that you specify in -- the request determines the calculated time. Leg -> Double durationSeconds :: Prelude.Double, -- | The terminating position of the leg. Follows the format -- @[longitude,latitude]@. -- -- If the @EndPosition@ isn\'t located on a road, it\'s -- <https://docs.aws.amazon.com/location/latest/developerguide/calculate-route.html#snap-to-nearby-road snapped to a nearby road>. Leg -> Sensitive (NonEmpty Double) endPosition :: Core.Sensitive (Prelude.NonEmpty Prelude.Double), -- | The starting position of the leg. Follows the format -- @[longitude,latitude]@. -- -- If the @StartPosition@ isn\'t located on a road, it\'s -- <https://docs.aws.amazon.com/location/latest/developerguide/calculate-route.html#snap-to-nearby-road snapped to a nearby road>. Leg -> Sensitive (NonEmpty Double) startPosition :: Core.Sensitive (Prelude.NonEmpty Prelude.Double), -- | Contains a list of steps, which represent subsections of a leg. Each -- step provides instructions for how to move to the next step in the leg -- such as the step\'s start position, end position, travel distance, -- travel duration, and geometry offset. Leg -> [Step] steps :: [Step] } deriving (Leg -> Leg -> Bool (Leg -> Leg -> Bool) -> (Leg -> Leg -> Bool) -> Eq Leg forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: Leg -> Leg -> Bool $c/= :: Leg -> Leg -> Bool == :: Leg -> Leg -> Bool $c== :: Leg -> Leg -> Bool Prelude.Eq, Int -> Leg -> ShowS [Leg] -> ShowS Leg -> String (Int -> Leg -> ShowS) -> (Leg -> String) -> ([Leg] -> ShowS) -> Show Leg forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [Leg] -> ShowS $cshowList :: [Leg] -> ShowS show :: Leg -> String $cshow :: Leg -> String showsPrec :: Int -> Leg -> ShowS $cshowsPrec :: Int -> Leg -> ShowS Prelude.Show, (forall x. Leg -> Rep Leg x) -> (forall x. Rep Leg x -> Leg) -> Generic Leg forall x. Rep Leg x -> Leg forall x. Leg -> Rep Leg x forall a. (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a $cto :: forall x. Rep Leg x -> Leg $cfrom :: forall x. Leg -> Rep Leg x Prelude.Generic) -- | -- Create a value of 'Leg' 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: -- -- 'geometry', 'leg_geometry' - Contains the calculated route\'s path as a linestring geometry. -- -- 'distance', 'leg_distance' - The distance between the leg\'s @StartPosition@ and @EndPosition@ along -- a calculated route. -- -- - The default measurement is @Kilometers@ unless the request specifies -- a @DistanceUnit@ of @Miles@. -- -- 'durationSeconds', 'leg_durationSeconds' - The estimated travel time between the leg\'s @StartPosition@ and -- @EndPosition@. The travel mode and departure time that you specify in -- the request determines the calculated time. -- -- 'endPosition', 'leg_endPosition' - The terminating position of the leg. Follows the format -- @[longitude,latitude]@. -- -- If the @EndPosition@ isn\'t located on a road, it\'s -- <https://docs.aws.amazon.com/location/latest/developerguide/calculate-route.html#snap-to-nearby-road snapped to a nearby road>. -- -- 'startPosition', 'leg_startPosition' - The starting position of the leg. Follows the format -- @[longitude,latitude]@. -- -- If the @StartPosition@ isn\'t located on a road, it\'s -- <https://docs.aws.amazon.com/location/latest/developerguide/calculate-route.html#snap-to-nearby-road snapped to a nearby road>. -- -- 'steps', 'leg_steps' - Contains a list of steps, which represent subsections of a leg. Each -- step provides instructions for how to move to the next step in the leg -- such as the step\'s start position, end position, travel distance, -- travel duration, and geometry offset. newLeg :: -- | 'distance' Prelude.Double -> -- | 'durationSeconds' Prelude.Double -> -- | 'endPosition' Prelude.NonEmpty Prelude.Double -> -- | 'startPosition' Prelude.NonEmpty Prelude.Double -> Leg newLeg :: Double -> Double -> NonEmpty Double -> NonEmpty Double -> Leg newLeg Double pDistance_ Double pDurationSeconds_ NonEmpty Double pEndPosition_ NonEmpty Double pStartPosition_ = Leg' :: Maybe LegGeometry -> Double -> Double -> Sensitive (NonEmpty Double) -> Sensitive (NonEmpty Double) -> [Step] -> Leg Leg' { $sel:geometry:Leg' :: Maybe LegGeometry geometry = Maybe LegGeometry forall a. Maybe a Prelude.Nothing, $sel:distance:Leg' :: Double distance = Double pDistance_, $sel:durationSeconds:Leg' :: Double durationSeconds = Double pDurationSeconds_, $sel:endPosition:Leg' :: 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:Leg' :: 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_, $sel:steps:Leg' :: [Step] steps = [Step] forall a. Monoid a => a Prelude.mempty } -- | Contains the calculated route\'s path as a linestring geometry. leg_geometry :: Lens.Lens' Leg (Prelude.Maybe LegGeometry) leg_geometry :: (Maybe LegGeometry -> f (Maybe LegGeometry)) -> Leg -> f Leg leg_geometry = (Leg -> Maybe LegGeometry) -> (Leg -> Maybe LegGeometry -> Leg) -> Lens Leg Leg (Maybe LegGeometry) (Maybe LegGeometry) forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b Lens.lens (\Leg' {Maybe LegGeometry geometry :: Maybe LegGeometry $sel:geometry:Leg' :: Leg -> Maybe LegGeometry geometry} -> Maybe LegGeometry geometry) (\s :: Leg s@Leg' {} Maybe LegGeometry a -> Leg s {$sel:geometry:Leg' :: Maybe LegGeometry geometry = Maybe LegGeometry a} :: Leg) -- | The distance between the leg\'s @StartPosition@ and @EndPosition@ along -- a calculated route. -- -- - The default measurement is @Kilometers@ unless the request specifies -- a @DistanceUnit@ of @Miles@. leg_distance :: Lens.Lens' Leg Prelude.Double leg_distance :: (Double -> f Double) -> Leg -> f Leg leg_distance = (Leg -> Double) -> (Leg -> Double -> Leg) -> Lens Leg Leg Double Double forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b Lens.lens (\Leg' {Double distance :: Double $sel:distance:Leg' :: Leg -> Double distance} -> Double distance) (\s :: Leg s@Leg' {} Double a -> Leg s {$sel:distance:Leg' :: Double distance = Double a} :: Leg) -- | The estimated travel time between the leg\'s @StartPosition@ and -- @EndPosition@. The travel mode and departure time that you specify in -- the request determines the calculated time. leg_durationSeconds :: Lens.Lens' Leg Prelude.Double leg_durationSeconds :: (Double -> f Double) -> Leg -> f Leg leg_durationSeconds = (Leg -> Double) -> (Leg -> Double -> Leg) -> Lens Leg Leg Double Double forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b Lens.lens (\Leg' {Double durationSeconds :: Double $sel:durationSeconds:Leg' :: Leg -> Double durationSeconds} -> Double durationSeconds) (\s :: Leg s@Leg' {} Double a -> Leg s {$sel:durationSeconds:Leg' :: Double durationSeconds = Double a} :: Leg) -- | The terminating position of the leg. Follows the format -- @[longitude,latitude]@. -- -- If the @EndPosition@ isn\'t located on a road, it\'s -- <https://docs.aws.amazon.com/location/latest/developerguide/calculate-route.html#snap-to-nearby-road snapped to a nearby road>. leg_endPosition :: Lens.Lens' Leg (Prelude.NonEmpty Prelude.Double) leg_endPosition :: (NonEmpty Double -> f (NonEmpty Double)) -> Leg -> f Leg leg_endPosition = (Leg -> Sensitive (NonEmpty Double)) -> (Leg -> Sensitive (NonEmpty Double) -> Leg) -> Lens Leg Leg (Sensitive (NonEmpty Double)) (Sensitive (NonEmpty Double)) forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b Lens.lens (\Leg' {Sensitive (NonEmpty Double) endPosition :: Sensitive (NonEmpty Double) $sel:endPosition:Leg' :: Leg -> Sensitive (NonEmpty Double) endPosition} -> Sensitive (NonEmpty Double) endPosition) (\s :: Leg s@Leg' {} Sensitive (NonEmpty Double) a -> Leg s {$sel:endPosition:Leg' :: Sensitive (NonEmpty Double) endPosition = Sensitive (NonEmpty Double) a} :: Leg) ((Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double))) -> Leg -> f Leg) -> ((NonEmpty Double -> f (NonEmpty Double)) -> Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double))) -> (NonEmpty Double -> f (NonEmpty Double)) -> Leg -> f Leg 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 the leg. Follows the format -- @[longitude,latitude]@. -- -- If the @StartPosition@ isn\'t located on a road, it\'s -- <https://docs.aws.amazon.com/location/latest/developerguide/calculate-route.html#snap-to-nearby-road snapped to a nearby road>. leg_startPosition :: Lens.Lens' Leg (Prelude.NonEmpty Prelude.Double) leg_startPosition :: (NonEmpty Double -> f (NonEmpty Double)) -> Leg -> f Leg leg_startPosition = (Leg -> Sensitive (NonEmpty Double)) -> (Leg -> Sensitive (NonEmpty Double) -> Leg) -> Lens Leg Leg (Sensitive (NonEmpty Double)) (Sensitive (NonEmpty Double)) forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b Lens.lens (\Leg' {Sensitive (NonEmpty Double) startPosition :: Sensitive (NonEmpty Double) $sel:startPosition:Leg' :: Leg -> Sensitive (NonEmpty Double) startPosition} -> Sensitive (NonEmpty Double) startPosition) (\s :: Leg s@Leg' {} Sensitive (NonEmpty Double) a -> Leg s {$sel:startPosition:Leg' :: Sensitive (NonEmpty Double) startPosition = Sensitive (NonEmpty Double) a} :: Leg) ((Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double))) -> Leg -> f Leg) -> ((NonEmpty Double -> f (NonEmpty Double)) -> Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double))) -> (NonEmpty Double -> f (NonEmpty Double)) -> Leg -> f Leg 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 -- | Contains a list of steps, which represent subsections of a leg. Each -- step provides instructions for how to move to the next step in the leg -- such as the step\'s start position, end position, travel distance, -- travel duration, and geometry offset. leg_steps :: Lens.Lens' Leg [Step] leg_steps :: ([Step] -> f [Step]) -> Leg -> f Leg leg_steps = (Leg -> [Step]) -> (Leg -> [Step] -> Leg) -> Lens Leg Leg [Step] [Step] forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b Lens.lens (\Leg' {[Step] steps :: [Step] $sel:steps:Leg' :: Leg -> [Step] steps} -> [Step] steps) (\s :: Leg s@Leg' {} [Step] a -> Leg s {$sel:steps:Leg' :: [Step] steps = [Step] a} :: Leg) (([Step] -> f [Step]) -> Leg -> f Leg) -> (([Step] -> f [Step]) -> [Step] -> f [Step]) -> ([Step] -> f [Step]) -> Leg -> f Leg forall b c a. (b -> c) -> (a -> b) -> a -> c Prelude.. ([Step] -> f [Step]) -> [Step] -> f [Step] forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b Lens.coerced instance Core.FromJSON Leg where parseJSON :: Value -> Parser Leg parseJSON = String -> (Object -> Parser Leg) -> Value -> Parser Leg forall a. String -> (Object -> Parser a) -> Value -> Parser a Core.withObject String "Leg" ( \Object x -> Maybe LegGeometry -> Double -> Double -> Sensitive (NonEmpty Double) -> Sensitive (NonEmpty Double) -> [Step] -> Leg Leg' (Maybe LegGeometry -> Double -> Double -> Sensitive (NonEmpty Double) -> Sensitive (NonEmpty Double) -> [Step] -> Leg) -> Parser (Maybe LegGeometry) -> Parser (Double -> Double -> Sensitive (NonEmpty Double) -> Sensitive (NonEmpty Double) -> [Step] -> Leg) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b Prelude.<$> (Object x Object -> Text -> Parser (Maybe LegGeometry) forall a. FromJSON a => Object -> Text -> Parser (Maybe a) Core..:? Text "Geometry") Parser (Double -> Double -> Sensitive (NonEmpty Double) -> Sensitive (NonEmpty Double) -> [Step] -> Leg) -> Parser Double -> Parser (Double -> Sensitive (NonEmpty Double) -> Sensitive (NonEmpty Double) -> [Step] -> Leg) 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] -> Leg) -> Parser Double -> Parser (Sensitive (NonEmpty Double) -> Sensitive (NonEmpty Double) -> [Step] -> Leg) 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] -> Leg) -> Parser (Sensitive (NonEmpty Double)) -> Parser (Sensitive (NonEmpty Double) -> [Step] -> Leg) 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] -> Leg) -> Parser (Sensitive (NonEmpty Double)) -> Parser ([Step] -> Leg) 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") Parser ([Step] -> Leg) -> Parser [Step] -> Parser Leg forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b Prelude.<*> (Object x Object -> Text -> Parser (Maybe [Step]) forall a. FromJSON a => Object -> Text -> Parser (Maybe a) Core..:? Text "Steps" Parser (Maybe [Step]) -> [Step] -> Parser [Step] forall a. Parser (Maybe a) -> a -> Parser a Core..!= [Step] forall a. Monoid a => a Prelude.mempty) ) instance Prelude.Hashable Leg instance Prelude.NFData Leg