Expand description
The h3o library implements the H3 geospatial indexing system.
H3 is a geospatial indexing system using a hexagonal grid that can be (approximately) subdivided into finer and finer hexagonal grids, combining the benefits of a hexagonal grid with S2’s hierarchical subdivisions.
§Crate features
-
std - When enabled, this will cause
h3oto use the standard library. In terms of APIs,stdcauses error types to implement thestd::error::Errortrait. Enablingstdwill also result in performance optimizations. -
geo - When enabled, you’ll be able to convert lists of H3 cell indexes from and into geometric shapes. Also enables the
GeoJSONsupport. Requiresstd. -
serde - When enabled, H3 index types (cell, vertex and edge) derive serde traits.
§H3 to H3O mapping
For people used to the H3 API, here is the mapping to H3O.
§Indexing functions
| H3 | H3O |
|---|---|
latLngToCell | LatLng::to_cell |
cellToLatLng | LatLng::from |
cellToBoundary | CellIndex::boundary |
§Index inspection functions
| H3 | H3O |
|---|---|
getResolution | CellIndex::resolution |
getBaseCellNumber | CellIndex::base_cell |
getIndexDigit | CellIndex::direction_at |
stringToH3 | str::parse |
h3ToString | ToString::to_string |
isValidCell | CellIndex::try_from |
isResClassIII | Resolution::is_class3 |
isPentagon | CellIndex::is_pentagon |
getIcosahedronFaces | CellIndex::icosahedron_faces |
maxFaceCount | CellIndex::max_face_count |
§Grid traversal functions
| H3 | H3O |
|---|---|
gridDisk | CellIndex::grid_disk |
maxGridDiskSize | max_grid_disk_size |
maxGridRingSize | max_grid_ring_size |
gridDiskDistances | CellIndex::grid_disk_distances |
gridDiskUnsafe | CellIndex::grid_disk_fast |
gridDiskDistancesUnsafe | CellIndex::grid_disk_distances_fast |
gridDiskDistancesSafe | CellIndex::grid_disk_distances_safe |
gridDisksUnsafe | CellIndex::grid_disks_fast |
gridRingUnsafe | CellIndex::grid_ring_fast |
gridRing | CellIndex::grid_ring |
gridPathCells | CellIndex::grid_path_cells |
gridPathCellsSize | CellIndex::grid_path_cells_size |
gridDistance | CellIndex::grid_distance |
cellToLocalIj | CellIndex::to_local_ij |
localIjToCell | CellIndex::try_from |
§Hierarchical grid functions
| H3 | H3O |
|---|---|
cellToParent | CellIndex::parent |
cellToChildren | CellIndex::children |
cellToChildrenSize | CellIndex::children_count |
cellToCenterChild | CellIndex::center_child |
cellToChildPos | CellIndex::child_position |
childPosToCell | CellIndex::child_at |
compactCells | CellIndex::compact |
uncompactCells | CellIndex::uncompact |
uncompactCellsSize | CellIndex::uncompact_size |
§Region functions
| H3 | H3O |
|---|---|
polygonToCells | geom::Tiler::into_coverage |
maxPolygonToCellsSize | geom::Tiler::coverage_size_hint |
h3SetToLinkedGeo | geom::Solvent::dissolve |
destroyLinkedPolygon | N/A |
§Directed edge functions
| H3 | H3O |
|---|---|
areNeighborCells | CellIndex::is_neighbor_with |
cellsToDirectedEdge | CellIndex::edge |
isValidDirectedEdge | DirectedEdgeIndex::try_from |
getDirectedEdgeOrigin | DirectedEdgeIndex::origin |
getDirectedEdgeDestination | DirectedEdgeIndex::destination |
directedEdgeToCells | DirectedEdgeIndex::cells |
originToDirectedEdges | CellIndex::edges |
directedEdgeToBoundary | DirectedEdgeIndex::boundary |
§Vertex functions
| H3 | H3O |
|---|---|
cellToVertex | CellIndex::vertex |
cellToVertexes | CellIndex::vertexes |
vertexToLatLng | LatLng::from |
isValidVertex | VertexIndex::try_from |
§Miscellaneous H3 functions
| H3 | H3O |
|---|---|
degsToRads | f64::to_radians |
radsToDegs | f64::to_degrees |
getHexagonAreaAvgKm2 | Resolution::area_km2 |
getHexagonAreaAvgM2 | Resolution::area_m2 |
cellAreaKm2 | CellIndex::area_km2 |
cellAreaM2 | CellIndex::area_m2 |
cellAreaRads2 | CellIndex::area_rads2 |
getHexagonEdgeLengthAvgKm | Resolution::edge_length_km |
getHexagonEdgeLengthAvgM | Resolution::edge_length_m |
edgeLengthKm | DirectedEdgeIndex::length_km |
edgeLengthM | DirectedEdgeIndex::length_m |
edgeLengthRads | DirectedEdgeIndex::length_rads |
getNumCells | Resolution::cell_count |
getRes0Cells | CellIndex::base_cells |
res0CellCount | BaseCell::count |
getPentagons | Resolution::pentagons |
pentagonCount | Resolution::pentagon_count |
greatCircleDistanceKm | LatLng::distance_km |
greatCircleDistanceM | LatLng::distance_m |
greatCircleDistanceRads | LatLng::distance_rads |
Modules§
Structs§
- Base
Cell - One of the 122 base cells.
- Boundary
- Boundary in latitude/longitude.
- Cell
Index - Represents a cell (hexagon or pentagon) in the H3 grid system at a particular resolution.
- CoordIJ
- IJ hexagon coordinates.
- Directed
Edge Index - Represents a single directed edge between two cells (an “origin” cell and a neighboring “destination” cell).
- Edge
- Edge of an H3 cell.
- Face
- An icosahedron face.
- FaceSet
- A set of icosahedron faces.
- LatLng
- Latitude/longitude.
- LocalIJ
IJcoordinates anchored by an origin.- Vertex
- Vertex of an H3 cell.
- Vertex
Index - Represents a single topological vertex in H3 grid system, shared by three cells.
Enums§
- Direction
- A direction within an hexagonal grid.
- Index
Mode - H3 index modes.
- Resolution
- Cell resolution, from 0 to 15.
Constants§
- EARTH_
RADIUS_ KM - Earth radius in kilometers using WGS84 authalic radius.
Functions§
- max_
grid_ disk_ size - Maximum number of indices produced by the grid disk algorithm with the given
k. - max_
grid_ ring_ size - Maximum number of cells that result from the
gridRingalgorithm with the givenk.