pub struct MortonCode(pub u64);Expand description
A 64-bit Morton (Z-order) code.
Wraps a raw u64. The encoder masks off bit 63 to preserve the NDS
semantics of the reference implementation.
Tuple Fields§
§0: u64Implementations§
Source§impl MortonCode
impl MortonCode
Sourcepub fn new(morton_code: u64) -> Self
pub fn new(morton_code: u64) -> Self
Construct a MortonCode from a raw 64-bit value.
Most callers use MortonCode::from_nds_coordinates instead.
Sourcepub fn from_nds_coordinates(x: i32, y: i32) -> MortonCode
pub fn from_nds_coordinates(x: i32, y: i32) -> MortonCode
Encode NDS integer coordinates into a Morton (Z-order) code.
x is NDS longitude (signed 32-bit), y is NDS latitude
(signed 31-bit). Out-of-range inputs are wrapped, exactly as in the
Python reference. Bit 63 is masked off.
Sourcepub fn to_nds_coordinates(&self) -> (i32, i32)
pub fn to_nds_coordinates(&self) -> (i32, i32)
Decode this Morton code back into NDS integer coordinates.
Inverse of MortonCode::from_nds_coordinates. Returns (x, y) as
signed integers: NDS longitude (32-bit) and NDS latitude (31-bit).
Trait Implementations§
Source§impl Clone for MortonCode
impl Clone for MortonCode
Source§fn clone(&self) -> MortonCode
fn clone(&self) -> MortonCode
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for MortonCode
Source§impl Debug for MortonCode
impl Debug for MortonCode
Source§impl Display for MortonCode
impl Display for MortonCode
impl Eq for MortonCode
Source§impl Hash for MortonCode
impl Hash for MortonCode
Source§impl Ord for MortonCode
impl Ord for MortonCode
Source§fn cmp(&self, other: &MortonCode) -> Ordering
fn cmp(&self, other: &MortonCode) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for MortonCode
impl PartialEq for MortonCode
Source§fn eq(&self, other: &MortonCode) -> bool
fn eq(&self, other: &MortonCode) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for MortonCode
impl PartialOrd for MortonCode
impl StructuralPartialEq for MortonCode
Auto Trait Implementations§
impl Freeze for MortonCode
impl RefUnwindSafe for MortonCode
impl Send for MortonCode
impl Sync for MortonCode
impl Unpin for MortonCode
impl UnsafeUnpin for MortonCode
impl UnwindSafe for MortonCode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more