#[repr(transparent)]pub struct H3Cell(_);
Expand description
H3 Index representing a H3 Cell (hexagon)
Implementations§
source§impl H3Cell
impl H3Cell
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.
source§impl 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§
source§impl<'de> Deserialize<'de> for H3Cell
impl<'de> Deserialize<'de> for H3Cell
source§fn 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>,
source§impl FromH3Index for H3Cell
impl FromH3Index for H3Cell
fn from_h3index(h3index: H3Index) -> Self
source§impl FromStr for H3Cell
impl FromStr for H3Cell
source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Parse a hex-representation of a H3Cell from a string.
With the parse
feature enabled this function is also able
to parse strings containing integers and a custom coordinate-based format
in the form of "x,y,resolution"
.
Examples:
use h3ron::{H3Cell, Index};
use std::str::FromStr;
let index = H3Cell::from_str("89283080ddbffff").unwrap();
#[cfg(feature = "parse")]
{
// parse from a string containing an integer
let index = H3Cell::from_str("617700169518678015").unwrap();
// parse from coordinates and resolution
let index = H3Cell::from_str("23.3,12.3,6").unwrap();
}
source§impl Index for H3Cell
impl Index for H3Cell
source§fn resolution(&self) -> u8
fn resolution(&self) -> u8
source§fn direction(&self) -> H3Direction
fn direction(&self) -> H3Direction
source§fn direction_checked(&self) -> Result<H3Direction, Error>
fn direction_checked(&self) -> Result<H3Direction, Error>
source§fn direction_to_parent_resolution(
&self,
target_resolution: u8
) -> Result<H3Direction, Error>
fn direction_to_parent_resolution(
&self,
target_resolution: u8
) -> Result<H3Direction, Error>
target_resolution
source§impl Ord for H3Cell
impl Ord for H3Cell
source§impl PartialEq<H3Cell> for H3Cell
impl PartialEq<H3Cell> for H3Cell
source§impl PartialOrd<H3Cell> for H3Cell
impl PartialOrd<H3Cell> for H3Cell
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl ToCoordinate for H3Cell
impl ToCoordinate for H3Cell
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§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.