MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / join_with_dwithin

Function join_with_dwithin

nodedb-spatial/src/spatial_join.rs:222–247  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

220
221 #[test]
222 fn join_with_dwithin() {
223 let left = vec![(1u64, Geometry::point(0.0, 0.0))];
224 let right = vec![(100u64, Geometry::point(0.001, 0.0))]; // ~111m away
225
226 let index = build_join_index(&left);
227 let probes: Vec<(u64, BoundingBox)> = right
228 .iter()
229 .map(|(id, g)| {
230 // Expand bbox by distance for R-tree search.
231 (*id, geometry_bbox(g).expand_meters(500.0))
232 })
233 .collect();
234
235 let left_map: std::collections::HashMap<u64, Geometry> = left.into_iter().collect();
236 let right_map: std::collections::HashMap<u64, Geometry> = right.into_iter().collect();
237
238 let result = spatial_join(
239 &index,
240 &probes,
241 &|id| left_map.get(&id).cloned(),
242 &|id| right_map.get(&id).cloned(),
243 SpatialJoinPredicate::DWithin(500.0), // 500m
244 );
245
246 assert_eq!(result.pairs.len(), 1);
247 }
248}

Callers

nothing calls this directly

Calls 7

build_join_indexFunction · 0.85
geometry_bboxFunction · 0.85
spatial_joinFunction · 0.85
collectMethod · 0.80
expand_metersMethod · 0.80
iterMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected