# `Bolty.Types.Point`

Manage spatial data introduced in Bolt V2

Point can be:
  - Cartesian 2D
  - Geographic 2D
  - Cartesian 3D
  - Geographic 3D

# `t`

```elixir
@type t() :: %Bolty.Types.Point{
  crs: String.t(),
  height: number() | nil,
  latitude: number() | nil,
  longitude: number() | nil,
  srid: integer(),
  x: number() | nil,
  y: number() | nil,
  z: number() | nil
}
```

# `create`

```elixir
@spec create(:cartesian | :wgs_84 | 4326 | 7203, number(), number()) :: t()
```

A 2D point either needs:
- 2 coordinates and a atom (:cartesian or :wgs_84) to define its type
- 2 coordinates and a srid (4326 or 7203) to define its type

## Examples:
    iex> Point.create(:cartesian, 10, 20.0)
    %Bolty.Types.Point{
      crs: "cartesian",
      height: nil,
      latitude: nil,
      longitude: nil,
      srid: 7203,
      x: 10.0,
      y: 20.0,
      z: nil
    }
    iex> Point.create(4326, 10, 20.0)
    %Bolty.Types.Point{
      crs: "wgs-84",
      height: nil,
      latitude: 20.0,
      longitude: 10.0,
      srid: 4326,
      x: 10.0,
      y: 20.0,
      z: nil
    }

# `create`

```elixir
@spec create(:cartesian | :wgs_84 | 4979 | 9157, number(), number(), number()) :: t()
```

Create a 3D point

A 3D point either needs:
- 3 coordinates and a atom (:cartesian or :wgs_84) to define its type
- 3 coordinates and a srid (4979 or 9157) to define its type

## Examples:
    iex> Point.create(:cartesian, 10, 20.0, 30)
    %Bolty.Types.Point{
      crs: "cartesian-3d",
      height: nil,
      latitude: nil,
      longitude: nil,
      srid: 9157,
      x: 10.0,
      y: 20.0,
      z: 30.0
    }
    iex> Point.create(4979, 10, 20.0, 30)
    %Bolty.Types.Point{
      crs: "wgs-84-3d",
      height: 30.0,
      latitude: 20.0,
      longitude: 10.0,
      srid: 4979,
      x: 10.0,
      y: 20.0,
      z: 30.0
    }

# `format_param`

```elixir
@spec format_param(t()) :: {:ok, map()} | {:error, any()}
```

Convert a Point struct into a Map suitable as an argument to Cypher's
`point()` function.

To store a Point as a property (or return one from a query), pass a
`%Bolty.Types.Point{}` directly as a parameter — Bolty packs it as a
native PackStream Point. Use this function only when you specifically
want the Map shape that Cypher's `point()` constructor accepts.

## Example
    iex> Point.create(4326, 10, 20.0) |> Point.format_param()
    {:ok, %{crs: "wgs-84", latitude: 20.0, longitude: 10.0, x: 10.0, y: 20.0}}

---

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