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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Location.Types.DistanceUnit
import qualified Amazonka.Prelude as Prelude

-- | A summary of the calculated route.
--
-- /See:/ 'newCalculateRouteSummary' smart constructor.
data CalculateRouteSummary = CalculateRouteSummary'
  { -- | The data provider of traffic and road network data used to calculate the
    -- route. Indicates one of the available providers:
    --
    -- -   @Esri@
    --
    -- -   @Here@
    --
    -- For more information about data providers, see
    -- <https://docs.aws.amazon.com/location/latest/developerguide/what-is-data-provider.html Amazon Location Service data providers>.
    CalculateRouteSummary -> Text
dataSource :: Prelude.Text,
    -- | The total distance covered by the route. The sum of the distance
    -- travelled between every stop on the route.
    --
    -- If Esri is the data source for the route calculator, the route distance
    -- can’t be greater than 400 km. If the route exceeds 400 km, the response
    -- is a @400 RoutesValidationException@ error.
    CalculateRouteSummary -> Double
distance :: Prelude.Double,
    -- | The unit of measurement for the distance.
    CalculateRouteSummary -> DistanceUnit
distanceUnit :: DistanceUnit,
    -- | The total travel time for the route measured in seconds. The sum of the
    -- travel time between every stop on the route.
    CalculateRouteSummary -> Double
durationSeconds :: Prelude.Double,
    -- | Specifies a geographical box surrounding a route. Used to zoom into a
    -- route when displaying it in a map. For example,
    -- @[min x, min y, max x, max y]@.
    --
    -- The first 2 @bbox@ parameters describe the lower southwest corner:
    --
    -- -   The first @bbox@ position is the X coordinate or longitude of the
    --     lower southwest corner.
    --
    -- -   The second @bbox@ position is the Y coordinate or latitude of the
    --     lower southwest corner.
    --
    -- The next 2 @bbox@ parameters describe the upper northeast corner:
    --
    -- -   The third @bbox@ position is the X coordinate, or longitude of the
    --     upper northeast corner.
    --
    -- -   The fourth @bbox@ position is the Y coordinate, or latitude of the
    --     upper northeast corner.
    CalculateRouteSummary -> Sensitive (NonEmpty Double)
routeBBox :: Core.Sensitive (Prelude.NonEmpty Prelude.Double)
  }
  deriving (CalculateRouteSummary -> CalculateRouteSummary -> Bool
(CalculateRouteSummary -> CalculateRouteSummary -> Bool)
-> (CalculateRouteSummary -> CalculateRouteSummary -> Bool)
-> Eq CalculateRouteSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CalculateRouteSummary -> CalculateRouteSummary -> Bool
$c/= :: CalculateRouteSummary -> CalculateRouteSummary -> Bool
== :: CalculateRouteSummary -> CalculateRouteSummary -> Bool
$c== :: CalculateRouteSummary -> CalculateRouteSummary -> Bool
Prelude.Eq, Int -> CalculateRouteSummary -> ShowS
[CalculateRouteSummary] -> ShowS
CalculateRouteSummary -> String
(Int -> CalculateRouteSummary -> ShowS)
-> (CalculateRouteSummary -> String)
-> ([CalculateRouteSummary] -> ShowS)
-> Show CalculateRouteSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CalculateRouteSummary] -> ShowS
$cshowList :: [CalculateRouteSummary] -> ShowS
show :: CalculateRouteSummary -> String
$cshow :: CalculateRouteSummary -> String
showsPrec :: Int -> CalculateRouteSummary -> ShowS
$cshowsPrec :: Int -> CalculateRouteSummary -> ShowS
Prelude.Show, (forall x. CalculateRouteSummary -> Rep CalculateRouteSummary x)
-> (forall x. Rep CalculateRouteSummary x -> CalculateRouteSummary)
-> Generic CalculateRouteSummary
forall x. Rep CalculateRouteSummary x -> CalculateRouteSummary
forall x. CalculateRouteSummary -> Rep CalculateRouteSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CalculateRouteSummary x -> CalculateRouteSummary
$cfrom :: forall x. CalculateRouteSummary -> Rep CalculateRouteSummary x
Prelude.Generic)

