From 2ec51b3dafbf15efef699a56277c6fc3e0f8a949 Mon Sep 17 00:00:00 2001 From: Gard Mellemstrand Date: Tue, 27 Apr 2021 13:13:46 +0200 Subject: [PATCH] Include stop places without parents --- .../model/stop/StopPlaceType.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/ext/java/org/opentripplanner/ext/transmodelapi/model/stop/StopPlaceType.java b/src/ext/java/org/opentripplanner/ext/transmodelapi/model/stop/StopPlaceType.java index cb10b6e43c3..c95d7e15c0f 100644 --- a/src/ext/java/org/opentripplanner/ext/transmodelapi/model/stop/StopPlaceType.java +++ b/src/ext/java/org/opentripplanner/ext/transmodelapi/model/stop/StopPlaceType.java @@ -361,14 +361,19 @@ else if("all".equals(multiModalMode)) { }); return result; } - // Default "parent" - Multi modal parent stop places without their mono modal children + // Default "parent" - Multi modal parent stop places without their mono modal children, but add + // mono modal stop places if they have no parent stop place else if("parent".equals(multiModalMode)){ - return stations - .map(it -> routingService.getMultiModalStationForStations().get(it)) - .filter(Objects::nonNull) - .distinct() - .map(MonoOrMultiModalStation::new) - .collect(Collectors.toUnmodifiableList()); + Set result = new HashSet<>(); + stations.forEach(it -> { + MultiModalStation p = routingService.getMultiModalStationForStations().get(it); + if(p != null) { + result.add(new MonoOrMultiModalStation(p)); + } else { + result.add(new MonoOrMultiModalStation(it, null)); + } + }); + return result; } else { throw new IllegalArgumentException("Unexpected multiModalMode: " + multiModalMode);