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.gridDisk — Function
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
FastH3.gridDiskDistances — Function
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
FastH3.gridDiskUnsafe — Function
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
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
FastH3.gridDiskDistancesUnsafe — Function
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
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
FastH3.gridRingUnsafe — Function
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
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
FastH3.maxGridDiskSize — Function
maxGridDiskSize(k::Int) -> (H3Error, Int64)Get the maximum number of cells that can be returned by gridDisk with radius k. Formula: 3k² + 3k + 1.
See also the H3 C API: maxGridDiskSize
Grid Distance and Paths
FastH3.gridDistance — Function
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
FastH3.gridPathCells — Function
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
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
FastH3.gridPathCellsSize — Function
gridPathCellsSize(start::H3Index, end_::H3Index) -> (H3Error, Int64)Get the number of cells in the grid path between start and end_ (inclusive).
See also the H3 C API: gridPathCellsSize
Local IJ Coordinates
FastH3.cellToLocalIj — Function
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
FastH3.localIjToCell — Function
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
Neighbor Detection
FastH3.areNeighborCells — Function
areNeighborCells(origin::H3Index, destination::H3Index) -> (H3Error, Bool)Determine whether two H3 cells are neighbors (share an edge).
See also the H3 C API: areNeighborCells