# `Visualize.Geo.Path`
[🔗](https://github.com/dcoai/Visualize/blob/v0.8.3/lib/visualize/geo/path.ex#L1)

Renders GeoJSON geometries as SVG path strings.

Takes GeoJSON data and a projection to produce SVG paths
suitable for rendering maps.

## Examples

    projection = Visualize.Geo.Projection.new(:mercator)
      |> Visualize.Geo.Projection.scale(100)
      |> Visualize.Geo.Projection.translate(200, 150)

    geo_path = Visualize.Geo.Path.new(projection)

    # Render a GeoJSON feature
    feature = %{
      "type" => "Feature",
      "geometry" => %{
        "type" => "Polygon",
        "coordinates" => [[[-122, 37], [-122, 38], [-121, 38], [-121, 37], [-122, 37]]]
      }
    }

    path_data = Visualize.Geo.Path.render(geo_path, feature)

## Clipping on the sphere

With a projection, lines and polygons are clipped on the sphere before they are
projected, as d3-geo clips them (spec/07 §2.2.1, D-127): under a projection with a
`clip_angle` they are cut where they cross the small circle of that radius about the
center — the orthographic's horizon — a line into several subpaths and a polygon closed
along the circle, so a globe never closes its land by a chord across the disc; under a
projection without one they are cut where they cross ±180° of the rotated frame and a
polygon is closed along the seam and the poles, so a rotated map never joins a ring the
long way round. Winding is d3's: a polygon's exterior ring runs clockwise on a north-up
map, and a ring wound the other way is the rest of the sphere.

# `t`

```elixir
@type t() :: %Visualize.Geo.Path{
  context: any(),
  point_radius: number(),
  projection: Visualize.Geo.Projection.t() | nil
}
```

# `area`

```elixir
@spec area(t(), map()) :: float()
```

Computes the projected planar area of a GeoJSON geometry.

# `bounds`

```elixir
@spec bounds(t(), map()) :: [float()] | nil
```

Computes the bounding box of a GeoJSON geometry.

Returns [x0, y0, x1, y1] in projected coordinates.

# `centroid`

```elixir
@spec centroid(t(), map()) :: {float(), float()} | nil
```

Computes the centroid of a GeoJSON geometry.

Returns {x, y} in projected coordinates.

# `new`

```elixir
@spec new(Visualize.Geo.Projection.t() | nil) :: t()
```

Creates a new GeoPath with the given projection

# `path`

```elixir
@spec path(t(), map()) :: Visualize.IR.Path.t()
```

The GeoJSON object as a `Visualize.IR.Path` (spec/07 §2.2): the same walk as `render/2`,
its numbers the projected coordinates unrounded, and an empty path for a geometry with
nothing to draw.

# `point_radius`

```elixir
@spec point_radius(t(), number()) :: t()
```

Sets the radius for Point geometries

# `projection`

```elixir
@spec projection(t(), Visualize.Geo.Projection.t()) :: t()
```

Sets the projection

# `render`

```elixir
@spec render(t(), map()) :: String.t()
```

Renders GeoJSON to an SVG path string.

Accepts GeoJSON Feature, FeatureCollection, or raw Geometry objects.

---

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