# `Macaw.Draw.Geo.Graticule`
[🔗](https://github.com/dcoai/macaw_draw/blob/v0.1.0/lib/macaw/draw/geo/graticule.ex#L1)

The graticule, d3-geo's `geoGraticule`: meridians, parallels and their outline as
GeoJSON that `Macaw.Draw.Geo.Path` clips and projects like any geometry (spec/09 §6).
visualize had none; this is a port of d3-geo's `src/graticule.js`.

    iex> {:ok, g} = Macaw.Draw.Geo.Graticule.new()
    iex> g |> Macaw.Draw.Geo.Graticule.lines() |> length()
    53

Every line is sampled every `precision` degrees, meridians as well as parallels: d3
samples a meridian every 90° and leaves the curve to its stream's adaptive resampling,
which `Macaw.Draw` does not have, so a meridian under a conic or an azimuthal projection
curves as it should here (decision 3).

# `extent`

```elixir
@type extent() :: [[number()]]
```

# `geometry`

```elixir
@type geometry() :: %{required(String.t()) =&gt; term()}
```

A GeoJSON geometry, string keys.

# `t`

```elixir
@type t() :: %Macaw.Draw.Geo.Graticule{
  extent_major: extent(),
  extent_minor: extent(),
  precision: number(),
  step_major: [number()],
  step_minor: [number()]
}
```

# `lines`

```elixir
@spec lines(t()) :: [geometry()] | {:error, [Macaw.Base.Fault.t()]}
```

One `LineString` per line (spec/09 §6.2): the major meridians, the major parallels, the
minor meridians not on a major one, and the minor parallels not on a major one, in that
order.

# `multi_line`

```elixir
@spec multi_line(t()) :: geometry() | {:error, [Macaw.Base.Fault.t()]}
```

Every line as one `MultiLineString`: d3's `graticule()`.

# `new`

```elixir
@spec new(keyword() | map()) :: {:ok, t()} | {:error, [Macaw.Base.Fault.t()]}
```

A graticule, its options checked at once (spec/09 §6.1): `extent_major`, `extent_minor`
(`[[lon0, lat0], [lon1, lat1]]`, the first corner below and west of the second, else
`{[key], :inverted}`), `step_major`, `step_minor` (`[dlon, dlat]` of positive numbers)
and `precision` (positive, `2.5`). `extent` sets both extents and `step` the minor step,
as d3's `extent` and `step` do; a key naming one of them alone wins over it.

# `outline`

```elixir
@spec outline(t()) :: geometry() | {:error, [Macaw.Base.Fault.t()]}
```

The `Polygon` bounding the major extent: the meridian at its west edge up, the parallel
at its north edge east, the meridian at its east edge down and the parallel at its south
edge west, each sampled at `precision`, shared corners once.

# `ten`

```elixir
@spec ten() :: geometry()
```

The defaults' `multi_line/1`: d3's `geoGraticule10`.

---

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