1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! Utiles traits
use crate::parent::Parents;
use crate::TileLike;
use std::hash::Hash;
/// `IsOk` trait for checking if a value is Ok and returns a result
/// of self or an error
pub trait IsOk: Sized {
/// Returns `Ok` if the value is `Ok` or an error
///
/// # Errors
///
/// Returns an error if the value is not `Ok`
fn ok(&self) -> Result<Self, crate::UtilesCoreError>;
}
/// `Coord2d` like trait for 2D coordinates has x/y getters
pub trait Coord2dLike {
/// Returns the x value
fn x(&self) -> f64;
/// Returns the y value
fn y(&self) -> f64;
}
/// `LngLat` like trait
pub trait LngLatLike: Coord2dLike {
/// Returns the longitude value
fn lng(&self) -> f64;
/// Returns the longitude value
fn lon(&self) -> f64 {
self.lng()
}
/// Returns the longitude value
fn longitude(&self) -> f64 {
self.lat()
}
/// Returns the latitude value
fn lat(&self) -> f64;
/// Returns the latitude value
fn latitude(&self) -> f64 {
self.lat()
}
}
pub trait TileParent: Eq + Hash + Copy + TileLike {
fn parent(&self, zoom: Option<u8>) -> Option<Self>
where
Self: Sized;
fn iter_parents(&self) -> Parents<Self> {
Parents {
current: self.parent(None),
}
}
#[must_use]
fn root() -> Self
where
Self: Sized;
}
pub trait TileChildren1: Eq + Hash + Copy + TileLike {
/// Returns direct children in Z order:
/// 1) top-left
/// 2) top-right
/// 3) bottom-left
/// 4) bottom-right
#[must_use]
fn children1(&self) -> [Self; 4];
}