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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 route distances.
    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 :: Data.Sensitive (Prelude.NonEmpty Prelude.Double)
  }
  deriving (CalculateRouteSummary -> CalculateRouteSummary -> Bool
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
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. 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 route distances.
--
-- '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'
      { $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 =
          forall a. Iso' (Sensitive a) a
Data._Sensitive
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
            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 :: Lens' CalculateRouteSummary Text
calculateRouteSummary_dataSource = 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 :: Lens' CalculateRouteSummary Double
calculateRouteSummary_distance = 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 route distances.
calculateRouteSummary_distanceUnit :: Lens.Lens' CalculateRouteSummary DistanceUnit
calculateRouteSummary_distanceUnit :: Lens' CalculateRouteSummary DistanceUnit
calculateRouteSummary_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 :: Lens' CalculateRouteSummary Double
calculateRouteSummary_durationSeconds = 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 :: Lens' CalculateRouteSummary (NonEmpty Double)
calculateRouteSummary_routeBBox = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON CalculateRouteSummary where
  parseJSON :: Value -> Parser CalculateRouteSummary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CalculateRouteSummary"
      ( \Object
x ->
          Text
-> Double
-> DistanceUnit
-> Double
-> Sensitive (NonEmpty Double)
-> CalculateRouteSummary
CalculateRouteSummary'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"DataSource")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Distance")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"DistanceUnit")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"DurationSeconds")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"RouteBBox")
      )

instance Prelude.Hashable CalculateRouteSummary where
  hashWithSalt :: Int -> CalculateRouteSummary -> Int
hashWithSalt Int
_salt CalculateRouteSummary' {Double
Text
Sensitive (NonEmpty Double)
DistanceUnit
routeBBox :: Sensitive (NonEmpty Double)
durationSeconds :: Double
distanceUnit :: DistanceUnit
distance :: Double
dataSource :: Text
$sel:routeBBox:CalculateRouteSummary' :: CalculateRouteSummary -> Sensitive (NonEmpty Double)
$sel:durationSeconds:CalculateRouteSummary' :: CalculateRouteSummary -> Double
$sel:distanceUnit:CalculateRouteSummary' :: CalculateRouteSummary -> DistanceUnit
$sel:distance:CalculateRouteSummary' :: CalculateRouteSummary -> Double
$sel:dataSource:CalculateRouteSummary' :: CalculateRouteSummary -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
dataSource
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Double
distance
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` DistanceUnit
distanceUnit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Double
durationSeconds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive (NonEmpty Double)
routeBBox

instance Prelude.NFData CalculateRouteSummary where
  rnf :: CalculateRouteSummary -> ()
rnf CalculateRouteSummary' {Double
Text
Sensitive (NonEmpty Double)
DistanceUnit
routeBBox :: Sensitive (NonEmpty Double)
durationSeconds :: Double
distanceUnit :: DistanceUnit
distance :: Double
dataSource :: Text
$sel:routeBBox:CalculateRouteSummary' :: CalculateRouteSummary -> Sensitive (NonEmpty Double)
$sel:durationSeconds:CalculateRouteSummary' :: CalculateRouteSummary -> Double
$sel:distanceUnit:CalculateRouteSummary' :: CalculateRouteSummary -> DistanceUnit
$sel:distance:CalculateRouteSummary' :: CalculateRouteSummary -> Double
$sel:dataSource:CalculateRouteSummary' :: CalculateRouteSummary -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
dataSource
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Double
distance
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf DistanceUnit
distanceUnit
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Double
durationSeconds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive (NonEmpty Double)
routeBBox