polaris.network.transit.lib_gtfs.GTFSRouteSystemBuilder#
- class polaris.network.transit.lib_gtfs.GTFSRouteSystemBuilder(network, agency_id, file_path, day='', description='', capacities: dict | None = None)#
Bases:
WorkerThread
Container for GTFS feeds providing data retrieval for the importer
from polaris.network.network import Network network_path = 'D:/Argonne/GTFS/CHICAGO/chicago2018-Supply.sqlite' GTFS_path = 'D:/Argonne/GTFS/CHICAGO/METRA/2019-10-04.zip' my_network = Network() my_network.open(network_path) transit = my_network.transit() feed = transit.new_gtfs(file_path=GTFS_path description='METRA Commuter Rail', agency_identifier='METRA') # In case you created the feed without providing an agency ID or description feed.set_description('METRA Commuter Air Force') # For a least of all dates covered by this feed feed.dates_available() # If you set it with the wrong feed and want to change it feed.set_feed('D:/Argonne/GTFS/CHICAGO/METRA/2073-12-03.zip') # To prevent map-matching to be performed and execute a faster import feed.set_allow_map_match(False) feed.load_date('2019-10-15') # To save the transit raw-shapes to the database for later consult feed.create_raw_shapes() # To map-match the services in this feed feed.map_match() feed.execute_import()
- __init__(network, agency_id, file_path, day='', description='', capacities: dict | None = None)#
Instantiates a transit class for the network
Args:
polaris network (
Network
): Supply model to which this GTFS will be imported agency_identifier (str
): ID for the agency this feed refers to (e.g. ‘CTA’) file_path (str
): Full path to the GTFS feed (e.g. ‘D:/project/my_gtfs_feed.zip’) day (str
, Optional): Service data contained in this field to be imported (e.g. ‘2019-10-04’) description (str
, Optional): Description for this feed (e.g. ‘CTA19 fixed by John after coffee’)
Methods
__init__
(network, agency_id, file_path[, ...])Instantiates a transit class for the network
Build the graph for links for a certain mode while splitting the closest links at stops' projection
Adds all shapes provided in the GTFS feeds to the TRANSIT_RAW_SHAPES table in the network file
Returns a list of all dates available for this feed
doWork
()Alias for execute_import
finished
()load_date
(service_date)Loads the transit services available for service_date
map_match
([route_types])Performs map-matching for all routes of one or more types
Saves all transit elements built in memory to disk
set_agency_identifier
(agency_id)Adds agency ID to this GTFS for use on import
set_allow_map_match
([allow])Changes behavior for finding transit-link shapes
set_capacities
(capacities)Sets default capacities for modes/vehicles.
set_date
(service_date)Sets the date for import without doing any of data processing, which is left for the importer
set_description
(description)Adds description to be added to the imported layers metadata
set_do_raw_shapes
(do_shapes)Sets the raw shapes importer to True for execution by the importer
set_feed
(feed_path)Sets GTFS feed source to be used
set_maximum_speeds
(max_speeds)Sets the maximum speeds to be enforced at segments.
Attributes
- signal = <polaris.utils.python_signal.PythonSignal object>#
- __init__(network, agency_id, file_path, day='', description='', capacities: dict | None = None)#
Instantiates a transit class for the network
Args:
polaris network (
Network
): Supply model to which this GTFS will be imported agency_identifier (str
): ID for the agency this feed refers to (e.g. ‘CTA’) file_path (str
): Full path to the GTFS feed (e.g. ‘D:/project/my_gtfs_feed.zip’) day (str
, Optional): Service data contained in this field to be imported (e.g. ‘2019-10-04’) description (str
, Optional): Description for this feed (e.g. ‘CTA19 fixed by John after coffee’)
- set_capacities(capacities: dict)#
Sets default capacities for modes/vehicles.
- Args:
- capacities (
dict
): Dictionary with GTFS types as keys, each with a list of 3 items for values for capacities: seated, design and total i.e. -> “{0: [150, 300, 300],…}”
- capacities (
- set_maximum_speeds(max_speeds: DataFrame)#
Sets the maximum speeds to be enforced at segments.
- Args:
max_speeds (
pd.DataFrame
): Requires 4 fields: mode, min_distance, max_distance, speed. Modes not covered in the data will not be touched and distance brackets not covered will receive the maximum speed, with a warning
- dates_available() list #
Returns a list of all dates available for this feed
- Returns:
feed dates (
list
): list of all dates available for this feed
- set_allow_map_match(allow=True)#
Changes behavior for finding transit-link shapes
Defaults to True
- Args:
allow (
bool
optional): If True, allows uses map-matching in search of precise transit_link shapes. If False, sets transit_link shapes equal to straight lines between stops. In the presence of GTFS raw shapes it has no effect.
- map_match(route_types: List[int] | None = None) None #
Performs map-matching for all routes of one or more types
Defaults to map-matching Bus routes (type 3) only For a reference of route types, see https://developers.google.com/transit/gtfs/reference#routestxt
- Args:
route_types (
List[int]
orTuple[int]
): Default is [3], for bus only
- set_agency_identifier(agency_id: str) None #
Adds agency ID to this GTFS for use on import
- Args:
agency_id (
str
): ID for the agency this feed refers to (e.g. ‘CTA’)
- set_feed(feed_path: str) None #
Sets GTFS feed source to be used
- Args:
file_path (
str
): Full path to the GTFS feed (e.g. ‘D:/project/my_gtfs_feed.zip’)
- set_description(description: str) None #
Adds description to be added to the imported layers metadata
- Args:
description (
str
): Description for this feed (e.g. ‘CTA2019 fixed by John Doe after strong coffee’)
- set_date(service_date: str) None #
Sets the date for import without doing any of data processing, which is left for the importer
- load_date(service_date: str) None #
Loads the transit services available for service_date
- Args:
service_date (
str
): Day for which services are to be imported (e.g. ‘2019-10-04’)
- set_do_raw_shapes(do_shapes: bool)#
Sets the raw shapes importer to True for execution by the importer
- create_raw_shapes()#
Adds all shapes provided in the GTFS feeds to the TRANSIT_RAW_SHAPES table in the network file
This table is for debugging purposes, as allows the user to compare it with the result of the map-matching procedure.
All previously existing entries with this feed’s prefix ID are removed. For patterns with no corresponding shape on shapes.txt or in the absence of shapes.txt, the raw shape is generated by connecting stops directly.
- doWork()#
Alias for execute_import
- execute_import()#
- save_to_disk()#
Saves all transit elements built in memory to disk
- finished()#
- builds_link_graphs_with_broken_stops()#
Build the graph for links for a certain mode while splitting the closest links at stops’ projection
- Args:
mode_id (
int
): Mode ID for which we will build the graph for