Map readability issue due to label collisions between layers
Hello! Although this project is definitely the best way to visualize OSM indoor map data, I find that for map data with odd shapes or gaps in them, the display can get quite cluttered by labels from base layers which overlap with the indoor geometry. Although those labels are underneath the indoor map, and they don't collide with labels on the indoor symbol layer, it still adds noise that makes comprehending the map more difficult. Some examples:
Obviously maplibre's label placement only takes other labels into account and not geometry, which means that any part of a room that is not covered by a symbol is at risk of having this clutter at its edges.
I'm wondering if there would be a way to make the labels of a specific layer avoid the geometry of another layer.
I've done a bit of research and found that while the symbol collision detection system doesn't support arbitrary geometry, it's possible to work around this by adding invisible symbols to the map that approximate the shape of the geometry.
This might sound like a hack, but given that the system only supports rectangles and circles, this is exactly how the original implementer proposes supporting arbitrary geometry:
Using multiple circles allows us to approximate arbitrary line geometries (and in fact there are outstanding feature requests that would require us to support other arbitrary collision geometries such as “don’t let labels get drawn over this lake” — we would probably implement support by converting those geometries into circles first).
Hi @varette Sorry for the delay! This problem is quite tricky indeed. Not sure how your hack could solve the issue. Maybe displaying the indoor=level geometry may solve this. I need to take a look.
Nothing to worry about, I'm just thinking about ways to improve the map out of personal interest, since I'd love to see indoor maps become a standard feature in OSM apps.
You're right that my solution wouldn't help, so I've had a different idea. We can use a filter layer and the "within" statement to filter out POIs within an arbitrary feature collection's geometry. So if we build a polygon that bounds the indoor geometry plus some buffer, then we can use it to filter out most of the POIs which are overlapping the indoor layer.
I've implement a prototype of this (source), and it seems like it could work. It's a rough experiment, there's probably a much more efficient way to build a bounding polygon. Right now I build the filtering polygons by running the level's geometry through turf's "buffer", "simplify, then "union".
Here's a comparison:
And a large view to show the surroundings