#[repr(transparent)]pub struct H3Cell(_);
Expand description
H3 Index representing a H3 Cell (hexagon)
Implementations
sourceimpl H3Cell
impl H3Cell
sourcepub fn from_coordinate(
c: Coordinate<f64>,
h3_resolution: u8
) -> Result<Self, Error>
pub fn from_coordinate(
c: Coordinate<f64>,
h3_resolution: u8
) -> Result<Self, Error>
sourcepub fn is_parent_of(&self, other: &Self) -> Result<bool, Error>
pub fn is_parent_of(&self, other: &Self) -> Result<bool, Error>
Checks if self
is a parent of other
sourcepub fn is_child_of(&self, other: &Self) -> Result<bool, Error>
pub fn is_child_of(&self, other: &Self) -> Result<bool, Error>
Checks if other
is a parent of self
sourcepub fn contains(&self, other: &Self) -> Result<bool, Error>
pub fn contains(&self, other: &Self) -> Result<bool, Error>
Checks if self
is a parent of other
sourcepub fn get_parent(&self, parent_resolution: u8) -> Result<Self, Error>
pub fn get_parent(&self, parent_resolution: u8) -> Result<Self, Error>
Retrieves the parent (or grandparent, etc) cell of the given cell
sourcepub fn get_children(&self, child_resolution: u8) -> Result<IndexVec<Self>, Error>
pub fn get_children(&self, child_resolution: u8) -> Result<IndexVec<Self>, Error>
Retrieves all children of self
at resolution child_resolution
sourcepub fn are_neighbor_cells(&self, other: Self) -> Result<bool, Error>
pub fn are_neighbor_cells(&self, other: Self) -> Result<bool, Error>
Checks if the current index and other
are neighbors.
sourcepub fn grid_disk(&self, k: u32) -> Result<IndexVec<Self>, Error>
pub fn grid_disk(&self, k: u32) -> Result<IndexVec<Self>, Error>
grid_disk
produces all cells within k distance of the origin cell.
k=0 is defined as the origin cell, k=1 is defined as k=0 + all neighboring cells, and so on.
Note
For repeated building of grid disks, there is also super::iter::GridDiskBuilder
.
sourcepub fn grid_ring_unsafe(&self, k: u32) -> Result<IndexVec<Self>, Error>
pub fn grid_ring_unsafe(&self, k: u32) -> Result<IndexVec<Self>, Error>
hollow hexagon ring at self
sourcepub fn grid_disk_distances(
&self,
k_min: u32,
k_max: u32
) -> Result<Vec<(u32, Self)>, Error>
pub fn grid_disk_distances(
&self,
k_min: u32,
k_max: u32
) -> Result<Vec<(u32, Self)>, Error>
Retrieves indexes around self
through K Rings.
Arguments
k_min
- the minimum k ring distancek_max
- the maximum k ring distance
Returns
A Vec
of (u32, Index)
tuple is returned. The u32
value is the K Ring distance
of the Index
value.
Note
For repeated building of k-rings, there is also super::iter::GridDiskBuilder
.
pub fn grid_disk_distances_unsafe(
&self,
k_min: u32,
k_max: u32
) -> Result<Vec<(u32, Self)>, Error>
sourcepub fn grid_distance_to(&self, other: Self) -> Result<usize, Error>
pub fn grid_distance_to(&self, other: Self) -> Result<usize, Error>
Retrieves the number of K Rings between self
and other
.
For distance in miles or kilometers use haversine algorithms.
sourcepub fn is_pentagon(&self) -> bool
pub fn is_pentagon(&self) -> bool
determines if an H3 cell is a pentagon
sourcepub fn get_base_cell_number(&self) -> u8
pub fn get_base_cell_number(&self) -> u8
returns the base cell “number” (0 to 121) of the provided H3 cell
sourcepub fn directed_edge_to(
&self,
destination: Self
) -> Result<H3DirectedEdge, Error>
pub fn directed_edge_to(
&self,
destination: Self
) -> Result<H3DirectedEdge, Error>
Gets the directed edge from self
to destination
Returns
If the built index is invalid, returns an Error.
Use the unidirectional_edge_to_unchecked
to avoid error.
sourcepub fn directed_edges(&self) -> Result<IndexVec<H3DirectedEdge>, Error>
pub fn directed_edges(&self) -> Result<IndexVec<H3DirectedEdge>, Error>
Retrieves all directed H3 edges around self
where self
is the origin
For repeated creation of H3DirectedEdge
around a H3Cell
also
see crate::iter::H3DirectedEdgesBuilder
, which is more efficient.
sourcepub fn area_avg_m2(resolution: u8) -> Result<f64, Error>
pub fn area_avg_m2(resolution: u8) -> Result<f64, Error>
get the average cell area at resolution
in square meters.
use h3ron::H3Cell;
assert_eq!(15047, H3Cell::area_avg_m2(10).unwrap() as i32);
sourcepub fn area_avg_km2(resolution: u8) -> Result<f64, Error>
pub fn area_avg_km2(resolution: u8) -> Result<f64, Error>
get the average cell area at resolution
in square kilometers.
sourcepub fn area_km2(&self) -> Result<f64, Error>
pub fn area_km2(&self) -> Result<f64, Error>
Retrieves the exact area of self
in square kilometers
sourcepub fn area_rads2(&self) -> Result<f64, Error>
pub fn area_rads2(&self) -> Result<f64, Error>
Retrieves the exact area of self
in square radians
sourcepub fn center_child(&self, resolution: u8) -> Result<Self, Error>
pub fn center_child(&self, resolution: u8) -> Result<Self, Error>
returns the center child of self
at the specified resolution.
sourceimpl H3Cell
impl H3Cell
sourcepub fn from_localij(origin_cell: Self, coordij: CoordIj) -> Result<Self, Error>
pub fn from_localij(origin_cell: Self, coordij: CoordIj) -> Result<Self, Error>
Produces an H3Cell
for the given coordij
coordinates anchored by origin_cell
.
The coordinate space used by this function may have deleted regions or warping due to pentagonal distortion.
Failure may occur if the index is too far away from the origin or if the index is on the other side of a pentagon.
This function’s output is not guaranteed to be compatible across different versions of H3.
sourcepub fn to_localij(&self, origin_cell: Self) -> Result<CoordIj, Error>
pub fn to_localij(&self, origin_cell: Self) -> Result<CoordIj, Error>
Produces CoordIj
coordinates for this H3Cell
instance anchored by an origin H3Cell
origin_cell
.
The coordinate space used by this function may have deleted regions or warping due to pentagonal distortion.
Failure may occur if the index is too far away from the origin or if the index is on the other side of a pentagon.
This function’s output is not guaranteed to be compatible across different versions of H3.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for H3Cell
impl<'de> Deserialize<'de> for H3Cell
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl FromH3Index for H3Cell
impl FromH3Index for H3Cell
fn from_h3index(h3index: H3Index) -> Self
sourceimpl Index for H3Cell
impl Index for H3Cell
sourcefn resolution(&self) -> u8
fn resolution(&self) -> u8
Gets the index resolution (0-15)
sourcefn direction(&self) -> H3Direction
fn direction(&self) -> H3Direction
Retrieves the direction of the current index Read more
sourcefn direction_checked(&self) -> Result<H3Direction, Error>
fn direction_checked(&self) -> Result<H3Direction, Error>
Retrieves the direction of the current index Read more
sourcefn direction_to_parent_resolution(
&self,
target_resolution: u8
) -> Result<H3Direction, Error>
fn direction_to_parent_resolution(
&self,
target_resolution: u8
) -> Result<H3Direction, Error>
Retrieves the direction of the current index relative to a parent at target_resolution
sourceimpl Ord for H3Cell
impl Ord for H3Cell
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialEq<H3Cell> for H3Cell
impl PartialEq<H3Cell> for H3Cell
sourceimpl PartialOrd<H3Cell> for H3Cell
impl PartialOrd<H3Cell> for H3Cell
sourcefn partial_cmp(&self, other: &H3Cell) -> Option<Ordering>
fn partial_cmp(&self, other: &H3Cell) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl ToCoordinate for H3Cell
impl ToCoordinate for H3Cell
sourcefn to_coordinate(&self) -> Result<Coordinate<f64>, Self::Error>
fn to_coordinate(&self) -> Result<Coordinate<f64>, Self::Error>
the centroid coordinate of the h3 index
type Error = Error
impl Copy for H3Cell
impl Eq for H3Cell
impl StructuralEq for H3Cell
impl StructuralPartialEq for H3Cell
Auto Trait Implementations
impl RefUnwindSafe for H3Cell
impl Send for H3Cell
impl Sync for H3Cell
impl Unpin for H3Cell
impl UnwindSafe for H3Cell
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more