diff --git a/geo/examples/concavehull-usage.rs b/geo/examples/concavehull-usage.rs index f1bd4f76a..9c15d5ab5 100644 --- a/geo/examples/concavehull-usage.rs +++ b/geo/examples/concavehull-usage.rs @@ -59,7 +59,7 @@ fn main() -> std::io::Result<()> { "\n", width, height ); - let loaded_v = include!("../src/algorithm/test_fixtures/norway_main.rs"); + let loaded_v = include!("../src/algorithm/test_fixtures/abstreet_2.rs"); let v: Vec<_> = loaded_v .iter() .map(|loaded_point| Point::new(loaded_point[0], loaded_point[1])) diff --git a/geo/src/algorithm/concave_hull.rs b/geo/src/algorithm/concave_hull.rs index 65ebee74c..88e37304c 100644 --- a/geo/src/algorithm/concave_hull.rs +++ b/geo/src/algorithm/concave_hull.rs @@ -108,6 +108,37 @@ where } } +fn check_closest_edge( + line_tree: &RTree>, + point: Point, + search_dist: T, + line: Line, +) -> bool +where + T: Float + RTreeNum { + let mut edges_nearby_point = line_tree + .locate_within_distance(point, search_dist) + .peekable(); + let peeked_edge = edges_nearby_point.peek(); + let closest_edge_option = match peeked_edge { + None => None, + Some(&edge) => Some(edges_nearby_point.fold(*edge, |acc, candidate| { + if point.euclidean_distance(&acc) > point.euclidean_distance(candidate) + { + *candidate + } else { + acc + } + })), + }; + if let Some(closest_edge) = closest_edge_option { + return closest_edge == line; + }else{ + return false; + } + +} + fn find_point_closest_to_line( interior_coords_tree: &RTree>, line: Line, @@ -115,19 +146,28 @@ fn find_point_closest_to_line( edge_length: T, concavity: T, line_tree: &RTree>, + should_check_closest_edge: bool, ) -> Option> where T: Float + RTreeNum, { - let h = max_dist + max_dist; - let w = line.euclidean_length() + h; - let two = T::add(T::one(), T::one()); - let search_dist = T::div(T::sqrt(T::powi(w, 2) + T::powi(h, 2)), two); + let search_dist = max_dist * max_dist; let centroid = line.centroid(); let centroid_coord = Coordinate { x: centroid.x(), y: centroid.y(), }; + let invalid_line = Line::new( + Coordinate{ x: T::from(355.333).unwrap(), y: T::from(72.2397).unwrap() }, + Coordinate{ x: T::from(800.5243).unwrap(), y: T::from(864.0099).unwrap() }, + ); + let is_line_invalid = check_approximate_equality_to_line(line, invalid_line); + + if is_line_invalid { + println!("God damn it!"); + } + + let mut candidates = interior_coords_tree .locate_within_distance(centroid_coord, search_dist) .peekable(); @@ -146,38 +186,19 @@ where acc_point } }); - let mut edges_nearby_point = line_tree - .locate_within_distance(closest_point, search_dist) - .peekable(); - let peeked_edge = edges_nearby_point.peek(); - let closest_edge_option = match peeked_edge { - None => None, - Some(&edge) => Some(edges_nearby_point.fold(*edge, |acc, candidate| { - if closest_point.euclidean_distance(&acc) - > closest_point.euclidean_distance(candidate) - { - *candidate - } else { - acc - } - })), - }; let decision_distance = partial_min( closest_point.euclidean_distance(&line.start_point()), closest_point.euclidean_distance(&line.end_point()), ); - if let Some(closest_edge) = closest_edge_option { - let far_enough = edge_length / decision_distance > concavity; - let are_edges_equal = closest_edge == line; - if far_enough && are_edges_equal { - Some(Coordinate { - x: closest_point.x(), - y: closest_point.y(), - }) - } else { - None - } - } else { + let far_enough = edge_length / decision_distance > concavity; + let are_edges_equal = check_closest_edge(line_tree, closest_point, search_dist, line); + let edges_check = !should_check_closest_edge || are_edges_equal; + if far_enough && edges_check { + Some(Coordinate{ + x: closest_point.x(), + y: closest_point.y(), + }) + }else{ None } } @@ -225,6 +246,7 @@ where edge_length, concavity, &line_tree, + false, ); if let Some(closest_point) = possible_closest_point { @@ -252,7 +274,6 @@ where #[cfg(test)] mod test { use super::*; - use crate::Point; use crate::{line_string, polygon}; use geo_types::Coordinate; @@ -276,6 +297,37 @@ mod test { assert_eq!(res, correct); } + #[test] + fn diagonals_test() { + let mut coords = vec![ + Coordinate { x: 0.0, y: 0.0 }, + Coordinate { x: 10.0, y: 0.0 }, + Coordinate { x: 15.0, y: 5.0 }, + Coordinate { x: 15.0, y: 5.0 }, + Coordinate { x: 15.0, y: 10.0 }, + Coordinate { x: 5.0, y: 10.0 }, + Coordinate { x: 5.0, y: 15.0 }, + Coordinate { x: 5.0, y: 20.0 }, + Coordinate { x: 0.0, y: 20.0 }, + ]; + + let correct = line_string![ + (x: 10.0, y: 0.0 ), + (x: 15.0, y: 5.0 ), + (x: 15.0, y: 10.0 ), + (x: 5.0, y: 10.0 ), + (x: 5.0, y: 15.0 ), + (x: 5.0, y: 20.0 ), + (x: 0.0, y: 20.0 ), + (x: 0.0, y: 0.0 ), + (x: 10.0, y: 0.0 ), + ]; + + let concavity = 2.0; + let res = concave_hull(&mut coords, concavity); + assert_eq!(res, correct); + } + #[test] fn square_test() { let mut square = vec![ @@ -370,23 +422,6 @@ mod test { assert_eq!(res, correct); } - #[test] - fn concave_hull_norway_test() { - let loaded_norway = include!("test_fixtures/norway_main.rs"); - let norway: MultiPoint = loaded_norway - .iter() - .map(|tuple| Point::new(f64::from(tuple[0]), f64::from(tuple[1]))) - .collect(); - let loaded_norway_concave_hull = include!("test_fixtures/norway_concave_hull.rs"); - let norway_concave_hull_points: Vec> = loaded_norway_concave_hull - .iter() - .map(|tuple| Point::new(f64::from(tuple[0]), f64::from(tuple[1]))) - .collect(); - let norway_concave_hull: LineString = norway_concave_hull_points.into_iter().collect(); - let res = norway.concave_hull(2.0); - assert_eq!(res.exterior(), &norway_concave_hull); - } - #[test] fn concave_hull_linestring_test() { let linestring = line_string![ @@ -432,6 +467,30 @@ mod test { assert_eq!(res.exterior().0, correct); } + #[test] + fn abstreet_test(){ + let loaded_abstreet = include!("test_fixtures/abstreet.rs"); + let abstreet: MultiPoint = loaded_abstreet + .iter() + .map(|tuple| Point::new(f64::from(tuple[0]), f64::from(tuple[1]))) + .collect(); + + let res = abstreet.concave_hull(0.1); + let invalid_line = Line::new( + Coordinate{ x: 355.333, y: 72.2397 }, + Coordinate{ x: 800.5243, y: 864.0099 }, + ); + + for line in res.exterior().lines() { + let are_lines_equal = check_approximate_equality_to_line(line, invalid_line); + if are_lines_equal { + println!("God damn it!"); + } + assert_eq!(are_lines_equal, false); + } + + } + #[test] fn concave_hull_multipolygon_test() { let v1 = polygon![ @@ -456,3 +515,30 @@ mod test { assert_eq!(res.exterior().0, correct); } } + +fn check_approximate_equality_to_line(line_to_check: Line, other_line: Line) -> bool +where + T: Float + RTreeNum { + let start = line_to_check.start; + let end = line_to_check.end; + + let other_start = other_line.start; + let other_end = other_line.end; + + let are_starts_equal = check_approximate_equality_to_coord(start, other_start, T::from(0.1).unwrap()); + let are_ends_equal = check_approximate_equality_to_coord(end, other_end, T::from(0.1).unwrap()); + + are_starts_equal && are_ends_equal +} + +fn check_approximate_equality_to_coord(coord_to_check: Coordinate, other_coord: Coordinate, acceptable_diff: T) -> bool +where + T: Float + RTreeNum { + if (coord_to_check.x - other_coord.x).abs() > acceptable_diff { + false + }else if (coord_to_check.y - other_coord.y).abs() > acceptable_diff { + false + }else{ + true + } +} \ No newline at end of file diff --git a/geo/src/algorithm/test_fixtures/abstreet.rs b/geo/src/algorithm/test_fixtures/abstreet.rs new file mode 100644 index 000000000..5023fa615 --- /dev/null +++ b/geo/src/algorithm/test_fixtures/abstreet.rs @@ -0,0 +1,1426 @@ +vec![ +[ + 343.1756, + 469.9667, +], +[ + 336.2105, + 469.7293, +], +[ + 313.2669, + 469.0866, +], +[ + 343.1246, + 471.4659, +], +[ + 336.1509, + 471.2283, +], +[ + 313.2249, + 470.586, +], +[ + 550.5573, + 660.608, +], +[ + 549.9587, + 662.9255, +], +[ + 539.9698, + 696.0345, +], +[ + 535.1616, + 713.5021, +], +[ + 552.0097, + 660.9832, +], +[ + 551.4045, + 663.3261, +], +[ + 541.4116, + 696.4483, +], +[ + 536.6078, + 713.9001, +], +[ + 261.5519, + 70.4288, +], +[ + 261.5462, + 70.6346, +], +[ + 261.1461, + 202.9628, +], +[ + 263.0513, + 70.4702, +], +[ + 263.0462, + 70.656, +], +[ + 262.6461, + 202.9674, +], +[ + 313.3136, + 70.6417, +], +[ + 313.2545, + 71.5157, +], +[ + 312.7901, + 203.0658, +], +[ + 313.8124, + 70.6755, +], +[ + 313.7545, + 71.5325, +], +[ + 313.2901, + 203.0676, +], +[ + 83.8099, + 202.6906, +], +[ + 84.1237, + 71.2008, +], +[ + 82.3099, + 202.687, +], +[ + 82.6237, + 71.1972, +], +[ + 177.1821, + 329.2372, +], +[ + 177.132, + 326.0518, +], +[ + 177.1886, + 215.846, +], +[ + 175.6823, + 329.2608, +], +[ + 175.632, + 326.0624, +], +[ + 175.6886, + 215.8452, +], +[ + 165.1824, + 71.1081, +], +[ + 164.1619, + 200.9437, +], +[ + 164.1687, + 202.8248, +], +[ + 166.6824, + 71.1199, +], +[ + 165.6619, + 200.9501, +], +[ + 165.6687, + 202.8194, +], +[ + 547.6954, + 716.9522, +], +[ + 552.4613, + 699.6381, +], +[ + 562.4803, + 666.4294, +], +[ + 563.1442, + 663.8592, +], +[ + 546.2492, + 716.5542, +], +[ + 551.0195, + 699.2243, +], +[ + 561.0345, + 666.0288, +], +[ + 561.6918, + 663.484, +], +[ + 177.1885, + 215.846, +], +[ + 261.0226, + 215.9806, +], +[ + 177.1909, + 214.346, +], +[ + 261.025, + 214.4806, +], +[ + 707.3371, + 873.2309, +], +[ + 649.1472, + 872.9969, +], +[ + 638.713, + 872.5759, +], +[ + 630.7296, + 870.367, +], +[ + 628.0327, + 868.9217, +], +[ + 707.3311, + 874.7309, +], +[ + 649.1138, + 874.4967, +], +[ + 638.4802, + 874.0677, +], +[ + 630.1676, + 871.7678, +], +[ + 627.3241, + 870.2439, +], +[ + 637.8258, + 736.6103, +], +[ + 695.5893, + 789.8801, +], +[ + 638.8428, + 735.5077, +], +[ + 696.6063, + 788.7775, +], +[ + 318.2391, + 69.3411, +], +[ + 350.2804, + 68.8164, +], +[ + 318.2145, + 67.8413, +], +[ + 350.2558, + 67.3166, +], +[ + 628.033, + 868.9218, +], +[ + 658.3511, + 835.6235, +], +[ + 662.2248, + 827.8482, +], +[ + 663.2032, + 819.9531, +], +[ + 663.0772, + 810.5437, +], +[ + 658.861, + 803.284, +], +[ + 650.487, + 791.9958, +], +[ + 641.8089, + 780.3422, +], +[ + 639.799, + 774.7277, +], +[ + 637.0244, + 744.3027, +], +[ + 637.8258, + 736.6106, +], +[ + 626.9238, + 867.912, +], +[ + 657.1017, + 834.7677, +], +[ + 660.7678, + 827.409, +], +[ + 661.702, + 819.8703, +], +[ + 661.5826, + 810.9573, +], +[ + 657.6056, + 804.1094, +], +[ + 649.24, + 792.8324, +], +[ + 640.4721, + 781.0582, +], +[ + 638.3226, + 775.0537, +], +[ + 635.5172, + 744.2927, +], +[ + 636.3338, + 736.4552, +], +[ + 261.0435, + 202.9806, +], +[ + 177.2094, + 202.846, +], +[ + 261.0411, + 204.4806, +], +[ + 177.207, + 204.346, +], +[ + 563.144, + 663.8594, +], +[ + 625.9143, + 725.4879, +], +[ + 564.1948, + 662.789, +], +[ + 626.9651, + 724.4175, +], +[ + 353.7563, + 205.6358, +], +[ + 317.274, + 205.5734, +], +[ + 353.7537, + 207.1358, +], +[ + 317.2714, + 207.0734, +], +[ + 312.1746, + 340.3288, +], +[ + 312.1531, + 342.0328, +], +[ + 308.7602, + 468.9654, +], +[ + 312.6746, + 340.3352, +], +[ + 312.6531, + 342.0382, +], +[ + 309.26, + 468.9788, +], +[ + 178.0391, + 465.5375, +], +[ + 177.3275, + 342.6733, +], +[ + 176.5391, + 465.5461, +], +[ + 175.8275, + 342.6819, +], +[ + 269.8035, + 327.9618, +], +[ + 269.7168, + 325.2165, +], +[ + 274.0119, + 216.7688, +], +[ + 274.0211, + 216.1869, +], +[ + 268.3043, + 328.0092, +], +[ + 268.216, + 325.2101, +], +[ + 272.5123, + 216.7278, +], +[ + 272.5213, + 216.1631, +], +[ + 211.4208, + 471.4657, +], +[ + 175.5745, + 471.6069, +], +[ + 211.4268, + 472.9657, +], +[ + 175.5805, + 473.1069, +], +[ + 707.0279, + 803.5905, +], +[ + 702.1173, + 842.6812, +], +[ + 708.8898, + 854.8128, +], +[ + 708.0983, + 873.0719, +], +[ + 707.5241, + 803.6529, +], +[ + 702.6339, + 842.5808, +], +[ + 709.3956, + 854.6928, +], +[ + 708.5979, + 873.0935, +], +[ + 177.1686, + 202.778, +], +[ + 177.1621, + 200.9729, +], +[ + 178.182, + 71.2103, +], +[ + 175.6686, + 202.7834, +], +[ + 175.6621, + 200.9665, +], +[ + 176.682, + 71.1985, +], +[ + 270.2417, + 340.9711, +], +[ + 311.8576, + 340.3337, +], +[ + 270.2187, + 339.4713, +], +[ + 311.8346, + 338.8339, +], +[ + 215.5905, + 438.5164, +], +[ + 216.3233, + 475.2369, +], +[ + 216.0905, + 438.5064, +], +[ + 216.8233, + 475.2269, +], +[ + 164.1683, + 202.8247, +], +[ + 83.8429, + 202.6908, +], +[ + 164.1657, + 204.3247, +], +[ + 83.8403, + 204.1908, +], +[ + 316.7557, + 337.7973, +], +[ + 354.1471, + 337.8152, +], +[ + 316.7565, + 336.2973, +], +[ + 354.1479, + 336.3152, +], +[ + 354.151, + 329.8152, +], +[ + 316.7596, + 329.7973, +], +[ + 354.1502, + 331.3152, +], +[ + 316.7588, + 331.2973, +], +[ + 437.3397, + 524.84, +], +[ + 508.6409, + 608.6659, +], +[ + 514.1191, + 614.9997, +], +[ + 520.9218, + 622.3879, +], +[ + 546.8271, + 647.835, +], +[ + 438.4823, + 523.8682, +], +[ + 509.7757, + 607.6851, +], +[ + 515.2407, + 614.0035, +], +[ + 521.999, + 621.3433, +], +[ + 547.8783, + 646.765, +], +[ + 84.1234, + 71.1952, +], +[ + 125.1049, + 70.9264, +], +[ + 165.1822, + 71.108, +], +[ + 84.1136, + 69.6952, +], +[ + 125.1019, + 69.4264, +], +[ + 165.189, + 69.608, +], +[ + 261.0228, + 215.9799, +], +[ + 261.016, + 216.4065, +], +[ + 256.7087, + 325.1642, +], +[ + 256.81, + 328.3721, +], +[ + 262.5226, + 216.0037, +], +[ + 262.5156, + 216.4475, +], +[ + 258.2095, + 325.1706, +], +[ + 258.3092, + 328.3247, +], +[ + 274.146, + 203.0021, +], +[ + 274.5456, + 70.8361, +], +[ + 274.5469, + 70.7893, +], +[ + 272.646, + 202.9975, +], +[ + 273.0456, + 70.8127, +], +[ + 273.0475, + 70.7467, +], +[ + 354.1515, + 337.8155, +], +[ + 353.9323, + 407.1661, +], +[ + 355.6515, + 337.8203, +], +[ + 355.4323, + 407.1709, +], +[ + 624.8958, + 735.2634, +], +[ + 623.9627, + 744.2188, +], +[ + 627.0028, + 777.5537, +], +[ + 630.2234, + 786.5502, +], +[ + 640.0327, + 799.723, +], +[ + 647.9854, + 810.4432, +], +[ + 650.124, + 814.1256, +], +[ + 650.1925, + 819.2373, +], +[ + 649.5971, + 824.042, +], +[ + 647.5215, + 828.2082, +], +[ + 618.4205, + 860.1697, +], +[ + 626.3878, + 735.4188, +], +[ + 625.4699, + 744.2288, +], +[ + 628.4792, + 777.2277, +], +[ + 631.5602, + 785.8342, +], +[ + 641.2799, + 798.8864, +], +[ + 649.2408, + 809.6178, +], +[ + 651.6186, + 813.712, +], +[ + 651.6937, + 819.3203, +], +[ + 651.0541, + 824.481, +], +[ + 648.7709, + 829.064, +], +[ + 619.5297, + 861.1795, +], +[ + 353.7767, + 214.903, +], +[ + 354.1511, + 329.815, +], +[ + 355.2767, + 214.8982, +], +[ + 355.6511, + 329.8102, +], +[ + 220.3226, + 475.1571, +], +[ + 219.5898, + 438.4366, +], +[ + 219.8226, + 475.1671, +], +[ + 219.0898, + 438.4466, +], +[ + 316.7901, + 203.0799, +], +[ + 317.2541, + 71.6574, +], +[ + 317.3045, + 70.9114, +], +[ + 316.2901, + 203.0781, +], +[ + 316.7541, + 71.6406, +], +[ + 316.8057, + 70.8776, +], +[ + 617.1375, + 861.5789, +], +[ + 613.6399, + 857.9543, +], +[ + 606.8476, + 845.9444, +], +[ + 595.6562, + 822.2671, +], +[ + 588.3771, + 804.476, +], +[ + 576.3548, + 784.8614, +], +[ + 558.5879, + 765.8787, +], +[ + 542.6285, + 755.414, +], +[ + 508.7574, + 740.2886, +], +[ + 498.9971, + 734.4122, +], +[ + 494.7657, + 729.2162, +], +[ + 491.3456, + 721.6271, +], +[ + 485.1777, + 694.0382, +], +[ + 478.8951, + 668.4996, +], +[ + 471.8929, + 647.3199, +], +[ + 465.2145, + 637.8997, +], +[ + 457.7568, + 632.3735, +], +[ + 436.3539, + 625.1754, +], +[ + 411.265, + 616.4661, +], +[ + 388.4692, + 610.0081, +], +[ + 616.0581, + 862.6205, +], +[ + 612.4283, + 858.8589, +], +[ + 605.5142, + 846.6336, +], +[ + 594.2842, + 822.8745, +], +[ + 587.0349, + 805.1562, +], +[ + 575.156, + 785.7756, +], +[ + 557.6155, + 767.0349, +], +[ + 541.9061, + 756.7342, +], +[ + 508.0618, + 741.6208, +], +[ + 497.9991, + 735.5622, +], +[ + 493.4787, + 730.0112, +], +[ + 489.9154, + 722.1045, +], +[ + 483.7187, + 694.3866, +], +[ + 477.4523, + 668.9142, +], +[ + 470.5393, + 648.0041, +], +[ + 464.1293, + 638.9625, +], +[ + 457.0544, + 633.7199, +], +[ + 435.8765, + 626.5974, +], +[ + 410.8142, + 617.8973, +], +[ + 388.0604, + 611.4513, +], +[ + 312.7588, + 469.0723, +], +[ + 316.1524, + 342.1121, +], +[ + 316.1743, + 340.3794, +], +[ + 312.259, + 469.0589, +], +[ + 315.6524, + 342.1067, +], +[ + 315.6743, + 340.373, +], +[ + 732.0548, + 819.233, +], +[ + 799.6805, + 865.2501, +], +[ + 732.8986, + 817.9928, +], +[ + 800.5243, + 864.0099, +], +[ + 262.5608, + 480.9326, +], +[ + 264.0799, + 479.796, +], +[ + 267.3302, + 475.6276, +], +[ + 268.871, + 472.3259, +], +[ + 269.566, + 469.8953, +], +[ + 270.0344, + 466.8835, +], +[ + 270.3872, + 445.2889, +], +[ + 270.2747, + 341.9066, +], +[ + 270.2415, + 340.9715, +], +[ + 261.6622, + 479.7316, +], +[ + 263.0205, + 478.7152, +], +[ + 266.0428, + 474.8394, +], +[ + 267.4614, + 471.7995, +], +[ + 268.0982, + 469.5725, +], +[ + 268.5362, + 466.7555, +], +[ + 268.8872, + 445.2775, +], +[ + 268.7747, + 341.9324, +], +[ + 268.7425, + 341.0247, +], +[ + 353.648, + 71.8448, +], +[ + 353.8328, + 72.4599, +], +[ + 353.7553, + 204.3708, +], +[ + 355.0846, + 71.4132, +], +[ + 355.333, + 72.2397, +], +[ + 355.2553, + 204.3716, +], +[ + 178.1933, + 69.7939, +], +[ + 220.4322, + 69.1769, +], +[ + 260.1394, + 70.129, +], +[ + 261.5583, + 70.2013, +], +[ + 178.1713, + 68.2941, +], +[ + 220.441, + 67.6767, +], +[ + 260.1924, + 68.6298, +], +[ + 261.6347, + 68.7033, +], +[ + 316.3272, + 327.3681, +], +[ + 316.3476, + 325.4825, +], +[ + 316.7437, + 216.0802, +], +[ + 315.8272, + 327.3627, +], +[ + 315.8476, + 325.4753, +], +[ + 316.2437, + 216.0784, +], +[ + 274.5472, + 70.7864, +], +[ + 313.1936, + 70.6419, +], +[ + 274.5416, + 69.2864, +], +[ + 313.188, + 69.1419, +], +[ + 312.7437, + 216.0657, +], +[ + 312.3476, + 325.4525, +], +[ + 312.3274, + 327.3248, +], +[ + 313.2437, + 216.0675, +], +[ + 312.8476, + 325.4597, +], +[ + 312.8274, + 327.3302, +], +[ + 312.2779, + 203.065, +], +[ + 274.1458, + 203.002, +], +[ + 312.2755, + 204.565, +], +[ + 274.1434, + 204.502, +], +[ + 799.173, + 873.4086, +], +[ + 712.3232, + 873.2456, +], +[ + 799.1702, + 874.9086, +], +[ + 712.3204, + 874.7456, +], +[ + 257.2497, + 341.4322, +], +[ + 257.2749, + 342.1429, +], +[ + 257.3871, + 445.1881, +], +[ + 257.0507, + 465.7737, +], +[ + 256.8446, + 467.0989, +], +[ + 256.6552, + 467.7614, +], +[ + 256.1726, + 468.7956, +], +[ + 254.8984, + 470.4297, +], +[ + 254.7729, + 470.5236, +], +[ + 258.7487, + 341.379, +], +[ + 258.7749, + 342.1171, +], +[ + 258.8871, + 445.1995, +], +[ + 258.5489, + 465.9021, +], +[ + 258.3126, + 467.4213, +], +[ + 258.065, + 468.2872, +], +[ + 257.4598, + 469.5842, +], +[ + 255.9576, + 471.5107, +], +[ + 255.6713, + 471.7248, +], +] \ No newline at end of file diff --git a/geo/src/algorithm/test_fixtures/abstreet_2.rs b/geo/src/algorithm/test_fixtures/abstreet_2.rs new file mode 100644 index 000000000..026c3b24e --- /dev/null +++ b/geo/src/algorithm/test_fixtures/abstreet_2.rs @@ -0,0 +1,1426 @@ +vec![ +[ + 215.5905, + 438.5164, +], +[ + 216.3233, + 475.2369, +], +[ + 216.0905, + 438.5064, +], +[ + 216.8233, + 475.2269, +], +[ + 269.8035, + 327.9618, +], +[ + 269.7168, + 325.2165, +], +[ + 274.0119, + 216.7688, +], +[ + 274.0211, + 216.1869, +], +[ + 268.3043, + 328.0092, +], +[ + 268.216, + 325.2101, +], +[ + 272.5123, + 216.7278, +], +[ + 272.5213, + 216.1631, +], +[ + 220.3226, + 475.1571, +], +[ + 219.5898, + 438.4366, +], +[ + 219.8226, + 475.1671, +], +[ + 219.0898, + 438.4466, +], +[ + 316.3272, + 327.3681, +], +[ + 316.3476, + 325.4825, +], +[ + 316.7437, + 216.0802, +], +[ + 315.8272, + 327.3627, +], +[ + 315.8476, + 325.4753, +], +[ + 316.2437, + 216.0784, +], +[ + 624.8958, + 735.2634, +], +[ + 623.9627, + 744.2188, +], +[ + 627.0028, + 777.5537, +], +[ + 630.2234, + 786.5502, +], +[ + 640.0327, + 799.723, +], +[ + 647.9854, + 810.4432, +], +[ + 650.124, + 814.1256, +], +[ + 650.1925, + 819.2373, +], +[ + 649.5971, + 824.042, +], +[ + 647.5215, + 828.2082, +], +[ + 618.4205, + 860.1697, +], +[ + 626.3878, + 735.4188, +], +[ + 625.4699, + 744.2288, +], +[ + 628.4792, + 777.2277, +], +[ + 631.5602, + 785.8342, +], +[ + 641.2799, + 798.8864, +], +[ + 649.2408, + 809.6178, +], +[ + 651.6186, + 813.712, +], +[ + 651.6937, + 819.3203, +], +[ + 651.0541, + 824.481, +], +[ + 648.7709, + 829.064, +], +[ + 619.5297, + 861.1795, +], +[ + 262.5608, + 480.9326, +], +[ + 264.0799, + 479.796, +], +[ + 267.3302, + 475.6276, +], +[ + 268.871, + 472.3259, +], +[ + 269.566, + 469.8953, +], +[ + 270.0344, + 466.8835, +], +[ + 270.3872, + 445.2889, +], +[ + 270.2747, + 341.9066, +], +[ + 270.2415, + 340.9715, +], +[ + 261.6622, + 479.7316, +], +[ + 263.0205, + 478.7152, +], +[ + 266.0428, + 474.8394, +], +[ + 267.4614, + 471.7995, +], +[ + 268.0982, + 469.5725, +], +[ + 268.5362, + 466.7555, +], +[ + 268.8872, + 445.2775, +], +[ + 268.7747, + 341.9324, +], +[ + 268.7425, + 341.0247, +], +[ + 343.1756, + 469.9667, +], +[ + 336.2105, + 469.7293, +], +[ + 313.2669, + 469.0866, +], +[ + 343.1246, + 471.4659, +], +[ + 336.1509, + 471.2283, +], +[ + 313.2249, + 470.586, +], +[ + 316.7901, + 203.0799, +], +[ + 317.2541, + 71.6574, +], +[ + 317.3045, + 70.9114, +], +[ + 316.2901, + 203.0781, +], +[ + 316.7541, + 71.6406, +], +[ + 316.8057, + 70.8776, +], +[ + 707.3371, + 873.2309, +], +[ + 649.1472, + 872.9969, +], +[ + 638.713, + 872.5759, +], +[ + 630.7296, + 870.367, +], +[ + 628.0327, + 868.9217, +], +[ + 707.3311, + 874.7309, +], +[ + 649.1138, + 874.4967, +], +[ + 638.4802, + 874.0677, +], +[ + 630.1676, + 871.7678, +], +[ + 627.3241, + 870.2439, +], +[ + 164.1683, + 202.8247, +], +[ + 83.8429, + 202.6908, +], +[ + 164.1657, + 204.3247, +], +[ + 83.8403, + 204.1908, +], +[ + 257.2497, + 341.4322, +], +[ + 257.2749, + 342.1429, +], +[ + 257.3871, + 445.1881, +], +[ + 257.0507, + 465.7737, +], +[ + 256.8446, + 467.0989, +], +[ + 256.6552, + 467.7614, +], +[ + 256.1726, + 468.7956, +], +[ + 254.8984, + 470.4297, +], +[ + 254.7729, + 470.5236, +], +[ + 258.7487, + 341.379, +], +[ + 258.7749, + 342.1171, +], +[ + 258.8871, + 445.1995, +], +[ + 258.5489, + 465.9021, +], +[ + 258.3126, + 467.4213, +], +[ + 258.065, + 468.2872, +], +[ + 257.4598, + 469.5842, +], +[ + 255.9576, + 471.5107, +], +[ + 255.6713, + 471.7248, +], +[ + 354.1515, + 337.8155, +], +[ + 353.9323, + 407.1661, +], +[ + 355.6515, + 337.8203, +], +[ + 355.4323, + 407.1709, +], +[ + 563.144, + 663.8594, +], +[ + 625.9143, + 725.4879, +], +[ + 564.1948, + 662.789, +], +[ + 626.9651, + 724.4175, +], +[ + 353.7767, + 214.903, +], +[ + 354.1511, + 329.815, +], +[ + 355.2767, + 214.8982, +], +[ + 355.6511, + 329.8102, +], +[ + 274.5472, + 70.7864, +], +[ + 313.1936, + 70.6419, +], +[ + 274.5416, + 69.2864, +], +[ + 313.188, + 69.1419, +], +[ + 312.2779, + 203.065, +], +[ + 274.1458, + 203.002, +], +[ + 312.2755, + 204.565, +], +[ + 274.1434, + 204.502, +], +[ + 637.8258, + 736.6103, +], +[ + 695.5893, + 789.8801, +], +[ + 638.8428, + 735.5077, +], +[ + 696.6063, + 788.7775, +], +[ + 270.2417, + 340.9711, +], +[ + 311.8576, + 340.3337, +], +[ + 270.2187, + 339.4713, +], +[ + 311.8346, + 338.8339, +], +[ + 84.1234, + 71.1952, +], +[ + 125.1049, + 70.9264, +], +[ + 165.1822, + 71.108, +], +[ + 84.1136, + 69.6952, +], +[ + 125.1019, + 69.4264, +], +[ + 165.189, + 69.608, +], +[ + 83.8099, + 202.6906, +], +[ + 84.1237, + 71.2008, +], +[ + 82.3099, + 202.687, +], +[ + 82.6237, + 71.1972, +], +[ + 316.7557, + 337.7973, +], +[ + 354.1471, + 337.8152, +], +[ + 316.7565, + 336.2973, +], +[ + 354.1479, + 336.3152, +], +[ + 732.0548, + 819.233, +], +[ + 799.6805, + 865.2501, +], +[ + 732.8986, + 817.9928, +], +[ + 800.5243, + 864.0099, +], +[ + 353.648, + 71.8448, +], +[ + 353.8328, + 72.4599, +], +[ + 353.7553, + 204.3708, +], +[ + 355.0846, + 71.4132, +], +[ + 355.333, + 72.2397, +], +[ + 355.2553, + 204.3716, +], +[ + 261.0228, + 215.9799, +], +[ + 261.016, + 216.4065, +], +[ + 256.7087, + 325.1642, +], +[ + 256.81, + 328.3721, +], +[ + 262.5226, + 216.0037, +], +[ + 262.5156, + 216.4475, +], +[ + 258.2095, + 325.1706, +], +[ + 258.3092, + 328.3247, +], +[ + 547.6954, + 716.9522, +], +[ + 552.4613, + 699.6381, +], +[ + 562.4803, + 666.4294, +], +[ + 563.1442, + 663.8592, +], +[ + 546.2492, + 716.5542, +], +[ + 551.0195, + 699.2243, +], +[ + 561.0345, + 666.0288, +], +[ + 561.6918, + 663.484, +], +[ + 274.146, + 203.0021, +], +[ + 274.5456, + 70.8361, +], +[ + 274.5469, + 70.7893, +], +[ + 272.646, + 202.9975, +], +[ + 273.0456, + 70.8127, +], +[ + 273.0475, + 70.7467, +], +[ + 707.0279, + 803.5905, +], +[ + 702.1173, + 842.6812, +], +[ + 708.8898, + 854.8128, +], +[ + 708.0983, + 873.0719, +], +[ + 707.5241, + 803.6529, +], +[ + 702.6339, + 842.5808, +], +[ + 709.3956, + 854.6928, +], +[ + 708.5979, + 873.0935, +], +[ + 628.033, + 868.9218, +], +[ + 658.3511, + 835.6235, +], +[ + 662.2248, + 827.8482, +], +[ + 663.2032, + 819.9531, +], +[ + 663.0772, + 810.5437, +], +[ + 658.861, + 803.284, +], +[ + 650.487, + 791.9958, +], +[ + 641.8089, + 780.3422, +], +[ + 639.799, + 774.7277, +], +[ + 637.0244, + 744.3027, +], +[ + 637.8258, + 736.6106, +], +[ + 626.9238, + 867.912, +], +[ + 657.1017, + 834.7677, +], +[ + 660.7678, + 827.409, +], +[ + 661.702, + 819.8703, +], +[ + 661.5826, + 810.9573, +], +[ + 657.6056, + 804.1094, +], +[ + 649.24, + 792.8324, +], +[ + 640.4721, + 781.0582, +], +[ + 638.3226, + 775.0537, +], +[ + 635.5172, + 744.2927, +], +[ + 636.3338, + 736.4552, +], +[ + 178.1933, + 69.7939, +], +[ + 220.4322, + 69.1769, +], +[ + 260.1394, + 70.129, +], +[ + 261.5583, + 70.2013, +], +[ + 178.1713, + 68.2941, +], +[ + 220.441, + 67.6767, +], +[ + 260.1924, + 68.6298, +], +[ + 261.6347, + 68.7033, +], +[ + 617.1375, + 861.5789, +], +[ + 613.6399, + 857.9543, +], +[ + 606.8476, + 845.9444, +], +[ + 595.6562, + 822.2671, +], +[ + 588.3771, + 804.476, +], +[ + 576.3548, + 784.8614, +], +[ + 558.5879, + 765.8787, +], +[ + 542.6285, + 755.414, +], +[ + 508.7574, + 740.2886, +], +[ + 498.9971, + 734.4122, +], +[ + 494.7657, + 729.2162, +], +[ + 491.3456, + 721.6271, +], +[ + 485.1777, + 694.0382, +], +[ + 478.8951, + 668.4996, +], +[ + 471.8929, + 647.3199, +], +[ + 465.2145, + 637.8997, +], +[ + 457.7568, + 632.3735, +], +[ + 436.3539, + 625.1754, +], +[ + 411.265, + 616.4661, +], +[ + 388.4692, + 610.0081, +], +[ + 616.0581, + 862.6205, +], +[ + 612.4283, + 858.8589, +], +[ + 605.5142, + 846.6336, +], +[ + 594.2842, + 822.8745, +], +[ + 587.0349, + 805.1562, +], +[ + 575.156, + 785.7756, +], +[ + 557.6155, + 767.0349, +], +[ + 541.9061, + 756.7342, +], +[ + 508.0618, + 741.6208, +], +[ + 497.9991, + 735.5622, +], +[ + 493.4787, + 730.0112, +], +[ + 489.9154, + 722.1045, +], +[ + 483.7187, + 694.3866, +], +[ + 477.4523, + 668.9142, +], +[ + 470.5393, + 648.0041, +], +[ + 464.1293, + 638.9625, +], +[ + 457.0544, + 633.7199, +], +[ + 435.8765, + 626.5974, +], +[ + 410.8142, + 617.8973, +], +[ + 388.0604, + 611.4513, +], +[ + 318.2391, + 69.3411, +], +[ + 350.2804, + 68.8164, +], +[ + 318.2145, + 67.8413, +], +[ + 350.2558, + 67.3166, +], +[ + 211.4208, + 471.4657, +], +[ + 175.5745, + 471.6069, +], +[ + 211.4268, + 472.9657, +], +[ + 175.5805, + 473.1069, +], +[ + 261.0435, + 202.9806, +], +[ + 177.2094, + 202.846, +], +[ + 261.0411, + 204.4806, +], +[ + 177.207, + 204.346, +], +[ + 165.1824, + 71.1081, +], +[ + 164.1619, + 200.9437, +], +[ + 164.1687, + 202.8248, +], +[ + 166.6824, + 71.1199, +], +[ + 165.6619, + 200.9501, +], +[ + 165.6687, + 202.8194, +], +[ + 353.7563, + 205.6358, +], +[ + 317.274, + 205.5734, +], +[ + 353.7537, + 207.1358, +], +[ + 317.2714, + 207.0734, +], +[ + 177.1686, + 202.778, +], +[ + 177.1621, + 200.9729, +], +[ + 178.182, + 71.2103, +], +[ + 175.6686, + 202.7834, +], +[ + 175.6621, + 200.9665, +], +[ + 176.682, + 71.1985, +], +[ + 312.7588, + 469.0723, +], +[ + 316.1524, + 342.1121, +], +[ + 316.1743, + 340.3794, +], +[ + 312.259, + 469.0589, +], +[ + 315.6524, + 342.1067, +], +[ + 315.6743, + 340.373, +], +[ + 313.3136, + 70.6417, +], +[ + 313.2545, + 71.5157, +], +[ + 312.7901, + 203.0658, +], +[ + 313.8124, + 70.6755, +], +[ + 313.7545, + 71.5325, +], +[ + 313.2901, + 203.0676, +], +[ + 177.1821, + 329.2372, +], +[ + 177.132, + 326.0518, +], +[ + 177.1886, + 215.846, +], +[ + 175.6823, + 329.2608, +], +[ + 175.632, + 326.0624, +], +[ + 175.6886, + 215.8452, +], +[ + 799.173, + 873.4086, +], +[ + 712.3232, + 873.2456, +], +[ + 799.1702, + 874.9086, +], +[ + 712.3204, + 874.7456, +], +[ + 312.1746, + 340.3288, +], +[ + 312.1531, + 342.0328, +], +[ + 308.7602, + 468.9654, +], +[ + 312.6746, + 340.3352, +], +[ + 312.6531, + 342.0382, +], +[ + 309.26, + 468.9788, +], +[ + 437.3397, + 524.84, +], +[ + 508.6409, + 608.6659, +], +[ + 514.1191, + 614.9997, +], +[ + 520.9218, + 622.3879, +], +[ + 546.8271, + 647.835, +], +[ + 438.4823, + 523.8682, +], +[ + 509.7757, + 607.6851, +], +[ + 515.2407, + 614.0035, +], +[ + 521.999, + 621.3433, +], +[ + 547.8783, + 646.765, +], +[ + 177.1885, + 215.846, +], +[ + 261.0226, + 215.9806, +], +[ + 177.1909, + 214.346, +], +[ + 261.025, + 214.4806, +], +[ + 354.151, + 329.8152, +], +[ + 316.7596, + 329.7973, +], +[ + 354.1502, + 331.3152, +], +[ + 316.7588, + 331.2973, +], +[ + 550.5573, + 660.608, +], +[ + 549.9587, + 662.9255, +], +[ + 539.9698, + 696.0345, +], +[ + 535.1616, + 713.5021, +], +[ + 552.0097, + 660.9832, +], +[ + 551.4045, + 663.3261, +], +[ + 541.4116, + 696.4483, +], +[ + 536.6078, + 713.9001, +], +[ + 312.7437, + 216.0657, +], +[ + 312.3476, + 325.4525, +], +[ + 312.3274, + 327.3248, +], +[ + 313.2437, + 216.0675, +], +[ + 312.8476, + 325.4597, +], +[ + 312.8274, + 327.3302, +], +[ + 261.5519, + 70.4288, +], +[ + 261.5462, + 70.6346, +], +[ + 261.1461, + 202.9628, +], +[ + 263.0513, + 70.4702, +], +[ + 263.0462, + 70.656, +], +[ + 262.6461, + 202.9674, +], +[ + 178.0391, + 465.5375, +], +[ + 177.3275, + 342.6733, +], +[ + 176.5391, + 465.5461, +], +[ + 175.8275, + 342.6819, +], +] \ No newline at end of file