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.78k stars 347 forks source link

Project: public transit #372

Open dabreegster opened 4 years ago

dabreegster commented 4 years ago

A/B Street has some modelling for public transit vehicles and riders, but it's quite incomplete. I'm not going to have any time to work on it soon, but I think it'd make a very fun project to jump in. I'm quite willing to mentor / help things along!

Some end goals could be:

Some of the tasks, in no particular order:

JavedNissar commented 4 years ago

I'm confused. There are already buses aren't there? How are the current bus routes set up?

dabreegster commented 4 years ago

A while ago, I started revamping how bus routes are interpreted, so that the vehicles don't make loops, but appear at the first stop ad vanish at the last: a-b-street/abstreet#190. I got distracted and dropped that effort, and in the current in-between state, most routes aren't imported properly.

The importing is done mostly in https://github.com/dabreegster/abstreet/blob/master/convert_osm/src/transit.rs and https://github.com/dabreegster/abstreet/blob/master/map_model/src/make/transit.rs. I can go into more detail if anyone's interested in picking this up. Some of the work described in this issue is half-started, but none of it is to the point of being usable yet.

matkoniecz commented 4 years ago

Figuring out how to model train stations. How long should it take somebody to walk from the road into/out of the station?

What about:

Step 1: implement support highway=footway highway=steps highway=path a-b-street/osm2streets#81 Step 2: for train station create highway=footway connection between its location and nearest sidewalk/road/footway/combined footway/cycleway (maybe skip underground ones) Step 3: run simulation as usual with pedestrians walking on footways

https://www.openstreetmap.org/query?lat=50.06501&lon=19.91663#map=18/50.08273/19.89345 https://www.openstreetmap.org/#map=19/50.08366/19.85961 https://www.openstreetmap.org/#map=19/50.08179/19.85769 look like a viable test cases

dabreegster commented 4 years ago

Good point -- previously I was trying to associate the bus/train position and pedestrian platform position with the old sidewalk model, which ignores separate footpaths. This might be much easier to do after a-b-street/osm2streets#81 is solved and the test case areas have consistent footway tags.

dabreegster commented 3 years ago

https://link.springer.com/chapter/10.1007/978-3-642-38527-8_6 could be nice for routing

dabreegster commented 3 years ago

https://factorio.com/blog/post/fff-364 The "train overview GUI" section has some really awesome ideas to peek in on all stations / buses of a single route, to get a quick sense of how stuck they are.

dabreegster commented 3 years ago

For when this work gets picked up, see some ideas/rationale in a-b-street/abstreet#500

dabreegster commented 3 years ago

https://osmus.slack.com/archives/C029HV951/p1619824463140400 https://wiki.openstreetmap.org/wiki/Proposed_features/Simpler_public_transport_route_relations Someone brought up the "should the route relations in OSM contain all of the ways to show the route" question. Relevant because the current half-broken impl of route importing tries to use these, and has an awfully hard time just putting the ways in order.

PayasR commented 3 years ago

https://epubs.siam.org/doi/pdf/10.1137/1.9781611975499.5 The springer paper is old in the comment above, this is more-or-less state of the art

dabreegster commented 3 years ago

https://www.transit.land/routes/r-c23nb-48#export TransitLand has some fantastic UIs for browsing routes and also for seeing an isochrone around stops, matched up with census data!

dabreegster commented 3 years ago

Just found https://wiki.openstreetmap.org/wiki/Metro_Mapping by way of https://alexey-zakharenkov.github.io/subways/rapid/; great explanations of OSM's model there

dabreegster commented 3 years ago

I think this effort is slowly getting revived, so below is a bit of a project plan. My time is limited, but I'll aim to get the first part done myself in the next ~week, and then handover to a few people who've expressed interest in working on this.

Current code status

Currently:

Importing routes

I'll try to crank this out in the next week to unblock the real work. The first attempt used OSM route relations, but there were lots of complications (described in other PRs and issues). I think just focusing on GTFS is a safer start.

The final desired model for stops and routes:

Transit routes can get crazy: https://github.com/a-b-street/abstreet/issues/190#issuecomment-657702555 I don't think we should try to understand routes that loop or change route numbers in the middle yet. We'll try to more directly follow whatever's in GTFS. If we were aiming for lots of realism, we need to model what happens to a bus in between serving routes. Does it chill at a stopover for a while, then start the route in the opposite direction? Does it go to a bus depot? Figuring out how many physical buses and drivers are needed to fulfill some agency's schedule is not something we should tackle yet. These things could be interesting later to help a transit agency understand costs, but let's start small.

So my plan to import from GTFS is this:

1) Download the GTFS files during import (done) 2) Fill out some routes in RawMap. Each route has metadata (name, GTFS IDs to debug things), a shape (just a polyline that we'll initially clip to the map boundary), a list of stops, and a schedule 3) In the RawMap->Map stage, we'll create the stops, just using distance-based snapping to get driving and sidewalk positions. We'll use A/B Street's pathfinding to make sure there's a driveable route between the sequence of stops, and toss out routes (with errors) that don't import reasonably. The polyline shape will tell us where the bus should enter and exit the map, if the first/last stop are outside the boundary.

Actually maybe we don't need to hold onto the full polyline in RawMap. We could take that full shape and try to snap the entire path to roads. We'd have to check that it's a valid driveable path anyway. Should the map model store the exact path that a bus takes, or always just calculate it as needed? People will edit the map and possibly adjust roads to change the pathfinding costs and make a bus want to take a slightly different route between stops. If we want to give people the ability to force a bus to follow a route they specify that doesn't match what pathfinding says, then we should store the exact path in the model and initially snap using the full shape. But... I don't think that's the right thing to start with.

Next steps coming...

dabreegster commented 3 years ago

These're steps intended for other people to do (with my help of course!). No order / priority necessarily.

Schedules

I'll just get the route shape and stops imported and ignore the schedule. Next step, somebody can figure out the right map model representation and import from GTFS.

Pathfinding for transit users

https://github.com/a-b-street/abstreet/blob/258ed1c156459618d6ef456c1cbdc77bc6a2aa11/map_model/src/pathfind/walking.rs#L137 currently ignores transit schedules entirely and doesn't model transfers. @PayasR will likely be creating a RAPTOR crate to help with this. Once it exists, we can integrate with A/B Street.

Simulation layer transfers

Once pathfinding can tell us a route with transfers (maybe walking in between or maybe waiting at the same platform for a different bus), make the simulation layer use this. https://a-b-street.github.io/docs/tech/trafficsim/trips.html describes how stuff works now.

Modeling transit stations

For the importing work I'll do, I'm going to just snap vehicle and sidewalk positions to the map in the naive distance-based way. In reality, we often have train stations / platforms that're underground, spread over multiple connected buildings, have multiple entrances/exits, etc. OSM has lots of this stuff tagged. How should we represent this in A/B Street? How much detail do we want? At the very least, representing that it takes at least 3 minutes to go from the street entrance to the platform seems important. Do we want to try to render station interiors? Maybe just a simplified view that shows the progress each passenger is in the station between street entrance and platform?

Editing

This is where it gets interesting! Once we can model public transit from real data reasonably, then we can let people change things. I'd think of this as a few stages:

1) What changes can somebody make to roads and intersections to affect an existing bus route? Adding bus lanes or transit signal priority at traffic signals, mainly?

2) Let people modify an existing route's schedule to be more/less frequent at different times of the day. Probably then it's time to think more about operating costs and how many physical buses/drivers are needed to fulfill a schedule.

3) Let people modify a bus's route. Create, delete, move, re-order bus stops. Maybe force the bus to take a certain route between stops that's different than what the bus pathfinding engine says.

4) Let people create entirely new routes. Bus and train routes probably work pretty differently here. Creating new light rail could maybe be conceptually pretty simple, since it doesn't really touch the existing road model much. But we could try to represent underground, elevated, and at-grade stuff. Maybe look at buildings the lines would cross under and reason about tunneling or eminent domain costs.

Measuring

What metrics are interesting to study for how successful transit is? How can we make nice dataviz UIs? If we want to gamify some piece of the public transit work, how do we assign a score for improving a route?

dabreegster commented 2 years ago

For reference: @ThomasDagier has found https://bl.ocks.org/kaezarrex/7a100491d541031b6c24, a super useful tool to debug GTFS shapes.txt. Note it seems quite slow for large input, like San Francisco's shapes.txt

dabreegster commented 2 years ago

https://www.youtube.com/watch?v=cKXoj6_LY2s a commercial tool in this space, UI examples

dabreegster commented 2 years ago

On the hunt for tools to debug / create GTFS, link dump:

dabreegster commented 6 months ago

If anyone's interested, I've started walking + GTFS routing over in https://github.com/a-b-street/15m/issues/4, an experimental rewrite of the 15-min neighbourhood tool. Plenty of project ideas, both frontend/design and backend. image