Skip to content

Commit

Permalink
Tweak docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tomtaylor committed Mar 8, 2024
1 parent 6e3e5d0 commit cbc5d90
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions lib/h3_geo.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
defmodule H3Geo do
@moduledoc """
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.
"""
version = Mix.Project.config()[:version]

use RustlerPrecompiled,
Expand All @@ -11,11 +20,13 @@ defmodule H3Geo do
version: version

@type index :: pos_integer()
@type precision :: pos_integer()
@type precision :: 0..15

@doc """
Takes a `Geo.Point` and an `Integer` precision and returns an integer
Takes a `Geo.Point` and an integer precision and returns an integer
representing the H3 Cell.
[Rust documentation](https://docs.rs/h3o/latest/h3o/struct.LatLng.html#method.to_cell).
"""
@spec point_to_cell(Geo.Point.t(), precision()) ::
{:ok, pos_integer()} | {:error, :invalid_lat_lng | :invalid_resolution}
Expand All @@ -25,7 +36,11 @@ defmodule H3Geo do
Takes `Geo.Polygon` and an integer precision and returns a list of integers
representing the H3 cells that intersect with the polygon.
Use containment mode, so the cells returned fully cover the polygon.
Uses the
[Covers](https://docs.rs/h3o/latest/h3o/geom/enum.ContainmentMode.html#variant.Covers)
containment mode, so the cells returned fully cover the polygon.
[Rust documentation](https://docs.rs/h3o/latest/h3o/geom/trait.ToCells.html)
"""
@spec polygon_to_cells(Geo.Polygon.t(), precision()) ::
{:ok, list(index())} | {:error, :invalid_resolution | :invalid_geometry}
Expand All @@ -35,7 +50,11 @@ defmodule H3Geo do
Takes `Geo.MultiPolygon` and an integer precision and returns a list of
integers representing the H3 cells that intersect with the multipolygon.
Use containment mode, so the cells returned fully cover the multipolygon.
Uses the
[Covers](https://docs.rs/h3o/latest/h3o/geom/enum.ContainmentMode.html#variant.Covers)
containment mode, so the cells returned fully cover the multipolygon.
[Rust documentation](https://docs.rs/h3o/latest/h3o/geom/trait.ToCells.html)
"""
@spec multipolygon_to_cells(Geo.MultiPolygon.t(), precision()) ::
{:ok, list(index())} | {:error, :invalid_resolution | :invalid_geometry}
Expand All @@ -45,13 +64,17 @@ defmodule H3Geo do
Takes a list of indexes and returns the compact indexes.
The incoming list is filtered for unique values automatically.
[Rust documentation](https://docs.rs/h3o/latest/h3o/struct.CellIndex.html#method.compact)
"""
@spec compact(list(index())) ::
{:ok, list(index())} | {:error, :invalid_cell_index | :compaction_error}
def compact(_indexes), do: :erlang.nif_error(:nif_not_loaded)

@doc """
Takes a list of indexes and returns the uncompacted indexes at the desired precision.
[Rust documentation](https://docs.rs/h3o/latest/h3o/struct.CellIndex.html#method.uncompact)
"""
@spec uncompact(list(index()), precision()) ::
{:ok, list(index())} | {:error, :invalid_cell_index | :invalid_resolution}
Expand Down

0 comments on commit cbc5d90

Please sign in to comment.