Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Realtime stops vectortile layer checks whether there are stoptimes on the service day #5861

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public void setUp() {
.withName(name)
.withDescription(desc)
.withCoordinate(50, 10)
.withTimeZone(ZoneIds.HELSINKI)
.build();
stop2 =
StopModel
Expand All @@ -54,6 +55,7 @@ public void setUp() {
.withName(name)
.withDescription(desc)
.withCoordinate(51, 10)
.withTimeZone(ZoneIds.HELSINKI)
.build();
}

Expand Down Expand Up @@ -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("servicesRunningOnServiceDay"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
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;
import org.opentripplanner.apis.support.mapping.PropertyMapper;
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;

Expand All @@ -32,10 +34,19 @@ protected Collection<KeyValue> map(RegularStop stop) {
.stream()
.anyMatch(alert -> alert.noServiceAt(currentTime));

var serviceDate = LocalDate.ofInstant(currentTime, transitService.getTimeZone());
sharhio marked this conversation as resolved.
Show resolved Hide resolved
boolean stopTimesExist = transitService
.getStopTimesForStop(stop, serviceDate, ArrivalDeparture.BOTH, true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to quickly take a look if this also includes stop times for patterns that have been added through an realtime update but I'm not sure. However, if it doesn't, I think we have plenty of other api calls which are also broken in that sense so maybe we shouldn't care about it for now.

Copy link
Contributor Author

@sharhio sharhio May 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the realtimes are added as the stopTimesHelper.stopTimesForStop fetches the patterns with includeRealtimeUpdates set as true.

.stream()
.anyMatch(stopTime -> stopTime.times.size() > 0);

Collection<KeyValue> sharedKeyValues = getBaseKeyValues(stop, i18NStringMapper, transitService);
return ListUtils.combine(
sharedKeyValues,
List.of(new KeyValue("closedByServiceAlert", noServiceAlert))
List.of(
new KeyValue("closedByServiceAlert", noServiceAlert),
new KeyValue("servicesRunningOnServiceDay", stopTimesExist)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think most of the time we call it ServiceDate instead of ServiceDay.

)
);
}
}
Loading