h3_core library
H3 geospatial indexing for Dart/Flutter.
Uses dart:ffi on native, h3-js on web.
Classes
- CellBoundary
- Cell boundary as an ordered list of vertices in degrees.
- CoordIJ
- Local IJ coordinate pair for grid-local coordinate operations.
- GeoPolygon
- Polygon defined by an exterior ring and optional holes, for region operations such as polygonToCells.
- H3Version
- Version constants for the h3_core package and the underlying H3 C library.
- LatLng
- Latitude/longitude coordinate pair in degrees.
Enums
- ContainmentMode
- Containment mode for polygon fill operations.
Extension Types
- H3Index
- H3 cell, directed edge, or vertex index stored as a hex string.
Functions
-
areNeighborCells(
H3Index origin, H3Index destination) → bool -
Returns whether
originanddestinationshare an edge. -
cellAreaKm2(
H3Index cell) → double -
Returns the exact area of the
cellin km². -
cellAreaM2(
H3Index cell) → double -
Returns the exact area of the
cellin m². -
cellsToDirectedEdge(
H3Index origin, H3Index destination) → H3Index -
Returns the directed edge from
origintodestination. -
cellsToMultiPolygon(
List< H3Index> cells) → List<List< List< >LatLng> > -
Returns the outlines of a set of
cellsas a GeoJSON-style multi-polygon. -
cellToBoundary(
H3Index cell) → CellBoundary -
Returns the boundary vertices of the given H3
cell. -
cellToCenterChild(
H3Index cell, int childRes) → H3Index -
Returns the center child of
cellat the finerchildRes. -
cellToChildPos(
H3Index child, int parentRes) → int -
Returns the position of
childwithin its parent atparentRes. -
cellToChildren(
H3Index cell, int childRes) → List< H3Index> -
Returns the children of
cellat the finerchildRes. -
cellToLatLng(
H3Index cell) → LatLng -
Returns the center coordinate of the given H3
cell. -
cellToLocalIj(
H3Index origin, H3Index cell) → CoordIJ -
Converts
cellto local IJ coordinates relative toorigin. -
cellToParent(
H3Index cell, int parentRes) → H3Index -
Returns the parent cell of
cellat the coarserparentRes. -
cellToVertex(
H3Index cell, int vertexNum) → H3Index -
Returns the vertex at index
vertexNum(0–5) of thecell. -
cellToVertexes(
H3Index cell) → List< H3Index> -
Returns all vertices of the given
cell. -
childPosToCell(
int childPos, H3Index parent, int childRes) → H3Index -
Returns the child cell at
childPoswithinparentatchildRes. -
compactCells(
List< H3Index> cells) → List<H3Index> -
Compacts a set of
cellsby replacing complete groups with their parent. -
compactCellsAsync(
List< H3Index> cells) → Future<List< H3Index> > - Async version of compactCells; runs on an isolate on native platforms.
-
constructCell(
int res, int baseCellNumber, List< int> digits) → H3Index -
Constructs an H3 cell index from
res,baseCellNumber, and directiondigits. -
directedEdgeToBoundary(
H3Index edge) → CellBoundary -
Returns the boundary vertices of the directed
edge. -
directedEdgeToCells(
H3Index edge) → List< H3Index> -
Returns the origin and destination cells of the directed
edge. -
edgeLengthKm(
H3Index edge) → double -
Returns the exact length of the directed
edgein kilometers. -
edgeLengthM(
H3Index edge) → double -
Returns the exact length of the directed
edgein meters. -
getBaseCellNumber(
H3Index h) → int - Returns the base cell number (0–121) of the given H3 index.
-
getDirectedEdgeDestination(
H3Index edge) → H3Index -
Returns the destination cell of the directed
edge. -
getDirectedEdgeOrigin(
H3Index edge) → H3Index -
Returns the origin cell of the directed
edge. -
getHexagonAreaAvgKm2(
int resolution) → double -
Returns the average hexagon area in km² at the given
resolution. -
getHexagonAreaAvgM2(
int resolution) → double -
Returns the average hexagon area in m² at the given
resolution. -
getHexagonEdgeLengthAvgKm(
int resolution) → double -
Returns the average hexagon edge length in km at the given
resolution. -
getHexagonEdgeLengthAvgM(
int resolution) → double -
Returns the average hexagon edge length in meters at the given
resolution. -
getIcosahedronFaces(
H3Index h) → List< int> - Returns the icosahedron face(s) that the given cell intersects.
-
getIndexDigit(
H3Index h, int resolution) → int -
Returns the direction digit at the given
resolutionfor indexh. -
getNumCells(
int resolution) → int -
Returns the total number of cells at the given
resolution. -
getPentagons(
int resolution) → List< H3Index> -
Returns all 12 pentagon cells at the given
resolution. -
getRes0Cells(
) → List< H3Index> - Returns all 122 resolution-0 cells.
-
getResolution(
H3Index h) → int - Returns the resolution (0–15) of the given H3 index.
-
greatCircleDistanceKm(
LatLng a, LatLng b) → double -
Returns the great-circle distance between
aandbin kilometers. -
greatCircleDistanceM(
LatLng a, LatLng b) → double -
Returns the great-circle distance between
aandbin meters. -
gridDisk(
H3Index origin, int k) → List< H3Index> -
Returns all cells within
kgrid steps oforigin(filled disk). -
gridDiskAsync(
H3Index origin, int k) → Future< List< H3Index> > - Async version of gridDisk; runs on an isolate on native platforms.
-
gridDiskDistances(
H3Index origin, int k) → Map< H3Index, int> -
Returns cells within
ksteps oforiginmapped to their grid distance. -
gridDistance(
H3Index origin, H3Index destination) → int -
Returns the minimum grid distance between
originanddestination. -
gridPathCells(
H3Index start, H3Index end) → List< H3Index> -
Returns the cells along the shortest grid path from
starttoend. -
gridRing(
H3Index origin, int k) → List< H3Index> -
Returns cells exactly
kgrid steps fromorigin(hollow ring). -
h3ToString(
H3Index h) → String - Returns the hex string representation of the given H3 index.
-
isPentagon(
H3Index h) → bool -
Returns whether
his a pentagon cell. -
isResClassIII(
H3Index h) → bool -
Returns whether
hhas Class III resolution orientation. -
isValidCell(
H3Index h) → bool -
Returns whether
his a valid H3 cell index. -
isValidDirectedEdge(
H3Index edge) → bool -
Returns whether
edgeis a valid H3 directed edge index. -
isValidIndex(
H3Index h) → bool -
Returns whether
his any valid H3 index (cell, edge, or vertex). -
isValidVertex(
H3Index vertex) → bool -
Returns whether
vertexis a valid H3 vertex index. -
latLngToCell(
LatLng latLng, int resolution) → H3Index -
Converts a
latLngcoordinate to the H3 cell index at the givenresolution(0–15). -
localIjToCell(
H3Index origin, CoordIJ ij) → H3Index -
Converts local
ijcoordinates relative tooriginback to an H3 cell. -
originToDirectedEdges(
H3Index origin) → List< H3Index> -
Returns all directed edges originating from
origin. -
pentagonCount(
) → int - Returns the number of pentagons per resolution (always 12).
-
polygonToCells(
GeoPolygon polygon, int resolution) → List< H3Index> -
Returns all cells whose centers are within the
polygonatresolution. -
polygonToCellsAsync(
GeoPolygon polygon, int resolution) → Future< List< H3Index> > - Async version of polygonToCells; runs on an isolate on native platforms.
-
polygonToCellsExperimental(
GeoPolygon polygon, int resolution, {ContainmentMode mode = ContainmentMode.center}) → List< H3Index> -
Returns cells within the
polygonusing the specified containmentmode. -
res0CellCount(
) → int - Returns the number of resolution-0 cells (always 122).
-
reverseDirectedEdge(
H3Index edge) → H3Index - Returns the directed edge with origin and destination swapped.
-
stringToH3(
String hex) → H3Index -
Parses a
hexstring into an H3Index, throwing H3Exception on invalid input. -
uncompactCells(
List< H3Index> cells, int resolution) → List<H3Index> -
Expands compacted
cellsto the givenresolution. -
uncompactCellsAsync(
List< H3Index> cells, int resolution) → Future<List< H3Index> > - Async version of uncompactCells; runs on an isolate on native platforms.
-
vertexToLatLng(
H3Index vertex) → LatLng -
Returns the coordinates of the given
vertex.
Exceptions / Errors
- H3Exception
- Exception thrown when an H3 operation fails.