Boltx.Types.Point (Boltx v0.0.6)

Manage spatial data introduced in Bolt V2

Point can be:

  • Cartesian 2D
  • Geographic 2D
  • Cartesian 3D
  • Geographic 3D

Summary

Functions

A 2D point either needs

Create a 3D point

Convert a Point struct into a cypher-compliant map

Types

@type t() :: %Boltx.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
}

Functions

Link to this function

create(arg1, x, y)

@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)
%Boltx.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)
%Boltx.Types.Point{
  crs: "wgs-84",
  height: nil,
  latitude: 20.0,
  longitude: 10.0,
  srid: 4326,
  x: 10.0,
  y: 20.0,
  z: 30.0
}
Link to this function

create(arg1, x, y, z)

@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 9147) to define its type

Examples:

iex> Point.create(:cartesian, 10, 20.0, 30)
%Boltx.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)
%Boltx.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
}
Link to this function

format_param(point)

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

Convert a Point struct into a cypher-compliant map

Example

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