amazonka-textract-2.0: gen/Amazonka/Textract/Types/Geometry.hs
{-# 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.Textract.Types.Geometry
-- 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.Textract.Types.Geometry 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.Textract.Types.BoundingBox
import Amazonka.Textract.Types.Point
-- | Information about where the following items are located on a document
-- page: detected page, text, key-value pairs, tables, table cells, and
-- selection elements.
--
-- /See:/ 'newGeometry' smart constructor.
data Geometry = Geometry'
{ -- | An axis-aligned coarse representation of the location of the recognized
-- item on the document page.
boundingBox :: Prelude.Maybe BoundingBox,
-- | Within the bounding box, a fine-grained polygon around the recognized
-- item.
polygon :: Prelude.Maybe [Point]
}
deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic)
-- |
-- Create a value of 'Geometry' 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:
--
-- 'boundingBox', 'geometry_boundingBox' - An axis-aligned coarse representation of the location of the recognized
-- item on the document page.
--
-- 'polygon', 'geometry_polygon' - Within the bounding box, a fine-grained polygon around the recognized
-- item.
newGeometry ::
Geometry
newGeometry =
Geometry'
{ boundingBox = Prelude.Nothing,
polygon = Prelude.Nothing
}
-- | An axis-aligned coarse representation of the location of the recognized
-- item on the document page.
geometry_boundingBox :: Lens.Lens' Geometry (Prelude.Maybe BoundingBox)
geometry_boundingBox = Lens.lens (\Geometry' {boundingBox} -> boundingBox) (\s@Geometry' {} a -> s {boundingBox = a} :: Geometry)
-- | Within the bounding box, a fine-grained polygon around the recognized
-- item.
geometry_polygon :: Lens.Lens' Geometry (Prelude.Maybe [Point])
geometry_polygon = Lens.lens (\Geometry' {polygon} -> polygon) (\s@Geometry' {} a -> s {polygon = a} :: Geometry) Prelude.. Lens.mapping Lens.coerced
instance Data.FromJSON Geometry where
parseJSON =
Data.withObject
"Geometry"
( \x ->
Geometry'
Prelude.<$> (x Data..:? "BoundingBox")
Prelude.<*> (x Data..:? "Polygon" Data..!= Prelude.mempty)
)
instance Prelude.Hashable Geometry where
hashWithSalt _salt Geometry' {..} =
_salt
`Prelude.hashWithSalt` boundingBox
`Prelude.hashWithSalt` polygon
instance Prelude.NFData Geometry where
rnf Geometry' {..} =
Prelude.rnf boundingBox
`Prelude.seq` Prelude.rnf polygon