1pub(crate) mod bounding_volumes;
7pub mod constants;
8pub mod intersection_tests;
9pub mod math;
10pub mod projection;
11
12use geometry::Point;
13use mln_style::geo::LatLng;
14use mln_style::size::Size;
15
16pub type ScreenCoordinate = Point<f64>;
17pub(crate) type ScreenLineString = Vec<Point<f64>>;
18
19#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
21pub enum NorthOrientation {
22 #[default]
23 Upwards,
24 Rightwards,
25 Downwards,
26 Leftwards,
27}
28
29#[derive(Clone, Copy, Debug, Default, PartialEq)]
33pub struct EdgeInsets {
34 pub top: f64,
36 pub left: f64,
38 pub bottom: f64,
40 pub right: f64,
42}
43
44impl EdgeInsets {
45 #[must_use]
46 pub const fn new(top: f64, left: f64, bottom: f64, right: f64) -> Self {
47 EdgeInsets { top, left, bottom, right }
48 }
49
50 #[must_use]
51 pub fn top(&self) -> f64 {
52 self.top
53 }
54 #[must_use]
55 pub fn left(&self) -> f64 {
56 self.left
57 }
58 #[must_use]
59 pub fn bottom(&self) -> f64 {
60 self.bottom
61 }
62 #[must_use]
63 pub fn right(&self) -> f64 {
64 self.right
65 }
66
67 #[must_use]
70 pub(crate) fn center_in(&self, size: Size) -> ScreenCoordinate {
71 Point::new(
72 (f64::from(size.width) - self.left() - self.right()) / 2.0 + self.left(),
73 (f64::from(size.height) - self.top() - self.bottom()) / 2.0 + self.top(),
74 )
75 }
76}
77
78impl std::ops::AddAssign for EdgeInsets {
79 fn add_assign(&mut self, o: EdgeInsets) {
80 self.top += o.top;
81 self.left += o.left;
82 self.bottom += o.bottom;
83 self.right += o.right;
84 }
85}
86
87impl std::ops::Add for EdgeInsets {
88 type Output = EdgeInsets;
89 fn add(mut self, o: EdgeInsets) -> EdgeInsets {
90 self += o;
91 self
92 }
93}
94
95#[derive(Clone, Copy, Debug, Default, PartialEq)]
96#[cfg(test)]
97pub(crate) struct LatLngAltitude {
98 pub(crate) location: LatLng,
99 pub(crate) altitude: f64,
100}
101
102#[must_use]
104pub fn lat_range(id: &crate::tile::UnwrappedTileID) -> [f32; 2] {
105 let latlng0 = LatLng::from_unwrapped_tile(id.canonical.z, id.canonical.x, id.canonical.y, id.wrap);
106 let below =
107 crate::tile::UnwrappedTileID::new(id.canonical.z, i64::from(id.canonical.x), i64::from(id.canonical.y) + 1);
108 let latlng1 = LatLng::from_unwrapped_tile(below.canonical.z, below.canonical.x, below.canonical.y, below.wrap);
109 [latlng0.latitude() as f32, latlng1.latitude() as f32]
110}