compute-regions.py

changeset 31
60045b362d71
parent 27
f89504285945
child 32
ca1a0ea81cf6
--- a/compute-regions.py	Sat Jun 24 19:38:05 2017 +0300
+++ b/compute-regions.py	Wed Jun 28 12:20:05 2017 +0300
@@ -2,6 +2,7 @@
 import sys, json
 from misc import *
 from geometry import *
+from zipfile import ZipFile
 
 with open('regions.gmp') as file:
 	data = file.read().split('@')
@@ -11,11 +12,12 @@
 
 bus_stops = {}
 
-with open('gtfs/stops.txt') as file:
-	for row in read_csv(file):
-		location = Sijainti(float(row['stop_lat']), float(row['stop_lon']))
-		reference = row['stop_id']
-		bus_stops[reference] = location
+with ZipFile('gtfs.zip') as archive:
+	with archive.open('stops.txt') as file:
+		for row in read_csv(map(bytes.decode, file)):
+			location = Sijainti(float(row['stop_lat']), float(row['stop_lon']))
+			reference = row['stop_id']
+			bus_stops[reference] = location
 
 district_shapes = []
 for polygon in data[1].splitlines():

mercurial