buses.py

changeset 19
16fa9fb20b32
parent 18
1c8ff93fbfac
child 20
3199e289ae62
--- a/buses.py	Sat Jun 10 21:09:11 2017 +0300
+++ b/buses.py	Sat Jun 10 22:30:55 2017 +0300
@@ -120,9 +120,6 @@
 		# Lajittele lopputulos saapumisajan mukaan.
 		result.sort(key = lambda schedule_entry: schedule_entry['time'])
 		return result
-	@property
-	def linkki_karttaan(self):
-		return 'http://www.openstreetmap.org/#map=19/%f/%f' % (self.sijainti.leveys, self.sijainti.pituus)
 
 class Pysähdys:
 	def __init__(self, saapumisaika, lähtöaika, pysäkki, ajo):
@@ -230,6 +227,12 @@
 		self.stops |= other.stops
 		other.stops = set()
 		other._center = None
+	def schedule(self, max_amount = 50):
+		result = []
+		for stop in self.stops:
+			result += stop.schedule(max_amount)
+		result.sort(key = lambda schedule_entry: schedule_entry['time'])
+		return result[:max_amount]
 
 from collections import defaultdict
 bus_stops_by_name = defaultdict(set)
@@ -326,6 +329,11 @@
 cluster_bus_stops()
 name_clusters()
 
+clusters_by_name = {}
+for cluster in all_clusters:
+	assert cluster.name not in clusters_by_name
+	clusters_by_name[cluster.name] = cluster
+
 print('Ladataan aikataulut... ', end = '', flush = True, file = stderr)
 with open('gtfs/stop_times.txt') as file:
 	rivimäärä = sum(line.count('\n') for line in file)

mercurial