compute-regions.py

changeset 73
c56b0ef96514
parent 52
cab8d38fe5c6
child 88
3b86597c5a88
equal deleted inserted replaced
72:65408ed066b3 73:c56b0ef96514
25 location = Sijainti(float(row['stop_lat']), float(row['stop_lon'])) 25 location = Sijainti(float(row['stop_lat']), float(row['stop_lon']))
26 reference = row['stop_id'] 26 reference = row['stop_id']
27 bus_stops[reference] = location 27 bus_stops[reference] = location
28 28
29 district_shapes = [] 29 district_shapes = []
30 districts = {}
31
30 for polygon in data[1].splitlines(): 32 for polygon in data[1].splitlines():
31 polygon = polygon.split('^') 33 polygon = polygon.split('^')
32 coordinates = [] 34 coordinates = []
33 for point in polygon[3].split('~'): 35 for point in polygon[3].split('~'):
34 x, y = point.split(',') 36 x, y = point.split(',')
35 coordinates.append(Sijainti(float(x), float(y))) 37 coordinates.append(Sijainti(float(x), float(y)))
36 district_shapes.append(Monikulmio(*coordinates)) 38 district_shapes.append(Monikulmio(*coordinates))
39 if polygon[0] != 'undefined':
40 districts[polygon[0]] = district_shapes[-1]
37 41
38 districts = {}
39 bus_stop_districts = {} 42 bus_stop_districts = {}
40 43
41 for name, stop_id in representatives.items(): 44 for name, stop_id in representatives.items():
42 if stop_id: 45 if stop_id:
43 if stop_id not in bus_stops: 46 if stop_id not in bus_stops:

mercurial