diff --git a/src/storage/u64idx/mod.rs b/src/storage/u64idx/mod.rs index 2aeb750..05265c3 100644 --- a/src/storage/u64idx/mod.rs +++ b/src/storage/u64idx/mod.rs @@ -46,7 +46,7 @@ use crate::{ }, qty::{Frequency, Hpx, MocQty, Time}, storage::u64idx::op1::{ - op1_mom_filter, op1_mom_sum, op1_mom_sum_from_data, op1_mom_sum_from_path, + op1_mom_filter, op1_mom_filter_mask, op1_mom_sum, op1_mom_sum_from_data, op1_mom_sum_from_path, }, }; @@ -1849,6 +1849,25 @@ impl U64MocStore { op1_mom_filter(index, mom_it) } + /// Set to 'false' the booleans associated to the UNIQ HEALPix cells + /// intersecting (or fully covered) by the MOC of given index. + /// + /// # Params + /// * `index`: index pf the S-MOC in the storage + /// * `it`: iterator on `uniq` HEALPix cells. + /// * `fully_covered_only`: set the boolean to false only if the cell is fully covered (else if it intersects) + pub fn multiordermap_filter_mask_moc<'a, I>( + &self, + index: usize, + it: I, + fully_covered_only: bool, + ) -> Result<(), String> + where + I: Sized + Iterator, + { + op1_mom_filter_mask(index, it, fully_covered_only) + } + /// Sum the value of the multi-order map in the given path which are in the given MOC. /// Remark: we have no information and cannot make any guess on the order if te `UNIQ` cell /// in the iterator. diff --git a/src/storage/u64idx/op1.rs b/src/storage/u64idx/op1.rs index 674d5fe..86ef4ed 100644 --- a/src/storage/u64idx/op1.rs +++ b/src/storage/u64idx/op1.rs @@ -296,7 +296,7 @@ pub(crate) fn op1_mom_sum_from_data(index: usize, mom_data: &[u8]) -> Result(index: usize, it: I) -> Result<(Vec, Vec), String> where I: Sized + Iterator, @@ -311,3 +311,38 @@ where InternalMoc::TimeSpace(_) => Err(String::from("MOM Filter not implemented for ST-MOCs.")), }) } + +/// Set to 'false' the booleans associated to the UNIQ HEALPix cells +/// intersecting (or fully covered) by the MOC of given index. +/// # Params +/// * `fully_covered_only`: set the boolean to false only if the cell is fully covered (else if it intersects) +pub(crate) fn op1_mom_filter_mask<'a, I>( + index: usize, + it: I, + fully_covered_only: bool, +) -> Result<(), String> +where + I: Sized + Iterator, +{ + store::exec_on_one_readonly_moc(index, move |moc| match moc { + InternalMoc::Space(moc) => { + if fully_covered_only { + for (uniq, flag) in it { + let (depth, ipix) = Hpx::::from_uniq_hpx(uniq); + let cell_fraction = moc.cell_fraction(depth, ipix); + *flag = cell_fraction < 1.0; + } + } else { + for (uniq, flag) in it { + let (depth, ipix) = Hpx::::from_uniq_hpx(uniq); + let cell_fraction = moc.cell_fraction(depth, ipix); + *flag = cell_fraction == 0.0; + } + } + Ok(()) + } + InternalMoc::Time(_) => Err(String::from("MOM Filter not implemented for T-MOCs.")), + InternalMoc::Frequency(_) => Err(String::from("MOM Filter not implemented for F-MOCs.")), + InternalMoc::TimeSpace(_) => Err(String::from("MOM Filter not implemented for ST-MOCs.")), + }) +}