Skip to content

Commit

Permalink
Add some paranoia to polygon_from_corners. #136
Browse files Browse the repository at this point in the history
Improves one test.
  • Loading branch information
dabreegster committed Dec 16, 2022
1 parent 66494d3 commit d3fc36c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
14 changes: 14 additions & 0 deletions osm2streets/src/geometry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,20 @@ fn polygon_from_corners(
.reversed(),
)
{
// When both roads lead between the same pair of endpoints, it's possible the
// extended lines don't collide on the intersection side, but they do on the other
// side. This can happen when the current side is pre-trimmed, for example. To deal
// with this, see if the collision point is on the original polyline on the
// incorrect half.
//
// For simplicity, we use one.pl, not extended. Extending only matters on the
// correct intersection end, anyway.
if let Some((dist, _)) = one.pl.dist_along_of_point(corner) {
if dist < one.pl.length() / 2.0 {
continue;
}
}

endpts.push(corner);
}
}
Expand Down
4 changes: 0 additions & 4 deletions tests/src/leeds_cycleway/geometry.json
Original file line number Diff line number Diff line change
Expand Up @@ -21546,10 +21546,6 @@
-1.5364064393817753,
53.798401116500486
],
[
-1.5366939903492274,
53.798343284720126
],
[
-1.5364497073057675,
53.79841454607122
Expand Down

0 comments on commit d3fc36c

Please sign in to comment.