XS H3

A pure-Rust implementation of Uber's H3 discrete global grid system.

XS-H3 is a pure Rust implementation of H3, the hexagonal global grid system originally developed by Uber. H3 divides the earth into hexagonal cells at 16 resolutions, from 122 base cells at resolution 0 down to sub-meter cells at resolution 15. Each resolution also has exactly 12 pentagons. A cell is identified by a 64-bit H3Index, which makes it a handy key for grouping, joining and searching location data.

The library follows the API and behavior of the C H3 library where it can, with function names like lat_lng_to_cell, cell_to_lat_lng and cell_to_boundary. Coordinates are LatLng values in radians; degs_to_rads and rads_to_degs convert for you. Fallible functions return Result<T, H3Error>.

It covers the main H3 areas. Inspection functions read a cell's resolution and base cell, validate an index and detect pentagons. Hierarchy functions find parents, children and child positions and compact or uncompact sets of cells. Traversal includes grid_disk, grid_ring_unsafe, grid_path_cells, grid_distance and neighbor checks. You also get average and exact cell areas, edge lengths and string conversion. Optional Serde support for the core types is behind the serde feature.

The project is experimental. The API may change between releases and not every C H3 feature is present yet. Polygon filling (polygon_to_cells) and cells_to_multi_polygon are basic, grid_path_cells and grid_distance differ from C for some cell pairs. Directed edge, vertex and full local IJ functions are still planned. It is not recommended for production use yet.

[dependencies]
xs_h3 = "0.2"

Licensed under MPL-2.0. Source at https://github.com/excsn/xs_h3 and API docs at https://docs.rs/xs_h3.