a-b-street / abstreet

Transportation planning and traffic simulation software for creating cities friendlier to walking, biking, and public transit
https://a-b-street.github.io/docs/
Apache License 2.0
7.74k stars 345 forks source link

Adding support for other cities #27

Closed taybin closed 4 years ago

taybin commented 4 years ago

What's involved with this? It's not just converting the OSM data right? Are locations hardcoded in somewhere? My city has terrible street traffic. I'd love to modify this to support other cities easily.

dabreegster commented 4 years ago

The short answer to get something going right now: https://github.com/dabreegster/abstreet/blob/master/docs/new_city.md

The longer answer:

https://github.com/dabreegster/abstreet/blob/master/docs/articles/map/article.md and https://docs.google.com/presentation/d/1cF7qFtjAzkXL_r62CjxBvgQnLvuQ9I2WTE2iX_5tMCY/edit?usp=sharing give a good idea of what map importing involves.

This issue is a long-term priority, but I can't drive it anytime soon (there are too many other pieces that I want to polish first). If you're interested in contributing, I will do whatever I can to help you along (except leading the effort).

dabreegster commented 4 years ago

Other random things I forgot, both easy to generalize:

taybin commented 4 years ago

Well, I grabbed my state off of open street maps and got a crude polygon for my city Then took a closer look and saw you were grabbing transit data as well. That'll take a little more research on my end to see what my area supports. In the meantime, going to see what condition the intersections and such are in first. Thanks, I'll let you know if I have more questions. Double thanks for the fast reply!

dabreegster commented 4 years ago

Most of the flags to convert_osm are optional, you don't need GTFS upfront. cargo run --release -- \ --osm=../data/input/osm/your_city.osm \ --output=../data/input/raw_maps/your_city.bin

taybin commented 4 years ago

One suggestion is to package the data under data/input by the map, so that it'd look something like data/input/seattle/osm and data/input/seattle/poly. This would create little map bundles instead of having different files for the same neighborhood in different locations.

yasomatinandana commented 4 years ago

Was trying to add a map for my local CBD (Perth, Australia) and it's throwing an error in the final 'precompute' command.

Specifically, it is saying thread 'main' panicked at 'What's turn restriction reverse?' in map_model/src/lane.rs:236:26 as well as 'dropping Timer during InitialMap to half of Map, due to panic?'

dabreegster commented 4 years ago

https://wiki.openstreetmap.org/wiki/Key:turn says 'reverse' means U-turns only. I'm not modelling U-turns properly yet; right now they get mapped to left turns usually. So sync past the above commit and try again -- that intersection with the restriction might be weird, but it should at least unblock you a bit.

yasomatinandana commented 4 years ago

Perth CBD example intersection Perth CBD intersection from ABstreet

There appears to be some difficulty with the conversion of certain intersections (see two screenshots attached). Would you be able to point me in the right direction of trying to fix this or are the intersections here in Perth too abnormal for the convert_osm to properly draw?

yasomatinandana commented 4 years ago

for further information, here is the sat view of the same intersection image

dabreegster commented 4 years ago

In short, this is a hard problem that I've struggled with myself for a very long time. I'm certain there are simpler approaches to solving this that a fresh perspective would bring. Start with slides 7-20 of https://docs.google.com/presentation/d/1cF7qFtjAzkXL_r62CjxBvgQnLvuQ9I2WTE2iX_5tMCY/edit?usp=sharing. https://github.com/dabreegster/abstreet/blob/master/docs/articles/map/article.md has lots more detail with code references. https://github.com/dabreegster/abstreet/blob/master/map_model/src/make/initial/geometry.rs is one of the main places. If you have a general idea how to make intersection polygons from OSM centerlines and widths, but don't want to wade through all of the code there now, let me know your idea, and I can try implementing it.

One of the first things to check is that each road segment has the correct number of lanes in reasonable places. Looks like the sidewalks on the north half of Victoria Ave are on the incorrect side, because I've hardcoded driving on the right side of the road (and so for one-way streets, only putting a sidewalk on the right side). Look for the comment "Reverse points for British-style driving" in map.rs and and try unshifted_pts.reversed() a few lines down. I'll think through the right place to plumb through a parameter to specify driving on the right/left.

If you send the .osm file you're feeding in, I can spend some time tomorrow working on the right/left issue and seeing if I can fix a few more things.

yasomatinandana commented 4 years ago

Here is a G-Drive link for both the CBD and overall Perth osm (I was using the Perth CBD in the example above) https://drive.google.com/drive/folders/1tVv1NLy-G0FasyCboeP8i-vIix8a0VC1?usp=sharing

With regards to how to make intersection polygons from OSM data, I am just a grad electrical engineer and I have found my self in the traffic signals management space with a side interest in learning how to simulate/model. I am eager to learn/help in whatever way I can :)

dabreegster commented 4 years ago

Thanks! I'll try converting tomorrow and work on some bug fixes. I'd love any ideas you have about the intersection polygon problem or others. If you have a chance to try out editing a traffic signal, any thoughts about the user interface?

yasomatinandana commented 4 years ago

Awesome! I'll let you know my thoughts once I have poked around a bit more. I almost forgot, with the Perth osm there is an additional OSM highway tag that isn't previously defined in your code. I added the line corridor=0 under map_model/src/road.rs around line 427

dabreegster commented 4 years ago

Screenshot from 2020-03-16 18-28-43 Support for driving on the left side of the road is actually a fair bit harder than I anticipated. I'm about halfway through the changes needed. This particular intersection is looking much better. The biggest complication is that both roads have some kind of median, so they're mapped as separate one-ways in OSM. Coming up with good geometry for this sort of thing has always been a challenge; https://www.openstreetmap.org/node/29464223 is the equivalent example in Seattle.

A big barrier to running simulations in any city is getting data about where parking is available, both on-street and in lots/garages. Looks like there's no https://wiki.openstreetmap.org/wiki/Key:parking:lane tagged in Perth. For Seattle, I have an extra dataset from the local GIS agency and some heuristics based on OSM highway types. Are there any typical patterns for on-street parking in Perth?

yasomatinandana commented 4 years ago

Went down a bit of a rabbit-hole, but it appears Australia's Federal, State and Local government have this handy-dandy online map/data visualisation tool at https://nationalmap.gov.au/ and for the additional parking bay/lot data you asked about above you would need to get data sets COP-004 and COP-031 image

dabreegster commented 4 years ago

Thanks! There's already some tooling to explore how KML data is snapped to roads; I'll update it to handle GeoJSON too.

More generally, now could be a time when I spend some effort doing the work at the beginning of this bug. I'd like to start including more cities by default in A/B Street; I just don't have time to do all the leg-work of making sure each place works well. If you're willing to hunt down data sources like trip demand data, GTFS, elevation, etc for Perth, then I can start generalizing the import pipeline.

dabreegster commented 4 years ago

There's now much better support for this, see https://github.com/dabreegster/abstreet/blob/master/docs/new_city.md. I'm tracking remaining work in https://github.com/dabreegster/abstreet/projects/1. If you have specific issues importing a city or just want to see one in particular added, I vote we split into more specific issues