Skip to content

Filter feed earlier in the script #27

@moshobo

Description

@moshobo

When using a GTFS feed from a larger network, Transit Simulator takes a long while to run. At just a glance, it seems that there are a few improvements that could be made to pare down the feed earlier in the script so as to not require so many calculations to be run

Fixes

append_dist_to_stop_times()

This is run on L96 and happens just after the feed is created:

feed = gk.read_feed(path, dist_units='mi')
moving_feed = feed.append_dist_to_stop_times()

As-is, this runs against all stops, before any filtering is done on lines of interest by the user. It definitely seems like this takes some of the largest amount of time to run and doesn't get any faster by specifying fewer routes using the -r flag

routes_to_geojson()

On L117, the geojson for the routes is generated, again before the feed is filtered down:

route_geo_json_array = feed.routes_to_geojson(include_stops=True)

feed.get_stops()

This one might be necessary, but on L119 all stops from the feed are gathered:

all_stops = feed.get_stops()

This is used later to when finding the parent stations to de-duplicate adjacent nodes in the simulation. It might be possible to use the existing route_stops = feed.get_stops(route_ids=[route_id]) on L143, but validation would need to be done to see if the parent stations are tied to the route_id and would therefore show up in this query. Presently, it does seem a bit redundant to make this feed.get_stops() call twice.

Performance Timing

TBD, add benchmarking based on example file to quantify improvements.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions