diff --git a/CHANGELOG.md b/CHANGELOG.md index 20127bc..5fbdaad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # `cdshealpix` Change Log +## 0.7.2 + +Released 2024-11-12 + +### Bug correction + +* Wrong parameter (`cos(lon)` instead of `cos(lat)`) + in `h_to_h_and_shs` method leading to possibly miss + cells in cone/ring coverage in case of cones/ring + much smaller than requested HEALPix cells. + + ## 0.7.1 Released 2024-11-08 diff --git a/Cargo.toml b/Cargo.toml index 4786fe0..612647d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cdshealpix" -version = "0.7.1" +version = "0.7.2" authors = ["F.-X. Pineau "] edition = "2021" rust-version = "1.81" diff --git a/src/nested/mod.rs b/src/nested/mod.rs index 54a8a91..c5ceecd 100644 --- a/src/nested/mod.rs +++ b/src/nested/mod.rs @@ -2507,7 +2507,7 @@ impl Layer { } // Common variable let cos_cone_lat = cone_lat.cos(); - let shs_cone_radius = dbg!(to_squared_half_segment(cone_radius)); + let shs_cone_radius = to_squared_half_segment(cone_radius); // Special case of very large radius: test the 12 base cells if !has_best_starting_depth(cone_radius) { let distances = largest_center_to_vertex_distances_with_radius( @@ -2982,8 +2982,9 @@ impl Layer { ), ); let root_layer = get(depth_start); + let center_hash_at_depth_start = root_layer.hash(cone_lon, cone_lat); let mut neigs: Vec = root_layer - .neighbours(root_layer.hash(cone_lon, cone_lat), true) + .neighbours(center_hash_at_depth_start, true) .values_vec() .iter() .filter(|neigh| { @@ -3287,8 +3288,9 @@ impl Layer { ), ); let root_layer = get(depth_start); + let center_hash_at_depth_start = root_layer.hash(cone_lon, cone_lat); let mut neigs: Vec = root_layer - .neighbours(root_layer.hash(cone_lon, cone_lat), true) + .neighbours(center_hash_at_depth_start, true) .values_vec() .iter() .map(h_to_h_and_shs(cone_lon, cone_lat, cos_cone_lat, root_layer)) @@ -4399,7 +4401,7 @@ fn h_to_h_and_shs( let (lon, lat) = layer.center(hash); ( hash, - squared_half_segment(lon - cone_lon, lat - cone_lat, lon.cos(), cos_cone_lat), + squared_half_segment(lon - cone_lon, lat - cone_lat, lat.cos(), cos_cone_lat), ) } } @@ -4827,6 +4829,42 @@ mod tests { } } + #[test] + fn testok_cone_approx_custom_bmoc_v2() { + let actual_res = cone_coverage_approx_custom( + 6, + 3, + 8.401978_f64.to_radians(), + 84.675171_f64.to_radians(), + 0.0008_f64.to_radians(), + ); + /*for cell in actual_res.flat_iter() { + println!("@@@@@ cell a: {:?}", cell); + }*/ + let expected_res: [u64; 1] = [4075]; + assert_eq!(actual_res.flat_iter().deep_size(), expected_res.len()); + for (h1, h2) in actual_res.flat_iter().zip(expected_res.iter()) { + assert_eq!(h1, *h2); + } + + println!("----------"); + + let actual_res = cone_coverage_approx_custom( + 6, + 3, + 8.401978_f64.to_radians(), + 84.675171_f64.to_radians(), + 0.0004_f64.to_radians(), + ); + /*for cell in actual_res.flat_iter() { + println!("@@@@@ cell a: {:?}", cell); + }*/ + assert_eq!(actual_res.flat_iter().deep_size(), expected_res.len()); + for (h1, h2) in actual_res.flat_iter().zip(expected_res.iter()) { + assert_eq!(h1, *h2); + } + } + #[test] fn testok_cone_approx_custom_bmoc_dbg() { let actual_res = cone_coverage_approx_custom(