@@ -135,27 +135,22 @@ def batch_find_path(self, plans):
135135 result_dict ["routes" ] += result ["routes" ]
136136 result_dict ['source' ] = result ['source' ]
137137 result_dict ['target' ] = result ['target' ]
138- return result_dict
138+ return self . _refine_results ( result_dict , plans )
139139
140- def refine_results (self , results ):
140+ def _refine_results (self , results , plans ):
141141 refined_results = []
142- for r in results ['routes' ]:
142+ for i , r in enumerate ( results ['routes' ]) :
143143 if r ['existence' ] == False :
144144 continue
145- modes = [f ['properties' ]['mode' ]
146- for f in r ['geojson' ]['features' ]
147- if f ['properties' ]['type' ] == 'path' ]
148- pt_modes = ['suburban' , 'underground' , 'tram' , 'bus' ]
149- # Eliminate the result claiming using public transit but actually
150- # does not
151- if not (set (modes ).isdisjoint (set (pt_modes ))):
145+ if MODES ['public_transportation' ] in plans [i ].mode_list :
152146 # Claim using public transit
153- real_switch_types = [sp ['properties' ]['switch_type' ] for sp in r ['switch_points' ]]
154- pt_switch_types = ['suburban_station' ,
155- 'underground_station' ,
156- 'tram_station' ,
157- 'bus_station' ]
158- if set (real_switch_types ).isdisjoint (set (pt_switch_types )):
147+ real_modes = [f ['properties' ]['mode' ]
148+ for f in r ['geojson' ]['features' ]
149+ if f ['properties' ]['type' ] == 'path' ]
150+ pt_modes = ['suburban' , 'underground' , 'tram' , 'bus' ]
151+ # Eliminate the result claiming using public transit but actually
152+ # does not
153+ if (set (real_modes ).isdisjoint (set (pt_modes ))):
159154 # It claims using public transit but no public transit station
160155 # is found in the result path. Such a path will be eliminated.
161156 continue
0 commit comments