Beakerboy / OSMBuilding

render an individual OSM building
MIT License
49 stars 5 forks source link

Multipolygon building not rendering correctly #35

Closed bryceco closed 7 months ago

bryceco commented 7 months ago

I'm trying to view https://www.openstreetmap.org/relation/3067442 using https://beakerboy.github.io/OSMBuilding/index.html?type=relation&id=3067442 but the building shape is totally wrong.

Is this a bug, a defect in the OSM data, or something I'm doing wrong?

Beakerboy commented 7 months ago

It looks like it’s rendering part of the building next door instead. The fact that there is no grid beneath the building tells me some error occurred, but nothing is displaying to the error console.

Thanks for reporting this! I’ll let you know what I find.

The code will extract the gps data from a relation and then grab all the ways within the bounds of this object as a way to find any building parts. So I’m not surprised that it would pull and render the building next door as it is so close. However, it should still at least output what caused the main object to fail.

Beakerboy commented 7 months ago

The Westbank Frye looks pretty cool: https://beakerboy.github.io/OSMBuilding/index.html?id=895975965

Beakerboy commented 7 months ago

It might be because there are buildings inside the building, which are not tagged as building parts.

bryceco commented 7 months ago

The code will extract the gps data from a relation and then grab all the ways within the bounds of this object as a way to find any building parts.

I see. It's more complicated than I realized!

Beakerboy commented 7 months ago

So, yeah the issue is: a multipolygon is just a complicated “way”. If there are no parts or buildings inside of it, it will just render a generic outine. If there are buildings inside it it will render all the parts and only the parts.

the best way to do this is to use a building relation. The relation contains all parts and they are then all rendered individually. https://wiki.openstreetmap.org/wiki/Relation:building

Beakerboy commented 7 months ago

I changed the inner buildings to also have a building:type = yes and it is now rendering the inner parts. If you want the ground floor to also be rendered, you should probably just change the main outline to be the building and change the multipolygon to a part with like three floors, and change the other buildings to have 10 floors or whatever.

Beakerboy commented 7 months ago

I’ve updated OSM a little with fake data. Check the render and tweak as needed

bryceco commented 7 months ago

I see. It's not my goal to fix this particular building, it's just something I noticed while looking into https://github.com/bryceco/GoMap/issues/728

bryceco commented 7 months ago

It looks much better now!

I don't know anything about tagging conventions for building parts. Would you say that the building was tagged correctly but your code doesn't handle that situation, or that the tagging on the building was incorrect?

Beakerboy commented 7 months ago

My code follows convention as far as I know. Feel free to ask any questions and look at some of the example buildings that I link to if you want to see how to tag different building and roof shapes, colors, and materials.

Beakerboy commented 7 months ago

I didn’t know who you were I love Go Map!! I’ve used it for years!

bryceco commented 7 months ago

That's great! 😃

Beakerboy commented 7 months ago

I see you’re also a nethack fan. I’ve been playing since the ‘90s and never ascended.

bryceco commented 7 months ago

Yeah I always stop paying attention or rush too much somewhere along the way and get killed.