This commit is contained in:
vcoppe
2026-09-24 20:55:30 +02:00
parent 497ac120ec
commit 27c0a57cc1
13 changed files with 296 additions and 143 deletions
+32 -1
View File
@@ -10,8 +10,39 @@ pub struct LngLat {
pub lat: f64,
}
#[derive(Debug, Default)]
#[derive(Debug)]
pub struct LngLatBounds {
pub sw: LngLat,
pub ne: LngLat,
}
impl Default for LngLatBounds {
fn default() -> Self {
Self {
sw: LngLat {
lng: 180.0,
lat: 90.0,
},
ne: LngLat {
lng: -180.0,
lat: -90.0,
},
}
}
}
impl LngLatBounds {
pub fn extend(&mut self, coordinates: LngLat) {
self.sw.lng = self.sw.lng.min(coordinates.lng);
self.sw.lat = self.sw.lat.min(coordinates.lat);
self.ne.lng = self.ne.lng.min(coordinates.lng);
self.ne.lat = self.ne.lat.min(coordinates.lat);
}
pub fn merge(&mut self, other: &LngLatBounds) {
self.sw.lng = self.sw.lng.min(other.sw.lng);
self.sw.lat = self.sw.lat.min(other.sw.lat);
self.ne.lng = self.ne.lng.min(other.ne.lng);
self.ne.lat = self.ne.lat.min(other.ne.lat);
}
}