def process_transit_graph(graphdb_filename, gtfsdb_filenames, osmdb_filename=None, profiledb_filename=None, agency_id=None, link_stations=False, slogs={}): g = Graph() if profiledb_filename: print( "Opening ProfileDB '%s'"%profiledb_filename ) profiledb = ProfileDB( profiledb_filename ) else: print( "No ProfileDB supplied" ) profiledb = None if osmdb_filename: # Load osmdb =============================== print( "Opening OSM-DB '%s'"%osmdb_filename ) osmdb = OSMDB( osmdb_filename ) compiler.load_streets_to_graph( g, osmdb, profiledb, slogs, reporter=sys.stdout ) # Load gtfsdb ============================== for i, gtfsdb_filename in enumerate(gtfsdb_filenames): gtfsdb = GTFSDatabase( gtfsdb_filename ) service_ids = [x.encode("ascii") for x in gtfsdb.service_ids()] compiler.load_gtfsdb_to_boardalight_graph(g, str(i), gtfsdb, agency_id=agency_id, service_ids=service_ids) if osmdb_filename: compiler.load_transit_street_links_to_graph( g, osmdb, gtfsdb, reporter=sys.stdout ) if link_stations: compiler.link_nearby_stops( g, gtfsdb ) # Export to graphdb ======================== graphdb = GraphDatabase( graphdb_filename, overwrite=True ) graphdb.populate( g, reporter=sys.stdout )
def process_transit_graph(gtfsdb_filename, agency_id, graphdb_filename, link=False): gtfsdb = GTFSDatabase( gtfsdb_filename ) g = Graph() service_ids = [x.encode("ascii") for x in gtfsdb.service_ids()] compiler.load_gtfsdb_to_boardalight_graph(g, gtfsdb, agency_id=agency_id, service_ids=service_ids) if link: compiler.link_nearby_stops( g, gtfsdb ) graphdb = GraphDatabase( graphdb_filename, overwrite=True ) graphdb.populate( g, reporter=sys.stdout )