StrandedKitty / streets-gl

🗺 OpenStreetMap 3D renderer powered by WebGL2
http://streets.gl
MIT License
632 stars 48 forks source link

Straight skeleton algorithm fails on complex building footprints #1

Closed StrandedKitty closed 12 months ago

StrandedKitty commented 1 year ago

To generate geometry for hipped and similar roof shapes in runtime this project uses a straight skeleton algorithm implementation ported from reinterpretcat's C# implementation: https://github.com/StrandedKitty/straight-skeleton

It seems like the algorithm tends to fail on buildings with a lot of right angles and holes. Basically, there are three types of failures:

  1. Straight skeleton code throws an error.
  2. The resulting geometry falls way out of the roof footprint.
  3. A part of the roof is missing.
Example of a hipped roof with a missing part

To temporarily fix this problem I've implemented a fallback to the flat roof shape, but it only works for the first two cases which are easily detactable.

Though I don't know if looking into this is worth the effort.

Beakerboy commented 1 year ago

I would love to work with you on this issue. I have some custom three-js geometries that render a few different roof shapes given their outlines:

https://github.com/Beakerboy/Threejs-Geometries

A hipped roof is next on my list. I’ll review your straight skeleton implementation and see what I can figure out.

StrandedKitty commented 1 year ago

@Beakerboy Good luck! My hipped roof implementation is located in HippedRoofBuilder.ts, you can take a look at it. Overall, there's nothing complicated, it's pretty easy to render a hipped roof once you have a straight skeleton generated.

kayD commented 1 year ago

Just for adding another example: https://streets.gl/#53.55148,10.00444,45.00,0.00,473.43

StrandedKitty commented 12 months ago

I've switched to a much more robust CGAL straight skeleton implementation that works much better with complex OSM polygons. See updated https://github.com/StrandedKitty/straight-skeleton for details.

kayD commented 10 months ago

Works really well for most situations, nice overall improvement! Example: https://streets.gl/#49.79288,9.93804,45.00,119.17,387.58

Thank you for that elaborate fix.