-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5743 from HSLdevcom/new-vectortile-realtime-stop-…
…layer New vectortile layer for Digitransit realtime stops
- Loading branch information
Showing
7 changed files
with
198 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...g/opentripplanner/ext/vectortiles/layers/stops/DigitransitRealtimeStopPropertyMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.opentripplanner.ext.vectortiles.layers.stops; | ||
|
||
import static org.opentripplanner.ext.vectortiles.layers.stops.DigitransitStopPropertyMapper.getBaseKeyValues; | ||
|
||
import java.time.Instant; | ||
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.transit.model.site.RegularStop; | ||
import org.opentripplanner.transit.service.TransitService; | ||
|
||
public class DigitransitRealtimeStopPropertyMapper extends PropertyMapper<RegularStop> { | ||
|
||
private final TransitService transitService; | ||
private final I18NStringMapper i18NStringMapper; | ||
|
||
public DigitransitRealtimeStopPropertyMapper(TransitService transitService, Locale locale) { | ||
this.transitService = transitService; | ||
this.i18NStringMapper = new I18NStringMapper(locale); | ||
} | ||
|
||
@Override | ||
protected Collection<KeyValue> map(RegularStop stop) { | ||
Instant currentTime = Instant.now(); | ||
boolean noServiceAlert = transitService | ||
.getTransitAlertService() | ||
.getStopAlerts(stop.getId()) | ||
.stream() | ||
.anyMatch(alert -> alert.noServiceAt(currentTime)); | ||
|
||
Collection<KeyValue> sharedKeyValues = getBaseKeyValues(stop, i18NStringMapper, transitService); | ||
return ListUtils.combine( | ||
sharedKeyValues, | ||
List.of(new KeyValue("closedByServiceAlert", noServiceAlert)) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters