--- a/buses.py Sun Jun 11 01:28:25 2017 +0300 +++ b/buses.py Tue Jun 13 00:47:24 2017 +0300 @@ -199,11 +199,15 @@ pysäkit[pysäkkitunniste].alue = alue print('%d pysäkkiä' % len(pysäkit), file = stderr) + class BusStopCluster: def __init__(self): self.stops = set() self._center = None self.name = None + @property + def url_name(self): + return self.name.lower().replace('(', '').replace(')', '').replace(' ', '-') def add_stop(self, stop): assert not stop.cluster stop.cluster = self @@ -294,8 +298,7 @@ clusters_per_name = defaultdict(set) for cluster in all_clusters: name_representing_stop = min((len(pysäkki.tunniste), pysäkki.tunniste, pysäkki) for pysäkki in cluster.stops)[2] - name = name_representing_stop.nimi.lower().replace(' ', '-') - clusters_per_name[name].add(cluster) + clusters_per_name[name_representing_stop.nimi].add(cluster) for name, clusters in clusters_per_name.items(): if len(clusters) == 1: # Ryhmä on ainoa jolla on varaus tälle nimelle. Sen kuin vaan. @@ -315,7 +318,7 @@ for cluster, unique_areas in proposal.items(): individual_cluster_name = name if unique_areas: - individual_cluster_name += '-' + min(unique_areas).lower().replace(' ', '-') + individual_cluster_name += ' (' + min(unique_areas) + ')' cluster.name = individual_cluster_name else: # Typerä reunatapaus. Indeksoidaan numeroin... @@ -332,8 +335,8 @@ clusters_by_name = {} for cluster in all_clusters: - assert cluster.name not in clusters_by_name - clusters_by_name[cluster.name] = cluster + assert cluster.url_name not in clusters_by_name + clusters_by_name[cluster.url_name] = cluster print('Ladataan aikataulut... ', end = '', flush = True, file = stderr) with open('gtfs/stop_times.txt') as file: