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

"Flooded" map #32

Open
nlehuby opened this issue Dec 17, 2019 · 7 comments
Open

"Flooded" map #32

nlehuby opened this issue Dec 17, 2019 · 7 comments
Projects

Comments

@nlehuby
Copy link

nlehuby commented Dec 17, 2019

I've built my own map for this region in OSM: https://www.openstreetmap.org/#map=14/5.3248/-4.0158

But the resulting map in A/B Street looks like the whole neighborhood is under water 😆

image

image

It seems only cosmetic, I couldn't see any impact on the traffic simulation.

@dabreegster
Copy link
Collaborator

Guess it's a flood simulator now. >_< Turning clipped OSM data into water polygons is a bit hard. https://github.com/dabreegster/abstreet/blob/9aa4fda837ab813fd2e6d7e4381208ee03ab55c2/convert_osm/src/osm_reader.rs#L347 is the relevant code. This roughly follows https://wiki.openstreetmap.org/wiki/Relation:multipolygon/Algorithm, then tries to deal with disconnected ends by finding a spot where the half-formed ring intersects the boundary polygon, and tracing along it.

I think the problem here is that when tracing along the boundary polygon, little bits of land reappear, and the code doesn't deal with that case yet. I don't know if I'll be able to look at this soon, but if you want to try to tackle it, run with --dev and then enter debug mode with control+D. You can select the water polygons and press x or F2 to look at the points and triangles.

@dabreegster dabreegster added this to To do in More cities May 3, 2020
@dabreegster
Copy link
Collaborator

I happened to hit this problem in Manhattan and found a possible workaround -- flip the order at https://github.com/dabreegster/abstreet/blob/41e80b48a16c624eda533de21131f2b8fb947407/geom/src/ring.rs#L94 to get the inverse polygon. Always picking the shorter connection doesn't make sense. There might be a way to decide automatically whether to pick the shorter or longer connection.

@dabreegster
Copy link
Collaborator

Stumbled across https://github.com/QwantResearch/osm_boundaries_utils_rs/blob/master/src/boundaries.rs, which could be the start to something more robust

@matkoniecz
Copy link
Contributor

I had similar issues - maybe process water area data by some external software such as mapshaper and load already clipped water polygons? ( https://github.com/mbloch/mapshaper )

@dabreegster
Copy link
Collaborator

I had looked around a while ago for existing water polygons and didn't find much. I missed mapshaper; I'll see if it could be an easier option. Thanks!

@dabreegster
Copy link
Collaborator

Another case that we need to handle is gluing two pieces of coastline together that're expressed in different ways. In Lisbon we have a natural=coastline way (https://www.openstreetmap.org/way/975228400) that ends right where a natural=water, type=multipolygon (https://www.openstreetmap.org/relation/2805665) begins:
Screenshot from 2021-11-19 10-13-31
Screenshot from 2021-11-19 10-13-28

But maybe not... I also see another section of natural=coastline that seems connected: https://www.openstreetmap.org/way/692883618. And it seems to keep going. Need to dig into glue_multipolygon to see what's happening here. The multipolygon is a red herring maybe.

@Darellur
Copy link

Darellur commented Jun 21, 2022

From https://wiki.openstreetmap.org/wiki/Tag:natural%3Dcoastline
"The direction the ways are drawn is very important! They must be drawn so that the land is on the left side and water on the right side"
Has this been considered?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
More cities
  
To do
Development

No branches or pull requests

4 participants