Bounds::zero and Bounds::eq

This commit is contained in:
Michael Kirk 2021-01-12 09:09:24 -06:00 committed by Dustin Carlino
parent 4c6d7af76d
commit f8a9844b2c

View File

@ -5,7 +5,7 @@ use aabb_quadtree::geom::{Point, Rect};
use crate::{LonLat, Polygon, Pt2D, Ring}; use crate::{LonLat, Polygon, Pt2D, Ring};
/// Represents a rectangular boundary of `Pt2D` points. /// Represents a rectangular boundary of `Pt2D` points.
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Bounds { pub struct Bounds {
pub min_x: f64, pub min_x: f64,
pub min_y: f64, pub min_y: f64,
@ -24,6 +24,15 @@ impl Bounds {
} }
} }
pub fn zero() -> Self {
Bounds {
min_x: 0.0,
min_y: 0.0,
max_x: 0.0,
max_y: 0.0,
}
}
/// Create a boundary covering some points. /// Create a boundary covering some points.
pub fn from(pts: &Vec<Pt2D>) -> Bounds { pub fn from(pts: &Vec<Pt2D>) -> Bounds {
let mut b = Bounds::new(); let mut b = Bounds::new();