diff --git a/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/stops/RealtimeStopsLayerTest.java b/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/stops/RealtimeStopsLayerTest.java index 8f2e1f94fa6..bb258beb76f 100644 --- a/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/stops/RealtimeStopsLayerTest.java +++ b/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/stops/RealtimeStopsLayerTest.java @@ -46,6 +46,7 @@ public void setUp() { .withName(name) .withDescription(desc) .withCoordinate(50, 10) + .withTimeZone(ZoneIds.HELSINKI) .build(); stop2 = StopModel @@ -54,6 +55,7 @@ public void setUp() { .withName(name) .withDescription(desc) .withCoordinate(51, 10) + .withTimeZone(ZoneIds.HELSINKI) .build(); } @@ -100,5 +102,6 @@ public TransitAlertService getTransitAlertService() { assertEquals("name", map.get("name")); assertEquals("desc", map.get("desc")); assertEquals(true, map.get("closedByServiceAlert")); + assertEquals(false, map.get("servicesRunningOnServiceDate")); } } diff --git a/src/ext/java/org/opentripplanner/ext/vectortiles/layers/stops/DigitransitRealtimeStopPropertyMapper.java b/src/ext/java/org/opentripplanner/ext/vectortiles/layers/stops/DigitransitRealtimeStopPropertyMapper.java index 55d67d28d71..cf555d6412f 100644 --- a/src/ext/java/org/opentripplanner/ext/vectortiles/layers/stops/DigitransitRealtimeStopPropertyMapper.java +++ b/src/ext/java/org/opentripplanner/ext/vectortiles/layers/stops/DigitransitRealtimeStopPropertyMapper.java @@ -3,6 +3,7 @@ import static org.opentripplanner.ext.vectortiles.layers.stops.DigitransitStopPropertyMapper.getBaseKeyValues; import java.time.Instant; +import java.time.LocalDate; import java.util.Collection; import java.util.List; import java.util.Locale; @@ -10,6 +11,7 @@ import org.opentripplanner.framework.collection.ListUtils; import org.opentripplanner.framework.i18n.I18NStringMapper; import org.opentripplanner.inspector.vector.KeyValue; +import org.opentripplanner.routing.stoptimes.ArrivalDeparture; import org.opentripplanner.transit.model.site.RegularStop; import org.opentripplanner.transit.service.TransitService; @@ -32,10 +34,19 @@ protected Collection map(RegularStop stop) { .stream() .anyMatch(alert -> alert.noServiceAt(currentTime)); + var serviceDate = LocalDate.now(transitService.getTimeZone()); + boolean stopTimesExist = transitService + .getStopTimesForStop(stop, serviceDate, ArrivalDeparture.BOTH, true) + .stream() + .anyMatch(stopTime -> stopTime.times.size() > 0); + Collection sharedKeyValues = getBaseKeyValues(stop, i18NStringMapper, transitService); return ListUtils.combine( sharedKeyValues, - List.of(new KeyValue("closedByServiceAlert", noServiceAlert)) + List.of( + new KeyValue("closedByServiceAlert", noServiceAlert), + new KeyValue("servicesRunningOnServiceDate", stopTimesExist) + ) ); } }