use crate::grouping::area::Area;
#[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Ord, Hash)]
pub struct AreaOfInterest<const MCL: usize, const MCC: usize, const MPL: usize, S> {
pub area: Area<MCL, MCC, MPL, S>,
pub max_count: u64,
pub max_size: u64,
}
impl<const MCL: usize, const MCC: usize, const MPL: usize, S> AreaOfInterest<MCL, MCC, MPL, S> {
pub fn new(area: Area<MCL, MCC, MPL, S>, max_count: u64, max_size: u64) -> Self {
Self {
area,
max_count,
max_size,
}
}
}
impl<const MCL: usize, const MCC: usize, const MPL: usize, S> AreaOfInterest<MCL, MCC, MPL, S>
where
S: PartialOrd + Clone,
{
pub fn intersection(
&self,
other: &AreaOfInterest<MCL, MCC, MPL, S>,
) -> Option<AreaOfInterest<MCL, MCC, MPL, S>> {
self.area
.intersection(&other.area)
.map(|area_intersection| Self {
area: area_intersection,
max_count: core::cmp::min(self.max_count, other.max_count),
max_size: self.max_size.min(other.max_size),
})
}
}