1
1
import csv
2
2
3
- fieldnames = ["testCaseId" , "description" , "departure" , "fromLat" , "fromLon" , "toLat" , "toLon" , "origin" , "destination" , "modes" , "category" ]
3
+ fieldnames = ["testCaseId" , "description" , "departure" , "fromLat" ,
4
+ "fromLon" , "toLat" , "toLon" , "origin" , "destination" , "modes" , "category" ]
4
5
5
- locations = [
6
+ locations = [
6
7
7
8
# Helsinki
8
9
{
22
23
"name" : "Itäkeskus"
23
24
},
24
25
{
25
- "coordinates" : "60.148237,24.985142" ,
26
- "name" : "Suomenlinna"
26
+ "coordinates" : "60.148237,24.985142" ,
27
+ "name" : "Suomenlinna"
27
28
},
28
29
# Espoo
29
30
{
43
44
"name" : "Kauklahti"
44
45
},
45
46
{
46
- "coordinates" : "60.29030, 24.56324" ,
47
- "name" : "Nuuksio"
47
+ "coordinates" : "60.29030, 24.56324" ,
48
+ "name" : "Nuuksio"
48
49
},
49
50
{
50
- "coordinates" : "60.17892, 24.65813" ,
51
- "name" : "Latokaski"
51
+ "coordinates" : "60.17892, 24.65813" ,
52
+ "name" : "Latokaski"
52
53
},
53
54
54
55
# Vantaa
55
56
{
56
57
"coordinates" : "60.29246, 25.03861" ,
57
58
"name" : "Tikkurila"
58
59
},
59
- #Airpot
60
+ # Airpot
60
61
{
61
- "coordinates" : "60.317508, 24.969089" ,
62
- "name" : "Airport"
62
+ "coordinates" : "60.317508, 24.969089" ,
63
+ "name" : "Airport"
63
64
},
64
- #Kirkkonummi
65
+ # Kirkkonummi
65
66
{
66
- "coordinates" : "60.12640, 24.43613" ,
67
- "name" : "Kirkkonummi"
67
+ "coordinates" : "60.12640, 24.43613" ,
68
+ "name" : "Kirkkonummi"
68
69
}
69
70
]
70
71
71
- departure_times = ["06:00" ,"13:00" ,"22:00" ]
72
-
73
-
74
- failing_cases = [27 , 66 , 105 , 144 , 159 , 183 , 222 , 300 , 339 , 420 , 459 , 498 , 537 , 576 , 589 , 601 , 602 , 603 , 604 , 605 , 606 , 607 , 608 , 609 , 610 , 611 , 616 , 629 , 642 , 655 , 668 , 681 , 694 , 707 , 720 ]
75
-
76
-
72
+ scooter_locations = [
73
+ {
74
+ "coordinates" : "60.169665, 24.934652" ,
75
+ "name" : "Kamppi"
76
+ },
77
+ {
78
+ "coordinates" : "60.179022, 24.924151" ,
79
+ "name" : "Töölöntori"
80
+ },
81
+ {
82
+ "coordinates" : "60.18234, 24.82531" ,
83
+ "name" : "Otaniemi"
84
+ },
85
+ {
86
+ "coordinates" : "60.198349, 24.875654" ,
87
+ "name" : "Munkkiniemi"
88
+ },
89
+ {
90
+ "coordinates" : "60.199712, 24.939437" ,
91
+ "name" : "Pasila"
92
+ },
93
+ {
94
+ "coordinates" : "60.155454, 24.945134" ,
95
+ "name" : "Eira"
96
+ },
97
+ {
98
+ "coordinates" : "60.184945,24.982309" ,
99
+ "name" : "Kalasatama"
100
+ },
101
+ {
102
+ "coordinates" : "60.15654,24.86665" ,
103
+ "name" : "Lauttasaari"
104
+ },
105
+ {
106
+ "coordinates" : "60.18534,25.00162" ,
107
+ "name" : "Kulosaari"
108
+ },
109
+ ]
110
+ departure_times = ["06:00" , "13:00" , "22:00" ]
77
111
78
112
113
+ failing_cases = [27 , 66 , 105 , 144 , 159 , 183 , 222 ,
114
+ 300 , 339 , 420 , 459 , 498 , 537 , 566 , 568 , 570 ]
79
115
80
116
81
117
rows = []
82
118
119
+
83
120
def parse_coords (input ):
84
121
split = input .split ("," )
85
122
return {
86
123
"lat" : split [0 ],
87
124
"lon" : split [1 ]
88
125
}
89
126
127
+
90
128
counter = 0
91
129
for start in locations :
92
130
for end in locations :
@@ -97,7 +135,8 @@ def parse_coords(input):
97
135
for departure in departure_times :
98
136
counter = counter + 1
99
137
if counter in failing_cases :
100
- print ("FAILED: " , start ["name" ], " " , end ["name" ], " " , departure )
138
+ print ("FAILED: " , start ["name" ],
139
+ " " , end ["name" ], " " , departure )
101
140
else :
102
141
rows .append ({
103
142
"testCaseId" : counter ,
@@ -113,32 +152,33 @@ def parse_coords(input):
113
152
"category" : "transit"
114
153
})
115
154
# Generate scooter test
116
- for start in locations :
117
- for end in locations :
155
+ for start in scooter_locations :
156
+ for end in scooter_locations :
118
157
if end ["coordinates" ] != start ["coordinates" ]:
119
158
start_coords = parse_coords (start ["coordinates" ])
120
159
end_coords = parse_coords (end ["coordinates" ])
121
160
departure = departure_times [0 ] # Use just the first time
122
161
counter += 1
123
162
if counter in failing_cases :
124
- print ("FAILED:" , start ["name" ], "→" , end ["name" ], "@" , departure , "(scooter-transit)" )
163
+ print ("FAILED:" , start ["name" ], "→" ,
164
+ end ["name" ], "@" , departure , "(scooter)" )
125
165
else :
126
166
rows .append ({
127
167
"testCaseId" : counter ,
128
- "description" : f'{ start ["name" ]} to { end ["name" ]} (scooter-transit )' ,
168
+ "description" : f'{ start ["name" ]} to { end ["name" ]} (scooter)' ,
129
169
"departure" : departure ,
130
170
"fromLat" : start_coords ["lat" ],
131
171
"fromLon" : start_coords ["lon" ],
132
172
"toLat" : end_coords ["lat" ],
133
173
"toLon" : end_coords ["lon" ],
134
174
"origin" : start ["name" ],
135
175
"destination" : end ["name" ],
136
- "modes" : "TRANSIT |WALK|SCOOTER_RENT " ,
137
- "category" : "scooter-transit "
176
+ "modes" : "SCOOTER_RENT |WALK" ,
177
+ "category" : "scooter"
138
178
})
139
179
140
180
print (counter )
141
181
with open ('travelSearch.csv' , 'w' , encoding = 'UTF8' , newline = '' ) as f :
142
182
writer = csv .DictWriter (f , fieldnames = fieldnames )
143
183
writer .writeheader ()
144
- writer .writerows (rows )
184
+ writer .writerows (rows )
0 commit comments