Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reusable OSM boundary logic #475

Open
msbarry opened this issue Feb 6, 2023 · 4 comments
Open

Reusable OSM boundary logic #475

msbarry opened this issue Feb 6, 2023 · 4 comments

Comments

@msbarry
Copy link
Contributor

msbarry commented Feb 6, 2023

Boundary handling in planetiler-openmaptiles is a mess and too slow to generalize to adding left/right labels for states, counties, towns, etc., I'd like to improve it with some built-in functionality in planetiler so that pt-omt just has to opt-into using that instead of implementing the boundary collection manually. If you squint your eyes, you basically have a bunch of segments that are shared between region polygons and you want a flow something like this:

  • collect all segments that are part of boundary relations
  • create polygons from segments for each region
  • use each polygon to label the region on one side of each of its boundary segments
  • then decide to emit each border segment with a min zoom based on the min admin level of a region it's a part of, but also take into account the size of the region, to avoid emitting borders for tiny regions at low zooms.

Alternatively you might always want to emit every state border in a particular country, so you might make a decision based on the size of the country and number of regions it's divided into...? We might want to dig into how https://github.com/nvkelso/natural-earth-vector handles this and try to match it's logic.

Originally posted by @msbarry in openmaptiles/planetiler-openmaptiles#67 (comment)

@msbarry
Copy link
Contributor Author

msbarry commented Feb 6, 2023

cc/ @ZeLonewolf

@ZeLonewolf
Copy link
Contributor

ZeLonewolf commented Feb 6, 2023

By rights, each boundary line should have all of it's left/right areas encoded, at all admin levels, or at the very least the most important one. I've thought about how to do this in classic OpenMapTiles but the SQL approach makes this way too complicated. The issue is that the left/right check is too hard.

@msbarry
Copy link
Contributor Author

msbarry commented Feb 6, 2023

I feel like the left/right check should be simpler if you assemble each region polygon from the ways along the edge, check if the winding is clockwise or conter-clockwise, then assign the region's label to each way along the edge as left or right depending on whether it was reversed or not. The current approach of creating a fake point a few meters to the left or right of the polygon seems like a brittle hack IMO.

@ZeLonewolf
Copy link
Contributor

Very very hacky, and I envisioned the same approach but I couldn't figure out how to determine the winding in pure Imposm+SQL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants