def test_zip_read_to_schedule_correct(correct_schedule_graph_nodes_from_test_gtfs, correct_schedule_graph_edges_from_test_gtfs, correct_schedule_graph_data_from_test_gtfs): schedule_graph = gtfs_reader.read_gtfs_to_schedule_graph(gtfs_test_file, '20190604') assert_semantically_equal(dict(schedule_graph.nodes(data=True)), correct_schedule_graph_nodes_from_test_gtfs) assert_semantically_equal(schedule_graph.edges._adjdict, correct_schedule_graph_edges_from_test_gtfs) del schedule_graph.graph['change_log'] del correct_schedule_graph_data_from_test_gtfs['change_log'] assert_semantically_equal(schedule_graph.graph, correct_schedule_graph_data_from_test_gtfs)
def read_gtfs(path, day, epsg=None): """ Reads from GTFS. The resulting services will not have network routes. Assumed to be in lat lon epsg:4326. :param path: to GTFS folder or a zip file :param day: 'YYYYMMDD' to use from the gtfs :param epsg: projection for the output Schedule, e.g. 'epsg:27700'. If not provided, the Schedule remains in epsg:4326 :return: """ logging.info(f'Reading GTFS from {path}') schedule_graph = gtfs_reader.read_gtfs_to_schedule_graph(path, day) s = schedule_elements.Schedule(epsg='epsg:4326', _graph=schedule_graph) if epsg is not None: s.reproject(new_epsg=epsg) return s
def test_reading_loopy_gtfs_removes_duplicated_stops(): schedule_graph = gtfs_reader.read_gtfs_to_schedule_graph( os.path.abspath(os.path.join(os.path.dirname(__file__), "test_data", "loopy_gtfs")), '20190604') assert schedule_graph.graph['routes']['1001_0']['ordered_stops'] == ['BSE', 'BSN', 'BSE', 'BSN']