# `Kreuzberg.OcrBoundingGeometry`
[🔗](https://github.com/kreuzberg-dev/kreuzberg/blob/main/lib/kreuzberg/ocr_bounding_geometry.ex#L1)

Bounding geometry for OCR-extracted text elements.

Represents the geometric positioning of OCR-detected text,
supporting both rectangular (left/top/width/height) and point-based
(polygon points) geometry definitions.

## Fields

  * `:type` - Geometry type ("rect" or "polygon")
  * `:left` - Left x-coordinate for rectangular geometry, or nil
  * `:top` - Top y-coordinate for rectangular geometry, or nil
  * `:width` - Width for rectangular geometry, or nil
  * `:height` - Height for rectangular geometry, or nil
  * `:points` - Array of [x, y] points for polygon geometry, or nil

## Examples

    iex> geometry = %Kreuzberg.OcrBoundingGeometry{
    ...>   type: "rect",
    ...>   left: 10.0,
    ...>   top: 20.0,
    ...>   width: 100.0,
    ...>   height: 50.0
    ...> }
    iex> geometry.type
    "rect"

# `t`

```elixir
@type t() :: %Kreuzberg.OcrBoundingGeometry{
  height: float() | nil,
  left: float() | nil,
  points: [[float()]] | nil,
  top: float() | nil,
  type: String.t(),
  width: float() | nil
}
```

# `from_map`

```elixir
@spec from_map(map()) :: t()
```

Creates an OcrBoundingGeometry struct from a map.

## Parameters

  * `data` - A map containing geometry fields

## Returns

An `OcrBoundingGeometry` struct with properly typed fields.

## Examples

    iex> geometry_map = %{
    ...>   "type" => "rect",
    ...>   "left" => 10.0,
    ...>   "top" => 20.0,
    ...>   "width" => 100.0,
    ...>   "height" => 50.0
    ...> }
    iex> geometry = Kreuzberg.OcrBoundingGeometry.from_map(geometry_map)
    iex> geometry.type
    "rect"

# `to_map`

```elixir
@spec to_map(t()) :: map()
```

Converts an OcrBoundingGeometry struct to a map.

## Parameters

  * `geometry` - An `OcrBoundingGeometry` struct

## Returns

A map with string keys representing all fields.

## Examples

    iex> geometry = %Kreuzberg.OcrBoundingGeometry{
    ...>   type: "rect",
    ...>   left: 10.0,
    ...>   top: 20.0,
    ...>   width: 100.0,
    ...>   height: 50.0
    ...> }
    iex> Kreuzberg.OcrBoundingGeometry.to_map(geometry)
    %{
      "type" => "rect",
      "left" => 10.0,
      ...
    }

---

*Consult [api-reference.md](api-reference.md) for complete listing*
