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

Function contained_square

nodedb-spatial/src/predicates/intersection.rs:261–275  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

259
260 #[test]
261 fn contained_square() {
262 let a = square(0.0, 10.0);
263 let b = square(2.0, 8.0);
264 let result = st_intersection(&a, &b);
265 if let Geometry::Polygon { coordinates } = &result {
266 // Result should be approximately b itself.
267 let xs: Vec<f64> = coordinates[0].iter().map(|c| c[0]).collect();
268 let min_x = xs.iter().cloned().fold(f64::INFINITY, f64::min);
269 let max_x = xs.iter().cloned().fold(f64::NEG_INFINITY, f64::max);
270 assert!((min_x - 2.0).abs() < 0.01);
271 assert!((max_x - 8.0).abs() < 0.01);
272 } else {
273 panic!("expected Polygon");
274 }
275 }
276
277 #[test]
278 fn disjoint_returns_empty() {

Callers

nothing calls this directly

Calls 5

st_intersectionFunction · 0.85
collectMethod · 0.80
foldMethod · 0.80
squareFunction · 0.70
iterMethod · 0.45

Tested by

no test coverage detected