pub(crate) mod bounding_volumes;
pub mod constants;
pub mod intersection_tests;
pub mod math;
pub mod projection;
use geometry::Point;
use mln_style::geo::LatLng;
use mln_style::size::Size;
pub type ScreenCoordinate = Point<f64>;
pub(crate) type ScreenLineString = Vec<Point<f64>>;
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum NorthOrientation {
#[default]
Upwards,
Rightwards,
Downwards,
Leftwards,
}
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct EdgeInsets {
pub top: f64,
pub left: f64,
pub bottom: f64,
pub right: f64,
}
impl EdgeInsets {
#[must_use]
pub const fn new(top: f64, left: f64, bottom: f64, right: f64) -> Self {
EdgeInsets { top, left, bottom, right }
}
#[must_use]
pub fn top(&self) -> f64 {
self.top
}
#[must_use]
pub fn left(&self) -> f64 {
self.left
}
#[must_use]
pub fn bottom(&self) -> f64 {
self.bottom
}
#[must_use]
pub fn right(&self) -> f64 {
self.right
}
#[must_use]
pub(crate) fn center_in(&self, size: Size) -> ScreenCoordinate {
Point::new(
(f64::from(size.width) - self.left() - self.right()) / 2.0 + self.left(),
(f64::from(size.height) - self.top() - self.bottom()) / 2.0 + self.top(),
)
}
}
impl std::ops::AddAssign for EdgeInsets {
fn add_assign(&mut self, o: EdgeInsets) {
self.top += o.top;
self.left += o.left;
self.bottom += o.bottom;
self.right += o.right;
}
}
impl std::ops::Add for EdgeInsets {
type Output = EdgeInsets;
fn add(mut self, o: EdgeInsets) -> EdgeInsets {
self += o;
self
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq)]
#[cfg(test)]
pub(crate) struct LatLngAltitude {
pub(crate) location: LatLng,
pub(crate) altitude: f64,
}
#[must_use]
pub fn lat_range(id: &crate::tile::UnwrappedTileID) -> [f32; 2] {
let latlng0 = LatLng::from_unwrapped_tile(id.canonical.z, id.canonical.x, id.canonical.y, id.wrap);
let below =
crate::tile::UnwrappedTileID::new(id.canonical.z, i64::from(id.canonical.x), i64::from(id.canonical.y) + 1);
let latlng1 = LatLng::from_unwrapped_tile(below.canonical.z, below.canonical.x, below.canonical.y, below.wrap);
[latlng0.latitude() as f32, latlng1.latitude() as f32]
}