30 bus_stop_districts = {} |
30 bus_stop_districts = {} |
31 |
31 |
32 for name, stop_id in representatives.items(): |
32 for name, stop_id in representatives.items(): |
33 if stop_id is None: |
33 if stop_id is None: |
34 continue |
34 continue |
35 for district_shape in district_shapes: |
35 if stop_id not in pysäkit: |
36 if district_shape.sisältää_pisteen(pysäkit[stop_id]): |
36 print('Alueen %r edustaja %r ei löydy aikatauluista' % (name, stop_id), file = sys.stderr) |
37 assert name not in districts |
|
38 districts[name] = district_shape |
|
39 district_shapes.remove(district_shape) |
|
40 bus_stop_districts[stop_id] = name |
|
41 break |
|
42 else: |
37 else: |
43 print('cannot find a shape for %r' % name, file = sys.stderr) |
38 for district_shape in district_shapes: |
|
39 if district_shape.sisältää_pisteen(pysäkit[stop_id]): |
|
40 assert name not in districts |
|
41 districts[name] = district_shape |
|
42 district_shapes.remove(district_shape) |
|
43 bus_stop_districts[stop_id] = name |
|
44 break |
|
45 else: |
|
46 print('cannot find a shape for %r' % name, file = sys.stderr) |
44 |
47 |
45 for stop_id, stop_position in pysäkit.items(): |
48 for stop_id, stop_position in pysäkit.items(): |
46 for district, shape in districts.items(): |
49 for district, shape in districts.items(): |
47 if shape.sisältää_pisteen(stop_position): |
50 if shape.sisältää_pisteen(stop_position): |
48 bus_stop_districts[stop_id] = district |
51 bus_stop_districts[stop_id] = district |