1 #!/usr/bin/env python3 |
1 #!/usr/bin/env python3 |
2 import sys, json |
2 import sys, json |
3 from misc import * |
3 from misc import * |
4 from geometry import * |
4 from geometry import * |
|
5 from zipfile import ZipFile |
5 |
6 |
6 with open('regions.gmp') as file: |
7 with open('regions.gmp') as file: |
7 data = file.read().split('@') |
8 data = file.read().split('@') |
8 |
9 |
9 with open('region-representatives.json') as file: |
10 with open('region-representatives.json') as file: |
10 representatives = json.load(file) |
11 representatives = json.load(file) |
11 |
12 |
12 bus_stops = {} |
13 bus_stops = {} |
13 |
14 |
14 with open('gtfs/stops.txt') as file: |
15 with ZipFile('gtfs.zip') as archive: |
15 for row in read_csv(file): |
16 with archive.open('stops.txt') as file: |
16 location = Sijainti(float(row['stop_lat']), float(row['stop_lon'])) |
17 for row in read_csv(map(bytes.decode, file)): |
17 reference = row['stop_id'] |
18 location = Sijainti(float(row['stop_lat']), float(row['stop_lon'])) |
18 bus_stops[reference] = location |
19 reference = row['stop_id'] |
|
20 bus_stops[reference] = location |
19 |
21 |
20 district_shapes = [] |
22 district_shapes = [] |
21 for polygon in data[1].splitlines(): |
23 for polygon in data[1].splitlines(): |
22 polygon = polygon.split('^') |
24 polygon = polygon.split('^') |
23 coordinates = [] |
25 coordinates = [] |