Expand description
Cell is an S2 region object that represents a cell. Unlike CellIDs, it supports efficient containment and intersection tests. However, it is also a more expensive representation.
Fields§
§orientation: u8
§id: CellID
§uv: Rect
Implementations§
source§impl Cell
impl Cell
pub fn face(&self) -> u8
pub fn level(&self) -> u8
pub fn is_leaf(&self) -> bool
pub fn size_ij(&self) -> u64
sourcepub fn vertex(&self, k: usize) -> Point
pub fn vertex(&self, k: usize) -> Point
vertex returns the k-th vertex of the cell (k = 0,1,2,3) in CCW order (lower left, lower right, upper right, upper left in the UV plane).
pub fn vertices(&self) -> [Point; 4]
sourcepub fn edge(&self, k: usize) -> Point
pub fn edge(&self, k: usize) -> Point
edge returns the inward-facing normal of the great circle passing through the CCW ordered edge from vertex k to vertex k+1 (mod 4) (for k = 0,1,2,3).
sourcepub fn center(&self) -> Point
pub fn center(&self) -> Point
center returns the direction vector corresponding to the center in (s,t)-space of the given cell. This is the point at which the cell is divided into four subcells; it is not necessarily the centroid of the cell in (u,v)-space or (x,y,z)-space
sourcepub fn children(&self) -> Option<[Cell; 4]>
pub fn children(&self) -> Option<[Cell; 4]>
Children returns the four direct children of this cell in traversal order and returns true. If this is a leaf cell, or the children could not be created, false is returned. The C++ method is called Subdivide.
sourcepub fn exact_area(&self) -> f64
pub fn exact_area(&self) -> f64
exact_area returns the area of this cell as accurately as possible.
sourcepub fn approx_area(&self) -> f64
pub fn approx_area(&self) -> f64
approx_area returns the approximate area of this cell. This method is accurate to within 3% percent for all cell sizes and accurate to within 0.1% for cells at level 5 or higher (i.e. squares 350km to a side or smaller on the Earth’s surface). It is moderately cheap to compute.
sourcepub fn average_area(&self) -> f64
pub fn average_area(&self) -> f64
average_area returns the average area of cells at the level of this cell. This is accurate to within a factor of 1.7.
sourcepub fn latitude(&self, i: i32, j: i32) -> Angle
pub fn latitude(&self, i: i32, j: i32) -> Angle
latitude returns the latitude of the cell vertex given by (i,j), where “i” and “j” are either 0 or 1.
sourcepub fn longitude(&self, i: i32, j: i32) -> Angle
pub fn longitude(&self, i: i32, j: i32) -> Angle
longitude returns the longitude of the cell vertex given by (i,j), where “i” and “j” are either 0 or 1.
sourcepub fn rect_bound(&self) -> Rect
pub fn rect_bound(&self) -> Rect
rect_bound returns the bounding rectangle of this cell.
pub fn contains_point(&self, p: &Point) -> bool
Trait Implementations§
source§impl<'de> Deserialize<'de> for Cell
impl<'de> Deserialize<'de> for Cell
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 Region for Cell
impl Region for Cell
source§fn intersects_cell(&self, other: &Cell) -> bool
fn intersects_cell(&self, other: &Cell) -> bool
intersects_cell reports whether the intersection of this cell and the other cell is not nil.
source§fn contains_cell(&self, other: &Cell) -> bool
fn contains_cell(&self, other: &Cell) -> bool
contains_cell reports whether this cell contains the other cell.