Fri, 01 Dec 2017 08:04:57 +0200
Asioita
profiles/föli.ini | file | annotate | diff | comparison | revisions | |
regions.gmp | file | annotate | diff | comparison | revisions | |
regions.ini | file | annotate | diff | comparison | revisions | |
service.py | file | annotate | diff | comparison | revisions |
--- a/profiles/föli.ini Fri Nov 24 22:41:48 2017 +0200 +++ b/profiles/föli.ini Fri Dec 01 08:04:57 2017 +0200 @@ -58,7 +58,6 @@ marttila = 100 koski tl = 100 katariina = 50 -länsikeskus = 30 kaanaa = 100 satava = 50 suikkila = 50 @@ -74,6 +73,7 @@ tortinmäki = 50 aura = 100 friskala = -1 +majamäki = -1 merimasku = 50 turkuhalli = 100 messukeskus = 100
--- a/regions.gmp Fri Nov 24 22:41:48 2017 +0200 +++ b/regions.gmp Fri Dec 01 08:04:57 2017 +0200 @@ -1,4 +1,4 @@ -roadmap^60.43146535467294, 22.155968766728055^14@undefined^#FF0000,5,1,#ff8800,0.4^^60.3977,22.24465~60.40772,22.24046~60.40792,22.26057~60.40076,22.27409~60.3952,22.25642 +roadmap^60.453958332715494, 22.152042012730252^15@undefined^#FF0000,5,1,#ff8800,0.4^^60.3977,22.24465~60.40772,22.24046~60.40792,22.26057~60.40076,22.27409~60.3952,22.25642 Haarla^#FF0000,5,1,#ff8800,0.4^^60.3977,22.22706~60.38719,22.23676~60.38341,22.22466~60.38518,22.21205~60.39359,22.20706~60.39816,22.21341 Friskala^#FF0000,5,1,#ff8800,0.4^^60.39868,22.21599~60.39804,22.22852~60.38876,22.23916~60.38952,22.24843~60.39329,22.25135~60.40217,22.23474~60.4019,22.21689 Oriniemi^#FF0000,5,1,#ff8800,0.4^^60.38871,22.16432~60.39236,22.18483~60.39972,22.188~60.40171,22.1823~60.39919,22.15413~60.39151,22.15633 @@ -25,9 +25,8 @@ undefined^#FF0000,5,1,#ff8800,0.4^^60.45191,22.2745~60.44999,22.27746~60.44796,22.2706~60.44837,22.26998~60.44934,22.272 undefined^#FF0000,5,1,#ff8800,0.4^^60.4457,22.19908~60.44249,22.20603~60.43554,22.20629~60.43394,22.19696~60.44188,22.18918 undefined^#FF0000,5,1,#ff8800,0.4^^60.4219,22.10621~60.4208,22.13539~60.40461,22.11823~60.40554,22.10579 -undefined^#FF0000,5,1,#ff8800,0.4^^60.46255,22.1208~60.46094,22.14792~60.45392,22.15324~60.45116,22.13868~60.44198,22.1196~60.4466,22.10751 -undefined^#FF0000,5,1,#ff8800,0.4^^60.4533,22.15139~60.45129,22.1614~60.45049,22.16689~60.44892,22.17899~60.4424,22.18543~60.43899,22.15149~60.43804,22.12393~60.44149,22.1198~60.45079,22.13974 -undefined^#FF0000,5,1,#ff8800,0.4^^60.45943,22.1494~60.45408,22.15343~60.45301,22.15429~60.45194,22.15877~60.45006,22.17728~60.45513,22.17316~60.4602,22.17171 +Pernon telakka^#FF0000,5,1,#ff8800,0.4^^60.46255,22.1208~60.46094,22.14792~60.45392,22.15324~60.45116,22.13868~60.44198,22.1196~60.4466,22.10751 +Perno^#FF0000,5,1,#ff8800,0.4^^60.45943,22.1494~60.45408,22.15343~60.45301,22.15429~60.45194,22.15877~60.45006,22.17728~60.45513,22.17316~60.4602,22.17171 undefined^#FF0000,5,1,#ff8800,0.4^^60.46014,22.17238~60.4603,22.18908~60.45773,22.18912~60.45789,22.18193~60.45188,22.1817~60.45125,22.18339~60.45265,22.18662~60.45364,22.19244~60.45041,22.19823~60.44625,22.19779~60.44274,22.18699~60.4505,22.17996 undefined^#FF0000,5,1,#ff8800,0.4^^60.45066,22.24616~60.44458,22.25495~60.44369,22.25247~60.43624,22.23858~60.4444,22.23654~60.44471,22.23537~60.4478,22.2407 undefined^#FF0000,5,1,#ff8800,0.4^^60.48504,22.23244~60.48575,22.24697~60.49033,22.24506~60.49114,22.24283~60.49107,22.24098~60.49086,22.24005~60.49023,22.23753~60.49002,22.23558~60.48981,22.23345~60.491,22.23294~60.48865,22.22914~60.48714,22.22952~60.48611,22.23257 @@ -266,4 +265,5 @@ Laukkavuori^#FF0000,5,1,#ff8800,0.4^^60.4453,22.32688~60.44323,22.33243~60.43775,22.33392~60.43999,22.32229 Itäkeskus^#FF0000,5,1,#ff8800,0.4^^60.44346,22.35808~60.44244,22.35827~60.44249,22.36081~60.44351,22.36066 Kansanpuisto^#FF0000,5,1,#ff8800,0.4^^60.43241,22.18311~60.42627,22.18908~60.42303,22.17673~60.42923,22.16934 +Pansio^#FF0000,5,1,#ff8800,0.4^^60.45072,22.13895~60.45236,22.14807~60.45108,22.15775~60.44835,22.16389~60.44122,22.17071~60.43832,22.13296~60.4417,22.12108 @@@@@@V2
--- a/regions.ini Fri Nov 24 22:41:48 2017 +0200 +++ b/regions.ini Fri Dec 01 08:04:57 2017 +0200 @@ -206,12 +206,9 @@ Nättinummi = 30 Oriketo = 1435 Paattinen = 1127 -Pansio = 1506 Papinsaari = 352 Patterinhaka = 578 Peltola = 1455 -Perno = 745 -Pernon telakka = 775 Pikisaari = 124 Pläkkikaupunki = 780 Pohjola = 1806
--- a/service.py Fri Nov 24 22:41:48 2017 +0200 +++ b/service.py Fri Dec 01 08:04:57 2017 +0200 @@ -166,6 +166,18 @@ tr = tr, ) +def week_schedule(bus_stop, **kwargs): + for i in range(-1, 7): + yield from bus_stop.schedule_for_day(today() + timedelta(i), **kwargs) + +def route_key(route): + match = re.search(r'^([a-zA-Z]*)(\d+)(.*)$', route) + if match: + groups = match.groups() + return (groups[0], int(groups[1]), groups[2]) + else: + return (route,) + @app.route('/stop_description/<reference>') def bus_stop_description(reference): from buses import bus_stops @@ -189,18 +201,36 @@ return type(names)() else: return names - for schedule_entry in bus_stop.schedule(max_amount = 100, arrivals = True): + data = [] + names = [] + from collections import defaultdict + night_routes = defaultdict(lambda: True) + num_leaves = 0 + for schedule_entry in week_schedule(bus_stop, arrivals = True): #bus_stop.schedule(max_amount = 500, arrivals = True): sign_tuple = tuple(sign_elements(schedule_entry)) + night_routes[schedule_entry['trip'].route.reference] &= is_night_time(schedule_entry['time']) + #for entry in sign_tuple: + # if entry not in names: + # names.append(entry) + #sign_tuple = tuple(names.index(place) for place in sign_tuple) destinations_per_route[schedule_entry['trip'].route.reference][sign_tuple] += 1 + num_leaves += 1 + night_routes = {key for key, value in night_routes.items() if value} routes_per_destination = defaultdict(set) for route in destinations_per_route: - winner = filter_names(destinations_per_route[route].most_common()[0][0]) - destinations_per_route[route] = winner and ' - '.join(winner) or '' - routes_per_destination[winner].add(route) + winner, count = destinations_per_route[route].most_common()[0] + if count >= 10 or count / num_leaves >= 0.01: + winner = filter_names(winner) + #destinations_per_route[route] = winner and ' - '.join(winner) or '' + routes_per_destination[winner].add(route) for key in routes_per_destination: routes_per_destination[key] = sorted(routes_per_destination[key], key = route_key) from pprint import pformat - return pformat(routes_per_destination) + return '<pre>' + \ + 'names: ' + str(names) + '\n '+ \ + 'night_routes: ' + str(night_routes) + '\n '+ \ + 'destinations_per_route: ' + pformat(dict(destinations_per_route)) + '\n' + \ + 'routes_per_destination: ' + pformat(dict(routes_per_destination)) + '</pre>' @app.route('/api/describe_destination/<trip_reference>/<stop_reference>/<int:index>') def describe_destination(trip_reference, stop_reference, index):