-- |
-- Create a value of 'CalculateRouteSummary' 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:
--
-- 'dataSource', 'calculateRouteSummary_dataSource' - The data provider of traffic and road network data used to calculate the
-- route. Indicates one of the available providers:
--
-- -   @Esri@
--
-- -   @Here@
--
-- For more information about data providers, see
-- <https://docs.aws.amazon.com/location/latest/developerguide/what-is-data-provider.html Amazon Location Service data providers>.
--
-- 'distance', 'calculateRouteSummary_distance' - The total distance covered by the route. The sum of the distance
-- travelled between every stop on the route.
--
-- If Esri is the data source for the route calculator, the route distance
-- can’t be greater than 400 km. If the route exceeds 400 km, the response
-- is a @400 RoutesValidationException@ error.
--
-- 'distanceUnit', 'calculateRouteSummary_distanceUnit' - The unit of measurement for the distance.
--
-- 'durationSeconds', 'calculateRouteSummary_durationSeconds' - The total travel time for the route measured in seconds. The sum of the
-- travel time between every stop on the route.
--
-- 'routeBBox', 'calculateRouteSummary_routeBBox' - Specifies a geographical box surrounding a route. Used to zoom into a
-- route when displaying it in a map. For example,
-- @[min x, min y, max x, max y]@.
--
-- The first 2 @bbox@ parameters describe the lower southwest corner:
--
-- -   The first @bbox@ position is the X coordinate or longitude of the
--     lower southwest corner.
--
-- -   The second @bbox@ position is the Y coordinate or latitude of the
--     lower southwest corner.
--
-- The next 2 @bbox@ parameters describe the upper northeast corner:
--
-- -   The third @bbox@ position is the X coordinate, or longitude of the
--     upper northeast corner.
--
-- -   The fourth @bbox@ position is the Y coordinate, or latitude of the
--     upper northeast corner.
newCalculateRouteSummary ::
  -- | 'dataSource'
  Prelude.Text ->
  -- | 'distance'
  Prelude.Double ->
  -- | 'distanceUnit'
  DistanceUnit ->
  -- | 'durationSeconds'
  Prelude.Double ->
  -- | 'routeBBox'
  Prelude.NonEmpty Prelude.Double ->
  CalculateRouteSummary
newCalculateRouteSummary :: Text
-> Double
-> DistanceUnit
-> Double
-> NonEmpty Double
-> CalculateRouteSummary
newCalculateRouteSummary
  Text
pDataSource_
  Double
pDistance_
  DistanceUnit
pDistanceUnit_
  Double
pDurationSeconds_
  NonEmpty Double
pRouteBBox_ =
    CalculateRouteSummary' :: Text
-> Double
-> DistanceUnit
-> Double
-> Sensitive (NonEmpty Double)
-> CalculateRouteSummary
CalculateRouteSummary'
      { $sel:dataSource:CalculateRouteSummary' :: Text
dataSource = Text
pDataSource_,
        $sel:distance:CalculateRouteSummary' :: Double
distance = Double
pDistance_,
        $sel:distanceUnit:CalculateRouteSummary' :: DistanceUnit
distanceUnit = DistanceUnit
pDistanceUnit_,
        $sel:durationSeconds:CalculateRouteSummary' :: Double
durationSeconds = Double
pDurationSeconds_,
        $sel:routeBBox:CalculateRouteSummary' :: Sensitive (NonEmpty Double)
routeBBox =
          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
pRouteBBox_
      }

-- | The data provider of traffic and road network data used to calculate the
-- route. Indicates one of the available providers:
--
-- -   @Esri@
--
-- -   @Here@
--
-- For more information about data providers, see
-- <https://docs.aws.amazon.com/location/latest/developerguide/what-is-data-provider.html Amazon Location Service data providers>.
calculateRouteSummary_dataSource :: Lens.Lens' CalculateRouteSummary Prelude.Text
calculateRouteSummary_dataSource :: (Text -> f Text)
-> CalculateRouteSummary -> f CalculateRouteSummary
calculateRouteSummary_dataSource = (CalculateRouteSummary -> Text)
-> (CalculateRouteSummary -> Text -> CalculateRouteSummary)
-> Lens CalculateRouteSummary CalculateRouteSummary Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CalculateRouteSummary' {Text
dataSource :: Text
$sel:dataSource:CalculateRouteSummary' :: CalculateRouteSummary -> Text
dataSource} -> Text
dataSource) (\s :: CalculateRouteSummary
s@CalculateRouteSummary' {} Text
a -> CalculateRouteSummary
s {$sel:dataSource:CalculateRouteSummary' :: Text
dataSource = Text
a} :: CalculateRouteSummary)

-- | The total distance covered by the route. The sum of the distance
-- travelled between every stop on the route.
--
-- If Esri is the data source for the route calculator, the route distance
-- can’t be greater than 400 km. If the route exceeds 400 km, the response
-- is a @400 RoutesValidationException@ error.
calculateRouteSummary_distance :: Lens.Lens' CalculateRouteSummary Prelude.Double
calculateRouteSummary_distance :: (Double -> f Double)
-> CalculateRouteSummary -> f CalculateRouteSummary
calculateRouteSummary_distance = (CalculateRouteSummary -> Double)
-> (CalculateRouteSummary -> Double -> CalculateRouteSummary)
-> Lens CalculateRouteSummary CalculateRouteSummary Double Double
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CalculateRouteSummary' {Double
distance :: Double
$sel:distance:CalculateRouteSummary' :: CalculateRouteSummary -> Double
distance} -> Double
distance) (\s :: CalculateRouteSummary
s@CalculateRouteSummary' {} Double
a -> CalculateRouteSummary
s {$sel:distance:CalculateRouteSummary' :: Double
distance = Double
a} :: CalculateRouteSummary)

-- | The unit of measurement for the distance.
calculateRouteSummary_distanceUnit :: Lens.Lens' CalculateRouteSummary DistanceUnit
calculateRouteSummary_distanceUnit :: (DistanceUnit -> f DistanceUnit)
-> CalculateRouteSummary -> f CalculateRouteSummary
calculateRouteSummary_distanceUnit = (CalculateRouteSummary -> DistanceUnit)
-> (CalculateRouteSummary -> DistanceUnit -> CalculateRouteSummary)
-> Lens
     CalculateRouteSummary
     CalculateRouteSummary
     DistanceUnit
     DistanceUnit
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CalculateRouteSummary' {DistanceUnit
distanceUnit :: DistanceUnit
$sel:distanceUnit:CalculateRouteSummary' :: CalculateRouteSummary -> DistanceUnit
distanceUnit} -> DistanceUnit
distanceUnit) (\s :: CalculateRouteSummary
s@CalculateRouteSummary' {} DistanceUnit
a -> CalculateRouteSummary
s {$sel:distanceUnit:CalculateRouteSummary' :: DistanceUnit
distanceUnit = DistanceUnit
a} :: CalculateRouteSummary)

-- | The total travel time for the route measured in seconds. The sum of the
-- travel time between every stop on the route.
calculateRouteSummary_durationSeconds :: Lens.Lens' CalculateRouteSummary Prelude.Double
calculateRouteSummary_durationSeconds :: (Double -> f Double)
-> CalculateRouteSummary -> f CalculateRouteSummary
calculateRouteSummary_durationSeconds = (CalculateRouteSummary -> Double)
-> (CalculateRouteSummary -> Double -> CalculateRouteSummary)
-> Lens CalculateRouteSummary CalculateRouteSummary Double Double
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CalculateRouteSummary' {Double
durationSeconds :: Double
$sel:durationSeconds:CalculateRouteSummary' :: CalculateRouteSummary -> Double
durationSeconds} -> Double
durationSeconds) (\s :: CalculateRouteSummary
s@CalculateRouteSummary' {} Double
a -> CalculateRouteSummary
s {$sel:durationSeconds:CalculateRouteSummary' :: Double
durationSeconds = Double
a} :: CalculateRouteSummary)

