Skip to content

Commit edd8847

Browse files
authored
Merge pull request #1023 from hove-io/fix_dest
fix: nav-5593 avoid route.destination_id which are not stop_areas
2 parents f96ab11 + 1a0434f commit edd8847

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
authors = ["Hove <core@hove.com>", "Guillaume Pinot <texitoi@texitoi.eu>"]
33
name = "transit_model"
4-
version = "0.80.0"
4+
version = "0.80.1"
55
license = "AGPL-3.0-only"
66
description = "Transit data management"
77
repository = "https://github.com/hove-io/transit_model"

src/model.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff 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,

0 commit comments

Comments
 (0)