File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11[package ]
22authors = [" Hove <core@hove.com>" , " Guillaume Pinot <texitoi@texitoi.eu>" ]
33name = " transit_model"
4- version = " 0.80.0 "
4+ version = " 0.80.1 "
55license = " AGPL-3.0-only"
66description = " Transit data management"
77repository = " https://github.com/hove-io/transit_model"
Original file line number Diff line number Diff line change @@ -1256,9 +1256,13 @@ impl Collections {
12561256
12571257 let mut route_names: BTreeMap < Idx < Route > , String > = BTreeMap :: new ( ) ;
12581258 let mut route_destination_ids: BTreeMap < Idx < Route > , Option < String > > = BTreeMap :: new ( ) ;
1259+ let is_valid_destination_id = |destination_id| self . stop_areas . contains_id ( destination_id) ;
12591260 for ( route_idx, route) in & self . routes {
12601261 let no_route_name = route. name . is_empty ( ) ;
1261- let no_destination_id = route. destination_id . is_none ( ) ;
1262+ let no_destination_id = route
1263+ . destination_id
1264+ . as_ref ( )
1265+ . is_none_or ( |destination_id| !is_valid_destination_id ( destination_id) ) ;
12621266 if no_route_name || no_destination_id {
12631267 let ( origin, destination) = skip_error_and_warn ! ( find_best_origin_destination(
12641268 route_idx,
@@ -2287,6 +2291,11 @@ mod tests {
22872291 & collections,
22882292 ) )
22892293 . unwrap ( ) ;
2294+ // destination_id references an unknown stop_area: it must be replaced
2295+ // by the computed destination stop_area.
2296+ let route_idx = collections. routes . get_idx ( "route_id" ) . unwrap ( ) ;
2297+ collections. routes . index_mut ( route_idx) . destination_id =
2298+ Some ( String :: from ( "stop_area:unknown" ) ) ;
22902299 let routes_to_vehicle_journeys = OneToMany :: new (
22912300 & collections. routes ,
22922301 & collections. vehicle_journeys ,
You can’t perform that action at this time.
0 commit comments