-- | Specifies a geographical box surrounding a route. Used to zoom into a
-- route when displaying it in a map. For example,
-- @[min x, min y, max x, max y]@.
--
-- The first 2 @bbox@ parameters describe the lower southwest corner:
--
-- -   The first @bbox@ position is the X coordinate or longitude of the
--     lower southwest corner.
--
-- -   The second @bbox@ position is the Y coordinate or latitude of the
--     lower southwest corner.
--
-- The next 2 @bbox@ parameters describe the upper northeast corner:
--
-- -   The third @bbox@ position is the X coordinate, or longitude of the
--     upper northeast corner.
--
-- -   The fourth @bbox@ position is the Y coordinate, or latitude of the
--     upper northeast corner.
calculateRouteSummary_routeBBox :: Lens.Lens' CalculateRouteSummary (Prelude.NonEmpty Prelude.Double)
calculateRouteSummary_routeBBox :: (NonEmpty Double -> f (NonEmpty Double))
-> CalculateRouteSummary -> f CalculateRouteSummary
calculateRouteSummary_routeBBox = (CalculateRouteSummary -> Sensitive (NonEmpty Double))
-> (CalculateRouteSummary
    -> Sensitive (NonEmpty Double) -> CalculateRouteSummary)
-> Lens
     CalculateRouteSummary
     CalculateRouteSummary
     (Sensitive (NonEmpty Double))
     (Sensitive (NonEmpty Double))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CalculateRouteSummary' {Sensitive (NonEmpty Double)
routeBBox :: Sensitive (NonEmpty Double)
$sel:routeBBox:CalculateRouteSummary' :: CalculateRouteSummary -> Sensitive (NonEmpty Double)
routeBBox} -> Sensitive (NonEmpty Double)
routeBBox) (\s :: CalculateRouteSummary
s@CalculateRouteSummary' {} Sensitive (NonEmpty Double)
a -> CalculateRouteSummary
s {$sel:routeBBox:CalculateRouteSummary' :: Sensitive (NonEmpty Double)
routeBBox = Sensitive (NonEmpty Double)
a} :: CalculateRouteSummary) ((Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double)))
 -> CalculateRouteSummary -> f CalculateRouteSummary)
-> ((NonEmpty Double -> f (NonEmpty Double))
    -> Sensitive (NonEmpty Double) -> f (Sensitive (NonEmpty Double)))
-> (NonEmpty Double -> f (NonEmpty Double))
-> CalculateRouteSummary
-> f CalculateRouteSummary
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 CalculateRouteSummary where
  parseJSON :: Value -> Parser CalculateRouteSummary
parseJSON =
    String
-> (Object -> Parser CalculateRouteSummary)
-> Value
-> Parser CalculateRouteSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CalculateRouteSummary"
      ( \Object
x ->
          Text
-> Double
-> DistanceUnit
-> Double
-> Sensitive (NonEmpty Double)
-> CalculateRouteSummary
CalculateRouteSummary'
            (Text
 -> Double
 -> DistanceUnit
 -> Double
 -> Sensitive (NonEmpty Double)
 -> CalculateRouteSummary)
-> Parser Text
-> Parser
     (Double
      -> DistanceUnit
      -> Double
      -> Sensitive (NonEmpty Double)
      -> CalculateRouteSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"DataSource")
            Parser
  (Double
   -> DistanceUnit
   -> Double
   -> Sensitive (NonEmpty Double)
   -> CalculateRouteSummary)
-> Parser Double
-> Parser
     (DistanceUnit
      -> Double -> Sensitive (NonEmpty Double) -> CalculateRouteSummary)
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
  (DistanceUnit
   -> Double -> Sensitive (NonEmpty Double) -> CalculateRouteSummary)
-> Parser DistanceUnit
-> Parser
     (Double -> Sensitive (NonEmpty Double) -> CalculateRouteSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser DistanceUnit
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"DistanceUnit")
            Parser
  (Double -> Sensitive (NonEmpty Double) -> CalculateRouteSummary)
-> Parser Double
-> Parser (Sensitive (NonEmpty Double) -> CalculateRouteSummary)
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) -> CalculateRouteSummary)
-> Parser (Sensitive (NonEmpty Double))
-> Parser CalculateRouteSummary
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
"RouteBBox")
      )

instance Prelude.Hashable CalculateRouteSummary

instance Prelude.NFData CalculateRouteSummary