Meridian.Builder.Geohash (Meridian v0.1.0)

Copy Markdown View Source

Builds graphs from geohash rectangular grids.

Requires the optional :geohash dependency.

Uses a flood-fill approach starting from the center of the bounding box to discover all geohash cells that intersect the area.

Topologies

  • :rook — 4 cardinal neighbors (default)
  • :queen — 8 neighbors including diagonals

Examples

iex> graph =
...>   Meridian.Graph.new(kind: :undirected)
...>   |> Meridian.Builder.Geohash.grid(
...>        sw: {40.6, -74.1},
...>        ne: {40.8, -73.9},
...>        precision: 5,
...>        topology: :rook
...>      )
iex> Meridian.Graph.node_count(graph) >= 1
true

Summary

Functions

Creates a graph covering a bounding box with geohash cells.

Functions

grid(g, opts)

@spec grid(
  Meridian.Graph.t(),
  keyword()
) :: Meridian.Graph.t()

Creates a graph covering a bounding box with geohash cells.

Options

  • :sw — southwest corner {lat, lon} (required)
  • :ne — northeast corner {lat, lon} (required)
  • :precision — geohash character length, 1–12 (required)
  • :topology:rook (default) or :queen
  • :node_data_fn — function (geohash :: String.t()) -> map

Examples

iex> graph =
...>   Meridian.Graph.new(kind: :undirected)
...>   |> Meridian.Builder.Geohash.grid(sw: {0.0, 0.0}, ne: {0.1, 0.1}, precision: 5)
iex> Meridian.Graph.node_count(graph) >= 1
true