--- a/compute-regions.py Wed Sep 26 13:17:22 2018 +0300 +++ b/compute-regions.py Fri Sep 28 13:09:04 2018 +0300 @@ -85,7 +85,7 @@ from argparse import ArgumentParser parser = ArgumentParser() parser.add_argument('gtfs_zip') - parser.add_argument('mapfile') + parser.add_argument('profile') return parser.parse_args() def compute_bus_stop_regions(regions, bus_stops): @@ -105,10 +105,16 @@ def percentage(a): return '%.1f%%' % (a * 100) +def compute_route_models(gtfs_path): + from buses import load_buses + load_buses(gtfs_path) + def main(): from regions import parse_regions + from misc import profile args = get_args() - regions = parse_regions(args.mapfile) + profile.read(args.profile) + regions = parse_regions(profile['regions']['osm-path']) bus_stops = read_bus_stops(args.gtfs_zip) bus_stop_regions = compute_bus_stop_regions(regions, bus_stops) covered = sum(1 if value else 0 for value in bus_stop_regions.values()) @@ -116,6 +122,8 @@ print('%s bus stops covered.' % percentage(covered / total), file = sys.stderr) json.dump(bus_stop_regions, sys.stdout, indent = 2) + return 0 if __name__ == '__main__': - main() + from sys import exit + exit(main())