{-# 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.Rekognition.Types.Landmark
-- 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.Rekognition.Types.Landmark where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.Rekognition.Types.LandmarkType

-- | Indicates the location of the landmark on the face.
--
-- /See:/ 'newLandmark' smart constructor.
data Landmark = Landmark'
  { -- | Type of landmark.
    Landmark -> Maybe LandmarkType
type' :: Prelude.Maybe LandmarkType,
    -- | The x-coordinate of the landmark expressed as a ratio of the width of
    -- the image. The x-coordinate is measured from the left-side of the image.
    -- For example, if the image is 700 pixels wide and the x-coordinate of the
    -- landmark is at 350 pixels, this value is 0.5.
    Landmark -> Maybe Double
x :: Prelude.Maybe Prelude.Double,
    -- | The y-coordinate of the landmark expressed as a ratio of the height of
    -- the image. The y-coordinate is measured from the top of the image. For
    -- example, if the image height is 200 pixels and the y-coordinate of the
    -- landmark is at 50 pixels, this value is 0.25.
    Landmark -> Maybe Double
y :: Prelude.Maybe Prelude.Double
  }
  deriving (Landmark -> Landmark -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Landmark -> Landmark -> Bool
$c/= :: Landmark -> Landmark -> Bool
== :: Landmark -> Landmark -> Bool
$c== :: Landmark -> Landmark -> Bool
Prelude.Eq, ReadPrec [Landmark]
ReadPrec Landmark
Int -> ReadS Landmark
ReadS [Landmark]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Landmark]
$creadListPrec :: ReadPrec [Landmark]
readPrec :: ReadPrec Landmark
$creadPrec :: ReadPrec Landmark
readList :: ReadS [Landmark]
$creadList :: ReadS [Landmark]
readsPrec :: Int -> ReadS Landmark
$creadsPrec :: Int -> ReadS Landmark
Prelude.Read, Int -> Landmark -> ShowS
[Landmark] -> ShowS
Landmark -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Landmark] -> ShowS
$cshowList :: [Landmark] -> ShowS
show :: Landmark -> String
$cshow :: Landmark -> String
showsPrec :: Int -> Landmark -> ShowS
$cshowsPrec :: Int -> Landmark -> ShowS
Prelude.Show, forall x. Rep Landmark x -> Landmark
forall x. Landmark -> Rep Landmark x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Landmark x -> Landmark
$cfrom :: forall x. Landmark -> Rep Landmark x
Prelude.Generic)

-- |
-- Create a value of 'Landmark' 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:
--
-- 'type'', 'landmark_type' - Type of landmark.
--
-- 'x', 'landmark_x' - The x-coordinate of the landmark expressed as a ratio of the width of
-- the image. The x-coordinate is measured from the left-side of the image.
-- For example, if the image is 700 pixels wide and the x-coordinate of the
-- landmark is at 350 pixels, this value is 0.5.
--
-- 'y', 'landmark_y' - The y-coordinate of the landmark expressed as a ratio of the height of
-- the image. The y-coordinate is measured from the top of the image. For
-- example, if the image height is 200 pixels and the y-coordinate of the
-- landmark is at 50 pixels, this value is 0.25.
newLandmark ::
  Landmark
newLandmark :: Landmark
newLandmark =
  Landmark'
    { $sel:type':Landmark' :: Maybe LandmarkType
type' = forall a. Maybe a
Prelude.Nothing,
      $sel:x:Landmark' :: Maybe Double
x = forall a. Maybe a
Prelude.Nothing,
      $sel:y:Landmark' :: Maybe Double
y = forall a. Maybe a
Prelude.Nothing
    }

-- | Type of landmark.
landmark_type :: Lens.Lens' Landmark (Prelude.Maybe LandmarkType)
landmark_type :: Lens' Landmark (Maybe LandmarkType)
landmark_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Landmark' {Maybe LandmarkType
type' :: Maybe LandmarkType
$sel:type':Landmark' :: Landmark -> Maybe LandmarkType
type'} -> Maybe LandmarkType
type') (\s :: Landmark
s@Landmark' {} Maybe LandmarkType
a -> Landmark
s {$sel:type':Landmark' :: Maybe LandmarkType
type' = Maybe LandmarkType
a} :: Landmark)

-- | The x-coordinate of the landmark expressed as a ratio of the width of
-- the image. The x-coordinate is measured from the left-side of the image.
-- For example, if the image is 700 pixels wide and the x-coordinate of the
-- landmark is at 350 pixels, this value is 0.5.
landmark_x :: Lens.Lens' Landmark (Prelude.Maybe Prelude.Double)
landmark_x :: Lens' Landmark (Maybe Double)
landmark_x = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Landmark' {Maybe Double
x :: Maybe Double
$sel:x:Landmark' :: Landmark -> Maybe Double
x} -> Maybe Double
x) (\s :: Landmark
s@Landmark' {} Maybe Double
a -> Landmark
s {$sel:x:Landmark' :: Maybe Double
x = Maybe Double
a} :: Landmark)

-- | The y-coordinate of the landmark expressed as a ratio of the height of
-- the image. The y-coordinate is measured from the top of the image. For
-- example, if the image height is 200 pixels and the y-coordinate of the
-- landmark is at 50 pixels, this value is 0.25.
landmark_y :: Lens.Lens' Landmark (Prelude.Maybe Prelude.Double)
landmark_y :: Lens' Landmark (Maybe Double)
landmark_y = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Landmark' {Maybe Double
y :: Maybe Double
$sel:y:Landmark' :: Landmark -> Maybe Double
y} -> Maybe Double
y) (\s :: Landmark
s@Landmark' {} Maybe Double
a -> Landmark
s {$sel:y:Landmark' :: Maybe Double
y = Maybe Double
a} :: Landmark)

instance Data.FromJSON Landmark where
  parseJSON :: Value -> Parser Landmark
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Landmark"
      ( \Object
x ->
          Maybe LandmarkType -> Maybe Double -> Maybe Double -> Landmark
Landmark'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Type")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"X")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Y")
      )

instance Prelude.Hashable Landmark where
  hashWithSalt :: Int -> Landmark -> Int
hashWithSalt Int
_salt Landmark' {Maybe Double
Maybe LandmarkType
y :: Maybe Double
x :: Maybe Double
type' :: Maybe LandmarkType
$sel:y:Landmark' :: Landmark -> Maybe Double
$sel:x:Landmark' :: Landmark -> Maybe Double
$sel:type':Landmark' :: Landmark -> Maybe LandmarkType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe LandmarkType
type'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
x
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
y

instance Prelude.NFData Landmark where
  rnf :: Landmark -> ()
rnf Landmark' {Maybe Double
Maybe LandmarkType
y :: Maybe Double
x :: Maybe Double
type' :: Maybe LandmarkType
$sel:y:Landmark' :: Landmark -> Maybe Double
$sel:x:Landmark' :: Landmark -> Maybe Double
$sel:type':Landmark' :: Landmark -> Maybe LandmarkType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe LandmarkType
type'
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
x
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
y