Nate-Wessel / bike-map

OSM-based map with bike-specific visual hierarchies
Other
9 stars 0 forks source link

Merge/Simplify split ways #11

Open Nate-Wessel opened 4 years ago

Nate-Wessel commented 4 years ago

OSM data for Toronto has hundreds of split ways representing larger streets where they are divided by traffic islands: Screenshot_2020-01-14_11-46-25

This is usually done to help with car routing, but they are ugly and inappropriate at the scale of this map. They should somehow be merged/simplified into a single way. Some of this can be done directly in OSM where appropriate, but most of the changes will need to be made algorithmically while processing the data.

Split ways can be detected as oneway pairs having the same name, especially if they connect at a shared node to a two-way with the same common name.

There may also be cases where it would be innapropiate to merge ways, such as some parts of Spadina, Queensway, University, etc. We would need to specify some sort of distance threshold past which merging wouldn't happen. We wouldn't want to eliminate the Spadina Crescent or Queens Park!

Nate-Wessel commented 4 years ago

See also: https://gist.github.com/Nate-Wessel/e7d72da7c7c12e00a472b41537334f8d A slow overpass query for helping to detect split ways

Nate-Wessel commented 11 months ago

It seems like some sort of force-based (e.g. D3-force) algorithm could work here.

  1. identify / isolate the split ways
  2. apply inverse square (gravity) force to pull nodes on opposite ways together, perhaps interpolating/adding nodes
  3. apply force (linear???) to pull nodes back toward their given positions
  4. apply tension to line, so nodes pulling together can pull in nodes that would otherwise stay putt
  5. construct single line from collapsed edges

Where very close, lines should essentially snap together. Where very far apart (e.g. Spadina Crescent) they should stay at their original positions. Edge cases like the approach to that crescent should have a smooth transition between merged and split.

See interactive JS demo: https://observablehq.com/d/0f97e8cb32b46de4