Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PolyLine shifting can crash #860

Closed
dabreegster opened this issue Feb 17, 2022 · 5 comments
Closed

PolyLine shifting can crash #860

dabreegster opened this issue Feb 17, 2022 · 5 comments

Comments

@dabreegster
Copy link
Collaborator

make_polygons(0.5m) of PolyLine { pts: [Pt2D { x: 5217.6908, y: 5241.742 }, Pt2D { x: 5217.683, y: 5241.7357 }, Pt2D { x: 5212.1705, y: 5244.2894 }], length: Distance(6.0854) } failed: Line from Pt2D { x: 5217.6908, y: 5241.742 } to Pt2D { x: 5217.683, y: 5241.7357 } too small

Camden and other maps crash for reasons I don't understand -- the road center line is OK, but when we try to shift the polyline, the result doesn't break upfront, but it later crashes when trying to make polygons.

Short-term fix is to avoid the crash and just return a circle instead of a thickened polyline:
Screenshot from 2022-02-17 14-18-00

Actual fix is to make polyline shifting correct and robust. I never meant for my horrible math to last this long; I really want to investigate https://github.com/jbuckmccready/cavalier_contours or something else.

@dabreegster
Copy link
Collaborator Author

Another example where a bug somewhere in this implementation is causing a mess:
Screenshot from 2022-02-23 14-33-38
It's actually fine in the map_editor:
Screenshot from 2022-02-23 14-34-11
(So maybe this is the problem with trimming center points from both ends?)

It looks fine in OSM, https://www.openstreetmap.org/node/282416719#map=19/51.46319/-2.54542

@dabreegster
Copy link
Collaborator Author

trimmed_road_geometry in the map_editor is totally fine for this road, even after shifting the result. There's some difference happening elsewhere in the importer. I am baffled.

@dabreegster
Copy link
Collaborator Author

In map_editor, trimmed points are

PolyLine::new(vec![     // length 120.6564m
  Pt2D::new(2608.9265, 2146.7426),
  Pt2D::new(2726.1538, 2140.5341),    // 117.22730000000001, -6.2085000000001855 (+ 117.3916m @ Angle(356.96837717355965 degrees))
  Pt2D::new(2728.6358, 2138.9885),    // 2.481999999999971, -1.5455999999999221 (+ 2.9239m @ Angle(328.08850253534797 degrees))
  Pt2D::new(2728.7598, 2138.6709),    // 0.12399999999979627, -0.31759999999985666 (+ 0.3409m @ Angle(291.32707776309627 degrees))
])

that matches importing by the end of InitialMap. OK. Over in the final map... Road.center_pts also match. Great, so the problem is somehow in the code that calculates lanes...

@dabreegster
Copy link
Collaborator Author

Screenshot from 2022-02-23 15-55-15
Here we go! For the lanes, we first shift the center points to the left edge of the road, then gradually shift it right. That's causing the problem here -- the center points are OK, shifting them left is mostly OK but winds up with that bend. If we then shift the partly bent line, the bend explodes.

@dabreegster
Copy link
Collaborator Author

Screenshot from 2022-02-23 16-05-21
This is if we shift relative to the road center. The yellow center-line is still funky, because of get_left_side...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant