From 7aa1945105285b38db4f4ffe7a4d3dfc6a7c9fe0 Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Wed, 4 Dec 2024 21:08:52 -0800 Subject: [PATCH] just use convex hull from now on --- src/maple/gtfs_handlers/hull_from_gtfs.rs | 53 +---------------------- src/maple_syrup/README.md | 8 +++- src/maple_syrup/mod.rs | 13 +++++- 3 files changed, 21 insertions(+), 53 deletions(-) diff --git a/src/maple/gtfs_handlers/hull_from_gtfs.rs b/src/maple/gtfs_handlers/hull_from_gtfs.rs index d1b0bed2..df7355eb 100644 --- a/src/maple/gtfs_handlers/hull_from_gtfs.rs +++ b/src/maple/gtfs_handlers/hull_from_gtfs.rs @@ -73,58 +73,9 @@ pub fn hull_from_gtfs(gtfs: >fs_structures::Gtfs) -> Option { //convert concave hull back into multipoint - //let concave_hull_points = concave_hull.exterior().points().collect::>(); + let concave_hull_points = concave_hull.exterior().points().collect::>(); - //let mut longest_side = longest_side_length_metres(&buffered_convex_hull); - - //while the convex hull is still long or too simple, try to shrink it - - /*while !(longest_side.length < 80000.0 || concave_hull_points.0.len() > 30) { - - //find the midpoint of the longest side - - let midpoint = buffered_convex_hull.exterior().points_iter().nth(longest_side.starting_index).unwrap().midpoint( - &buffered_convex_hull.exterior().points_iter().nth(longest_side.ending_index).unwrap() - ); - - //find the closest point on the concave hull to the midpoint - - let closest_point = concave_hull_points.0.iter().min_by_key(|point| point.haversine_distance(&midpoint)).unwrap(); - - //if the vector of convex hull coordinates contains the closest point coordinate , then we can't shrink it any further - - let closest_point_is_on_convex_hull = buffered_convex_hull.exterior().points_iter().any(|point| point == closest_point); - - if closest_point_is_on_convex_hull { - break; - } - - //if the closest point is within 5km of the midpoint, - - //recompute longest side of the polygon - longest_side = longest_side_length_metres(&buffered_convex_hull); - }*/ - - //let buffer_concave_hull = buffer_geo_polygon(concave_hull, buffer_distance); - - let buffer_amount_bad_degs = match bus_only { - true => 0.05, - false => match contains_metro_and_bus_only { - true => 0.05, - false => 0.02, - }, - }; - - - let buffer_concave_hull = buffer_polygon(&concave_hull, buffer_amount_bad_degs); - - let buffer_concave_exterior = buffer_concave_hull.rings().next().unwrap().clone(); - - //convert to polygon - - let polygon_concave = geo::Polygon::new(buffer_concave_exterior, vec![]); - - Some(polygon_concave) + Some(buffered_convex_hull) } struct PolygonSide { diff --git a/src/maple_syrup/README.md b/src/maple_syrup/README.md index 2264d6d8..7a36f42a 100644 --- a/src/maple_syrup/README.md +++ b/src/maple_syrup/README.md @@ -14,4 +14,10 @@ We can answer a direct-connection query of A@t -> B by looking at all itinerarie Remember that trip ids must be filtered by service ids that use the day of the query. -Those resulting times can then be compared to return the cost of A@t -> B. \ No newline at end of file +Those resulting times can then be compared to return the cost of A@t -> B. + +### Testing + +```bash +cargo test maple_syrup::tests::irvine_interpolation_test +``` \ No newline at end of file diff --git a/src/maple_syrup/mod.rs b/src/maple_syrup/mod.rs index 80c30a69..86b23946 100644 --- a/src/maple_syrup/mod.rs +++ b/src/maple_syrup/mod.rs @@ -401,4 +401,15 @@ fn calculate_direction_pattern_id(route_id: &str, stop_sequence: Vec