Traversal

Functions for finding cells near other cells and computing paths across the grid.

Corresponds to the H3 C API Traversal section.

Grid Disk

FastH3.gridDiskFunction
gridDisk(origin::H3Index, k::Int) -> (H3Error, Vector{H3Index})

Produce all cells within grid distance k of origin. Tries the fast gridDiskUnsafe first and falls back to a safe BFS traversal if pentagons are encountered.

See also the H3 C API: gridDisk

source
FastH3.gridDiskDistancesFunction
gridDiskDistances(origin::H3Index, k::Int) -> (H3Error, Vector{H3Index}, Vector{Int})

Produce all cells within grid distance k of origin, along with their distances. Tries the fast unsafe path first and falls back to safe BFS if needed.

See also the H3 C API: gridDiskDistances

source
FastH3.gridDiskUnsafeFunction
gridDiskUnsafe(op::F, origin::H3Index, k::Int) -> H3Error where {F}

Call op(cell) for each cell within grid distance k of origin (no result vector allocated).

Fails with E_PENTAGON if a pentagon is encountered. Use gridDisk for a safe fallback.

See also the H3 C API: gridDiskUnsafe

source
gridDiskUnsafe(origin::H3Index, k::Int) -> (H3Error, Vector{H3Index})

Produce all cells within grid distance k of origin. Fails with E_PENTAGON if a pentagon is encountered. Use gridDisk for a safe fallback.

See also the H3 C API: gridDiskUnsafe

source
FastH3.gridDiskDistancesUnsafeFunction
gridDiskDistancesUnsafe(op::F, origin::H3Index, k::Int) -> H3Error where {F}

Call op(cell, ring) for each cell within grid distance k of origin, where ring is the grid distance from origin (no result vectors allocated).

Fails with E_PENTAGON if a pentagon is encountered. Use gridDiskDistances for a safe fallback.

See also the H3 C API: gridDiskDistancesUnsafe

source
gridDiskDistancesUnsafe(origin::H3Index, k::Int) -> (H3Error, Vector{H3Index}, Vector{Int})

Produce all cells within grid distance k of origin, along with their distances. Fails with E_PENTAGON if a pentagon is encountered. Use gridDiskDistances for a safe fallback.

See also the H3 C API: gridDiskDistancesUnsafe

source
FastH3.gridRingUnsafeFunction
gridRingUnsafe(op::F, origin::H3Index, k::Int) -> H3Error where {F}

Call op(cell) for each cell on the ring at exactly grid distance k from origin (no result vector allocated).

Fails with E_PENTAGON if a pentagon is encountered.

See also the H3 C API: gridRingUnsafe

source
gridRingUnsafe(origin::H3Index, k::Int) -> (H3Error, Vector{H3Index})

Produce the cells forming the ring at exactly grid distance k from origin. Fails with E_PENTAGON if a pentagon is encountered.

See also the H3 C API: gridRingUnsafe

source

Grid Distance and Paths

FastH3.gridDistanceFunction
gridDistance(origin::H3Index, h3::H3Index) -> (H3Error, Int64)

Compute the grid distance (minimum number of cell steps) between two cells at the same resolution.

See also the H3 C API: gridDistance

source
FastH3.gridPathCellsFunction
gridPathCells(op::F, start_::H3Index, end_::H3Index) -> H3Error where {F}

Call op(cell) for each cell on the line between start_ and end_ (no result vector allocated).

See also the H3 C API: gridPathCells

source
gridPathCells(start_::H3Index, end_::H3Index) -> (H3Error, Vector{H3Index})

Compute the line of cells between start_ and end_ using cube coordinate interpolation. The first element is start_ and the last is end_.

See also the H3 C API: gridPathCells

source

Local IJ Coordinates

FastH3.cellToLocalIjFunction
cellToLocalIj(origin::H3Index, h::H3Index, mode::UInt32) -> (H3Error, CoordIJ)

Convert cell h to local IJ coordinates relative to origin. Both cells must be at the same resolution.

See also the H3 C API: cellToLocalIj

source
FastH3.localIjToCellFunction
localIjToCell(origin::H3Index, ij::CoordIJ, mode::UInt32) -> (H3Error, H3Index)

Convert local IJ coordinates back to a cell, using origin as the coordinate system anchor.

See also the H3 C API: localIjToCell

source

Neighbor Detection