#neighbor #h3 #build #libh3 #h3-index

libh3

Safe Rust Bindings to Uber's Hexagonal Hierarchical Spatial Index - H3

11 releases

new 0.2.2 Apr 25, 2025
0.2.1 Apr 24, 2025
0.1.8 Jul 18, 2020
0.1.7 Jun 20, 2020
0.1.5 Mar 18, 2020

#406 in Rust patterns

Download history 1/week @ 2025-02-05 18/week @ 2025-02-12 1/week @ 2025-02-19 3/week @ 2025-02-26 2/week @ 2025-03-26 256/week @ 2025-04-23

256 downloads per month

MIT license

36KB
575 lines

libh3 - Wrapper for Uber’s H3 Hexagonal Hierarchical Spatial Index in Rust

This crate calls functions provided by Uber's H3 library to expose a safe Rust API for it.

Contributions are welcome, just do a pull request.

Quickstart

This refers to a Debian like sytem, please adopt to your needs. It will build Uber's H3 library during build step, otherwise the libh3 crate cannot link.

sudo apt install cmake make gcc libtool

You may then dir into your project and build it using libh3 as dependency

Provide Own H3 Library

To provide your own H3 Library, you must set H3_INSTALL_PREFIX as environment variable, so libh3 can find it's header and static library. You must then call cargo with feature flag uber_h3_from_scratch disabled, e.g.:

cargo build --no-default-features

Provided By Distribution

If you installed H3 via a package manager, it's likely installed to /usr. Set environment accordingly:

export H3_INSTALL_PREFIX=/usr

Self build

To build from sources do following steps:

sudo apt install git cmake make gcc libtool
git clone --depth=1 --branch v4.2.1 https://github.com/uber/h3.git
export H3_INSTALL_PREFIX=$PWD/h3_inst
cmake -S h3 -B h3_build
cmake --build h3_build --parallel 8
cmake --install ./h3_build --prefix $H3_INSTALL_PREFIX

Documentation

For further documentation have a look at https://docs.rs/libh3/

For the concepts behind the library refer to h3geo.org or the H3 blog

Dependencies

~0–3MB
~54K SLoC