Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
cov/c3 ▾

Modern-Apps.git / scripts / maps / tile_build / src / subdivide_part3.rs

subdivide_part3.rs41 lines · 1.8 KiBRaw
1 /// An empty geometry, and one entirely off the grid, produce nothing rather than
2 /// panicking on a start cell that does not exist.
3 #[test]
4 fn nothing_to_tile_emits_nothing() {
5 let mut hit = 0usize;
6 for g in [
7 Geometry::<SigPt>::Lines(vec![]),
8 Geometry::<SigPt>::Points(vec![]),
9 Geometry::<SigPt>::Polygons(vec![]),
10 Geometry::Lines(vec![sig(&[(w(-40.0), w(-40.0)), (w(-30.0), w(-30.0))])]),
11 Geometry::Points(sig(&[(f64::NAN, 0.0)])),
12 ] {
13 subdivide(&g, 4, EXTENT, BUFFER, &mut |_, _, _| hit += 1);
14 }
15 assert_eq!(hit, 0);
16 }
17
18 /// Points are bucketed rather than descended, and a point inside a neighbour's
19 /// buffer is in both tiles -- which is what the per-tile `contains` filter did.
20 #[test]
21 fn a_point_lands_in_every_tile_whose_buffer_holds_it() {
22 let g = Geometry::Points(sig(&[(w(1.0) + 1.0, w(1.0) + 1.0)]));
23 let mut tiles: Vec<(u64, u64)> = Vec::new();
24 subdivide(&g, 4, EXTENT, BUFFER, &mut |tx, ty, got| {
25 assert_eq!(vertices(got), 1);
26 tiles.push((tx, ty));
27 });
28 assert_eq!(tiles, vec![(0, 0), (0, 1), (1, 0), (1, 1)]);
29 }
30
31 /// Points keep their input order within a tile. The drop policy's tie-break is the
32 /// feature index, but a MultiPoint's own parts have no index of their own, so
33 /// their order is the order they arrived in.
34 #[test]
35 fn points_keep_their_input_order_within_a_tile() {
36 let want = sig(&[(w(0.9), w(0.1)), (w(0.1), w(0.9)), (w(0.5), w(0.5))]);
37 let g = Geometry::Points(want.clone());
38 subdivide(&g, 4, EXTENT, BUFFER, &mut |_, _, got| {
39 assert_eq!(*got, Geometry::Points(want.clone()))
40 });
41 }