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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(Landmark -> Landmark -> Bool)
-> (Landmark -> Landmark -> Bool) -> Eq Landmark
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]
(Int -> ReadS Landmark)
-> ReadS [Landmark]
-> ReadPrec Landmark
-> ReadPrec [Landmark]
-> Read 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
(Int -> Landmark -> ShowS)
-> (Landmark -> String) -> ([Landmark] -> ShowS) -> Show Landmark
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. Landmark -> Rep Landmark x)
-> (forall x. Rep Landmark x -> Landmark) -> Generic Landmark
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' :: Maybe LandmarkType -> Maybe Double -> Maybe Double -> Landmark
Landmark'
    { $sel:type':Landmark' :: Maybe LandmarkType
type' = Maybe LandmarkType
forall a. Maybe a
Prelude.Nothing,
      $sel:x:Landmark' :: Maybe Double
x = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:y:Landmark' :: Maybe Double
y = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | Type of landmark.
landmark_type :: Lens.Lens' Landmark (Prelude.Maybe LandmarkType)
landmark_type :: (Maybe LandmarkType -> f (Maybe LandmarkType))
-> Landmark -> f Landmark
landmark_type = (Landmark -> Maybe LandmarkType)
-> (Landmark -> Maybe LandmarkType -> Landmark)
-> Lens Landmark Landmark (Maybe LandmarkType) (Maybe LandmarkType)
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 :: (Maybe Double -> f (Maybe Double)) -> Landmark -> f Landmark
landmark_x = (Landmark -> Maybe Double)
-> (Landmark -> Maybe Double -> Landmark)
-> Lens Landmark Landmark (Maybe Double) (Maybe Double)
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 :: (Maybe Double -> f (Maybe Double)) -> Landmark -> f Landmark
landmark_y = (Landmark -> Maybe Double)
-> (Landmark -> Maybe Double -> Landmark)
-> Lens Landmark Landmark (Maybe Double) (Maybe Double)
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 Core.FromJSON Landmark where
  parseJSON :: Value -> Parser Landmark
parseJSON =
    String -> (Object -> Parser Landmark) -> Value -> Parser Landmark
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Landmark"
      ( \Object
x ->
          Maybe LandmarkType -> Maybe Double -> Maybe Double -> Landmark
Landmark'
            (Maybe LandmarkType -> Maybe Double -> Maybe Double -> Landmark)
-> Parser (Maybe LandmarkType)
-> Parser (Maybe Double -> Maybe Double -> Landmark)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe LandmarkType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
            Parser (Maybe Double -> Maybe Double -> Landmark)
-> Parser (Maybe Double) -> Parser (Maybe Double -> Landmark)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"X")
            Parser (Maybe Double -> Landmark)
-> Parser (Maybe Double) -> Parser Landmark
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Y")
      )

instance Prelude.Hashable Landmark

instance Prelude.NFData Landmark