H3Geo (H3Geo v0.1.2)
H3Geo implements the H3 geospatial indexing system.
It's a wrapper around the h3o Rust library, using Rustler
to expose
functions from the library in a manner that can be easily called from Elixir.
Currently only a handful of functions are implemented, mostly to do with converting existing geometries into H3 cell indexes.
Summary
Functions
Takes a list of indexes and returns the compact indexes.
Takes Geo.MultiPolygon
and an integer precision and returns a list of
integers representing the H3 cells that intersect with the multipolygon.
Takes a Geo.Point
and an integer precision and returns an integer
representing the H3 Cell.
Takes Geo.Polygon
and an integer precision and returns a list of integers
representing the H3 cells that intersect with the polygon.
Takes a list of indexes and returns the uncompacted indexes at the desired precision.
Types
index()
@type index() :: pos_integer()
precision()
@type precision() :: 0..15
Functions
compact(indexes)
Takes a list of indexes and returns the compact indexes.
The incoming list is filtered for unique values automatically.
multipolygon_to_cells(multipolygon, precision)
@spec multipolygon_to_cells(Geo.MultiPolygon.t(), precision()) :: {:ok, [index()]} | {:error, :invalid_resolution | :invalid_geometry}
Takes Geo.MultiPolygon
and an integer precision and returns a list of
integers representing the H3 cells that intersect with the multipolygon.
Uses the Covers containment mode, so the cells returned fully cover the multipolygon.
point_to_cell(point, precision)
@spec point_to_cell(Geo.Point.t(), precision()) :: {:ok, pos_integer()} | {:error, :invalid_lat_lng | :invalid_resolution}
Takes a Geo.Point
and an integer precision and returns an integer
representing the H3 Cell.
polygon_to_cells(polygon, precision)
@spec polygon_to_cells(Geo.Polygon.t(), precision()) :: {:ok, [index()]} | {:error, :invalid_resolution | :invalid_geometry}
Takes Geo.Polygon
and an integer precision and returns a list of integers
representing the H3 cells that intersect with the polygon.
Uses the Covers containment mode, so the cells returned fully cover the polygon.
uncompact(indexes, resolution)
@spec uncompact([index()], precision()) :: {:ok, [index()]} | {:error, :invalid_cell_index | :invalid_resolution}
Takes a list of indexes and returns the uncompacted indexes at the desired precision.