1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#[cfg(test)]
mod integration_tests {
use crate::HilbertRTreeLeg;
#[test]
fn test_new_api_parameter_order() {
// Integration test to demonstrate the new API parameter order: (min_x, min_y, max_x, max_y)
let mut tree = HilbertRTreeLeg::new();
// Add some boxes using the new parameter order
tree.add(0.0, 0.0, 2.0, 2.0); // Box 0: bottom-left (0,0) to top-right (2,2)
tree.add(1.0, 1.0, 3.0, 3.0); // Box 1: bottom-left (1,1) to top-right (3,3) - overlaps Box 0
tree.add(5.0, 5.0, 6.0, 6.0); // Box 2: bottom-left (5,5) to top-right (6,6) - distant
tree.add(1.5, 1.5, 2.5, 2.5); // Box 3: bottom-left (1.5,1.5) to top-right (2.5,2.5) - inside others
tree.build();
// Test intersecting query using new parameter order
let mut results = Vec::new();
tree.query_intersecting(1.2, 1.2, 2.8, 2.8, &mut results);
// Should find boxes 0, 1, and 3 that intersect the region (1.2,1.2) to (2.8,2.8)
assert!(results.len() >= 2, "Should find at least 2 intersecting boxes");
assert!(results.contains(&0) || results.contains(&1) || results.contains(&3));
// Test point query
results.clear();
tree.query_point(1.8, 1.8, &mut results);
assert!(!results.is_empty(), "Point (1.8, 1.8) should be contained in at least one box");
// Test contain query using new parameter order
results.clear();
tree.query_contain(1.2, 1.2, 1.8, 1.8, &mut results);
// Should find boxes that completely contain the rectangle (1.2,1.2) to (1.8,1.8)
// Test contained_within query using new parameter order
results.clear();
tree.query_contained_within(0.5, 0.5, 3.5, 3.5, &mut results);
// Should find boxes contained in the large rectangle (0.5,0.5) to (3.5,3.5)
// All tests passed - API parameter order change is working!
println!("✅ New API parameter order (min_x, min_y, max_x, max_y) is working correctly!");
}
}