Skip to content

Commit

Permalink
Merge pull request #3751 from entur/otp2_map_station_mode
Browse files Browse the repository at this point in the history
Add mode from parent StopPlace for Quays in Netex mapper
  • Loading branch information
t2gran authored Dec 2, 2021
2 parents edfe3b9 + b05db01 commit 1e4c584
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
import java.util.stream.Collectors;
import org.opentripplanner.graph_builder.DataImportIssueStore;
import org.opentripplanner.graph_builder.Issue;
import org.opentripplanner.gtfs.mapping.TransitModeMapper;
import org.opentripplanner.model.FareZone;
import org.opentripplanner.model.Station;
import org.opentripplanner.model.Stop;
import org.opentripplanner.model.TransitMode;
import org.opentripplanner.netex.index.api.ReadOnlyHierarchicalVersionMapById;
import org.opentripplanner.netex.issues.StopPlaceWithoutQuays;
import org.opentripplanner.netex.mapping.support.FeedScopedIdFactory;
Expand All @@ -43,6 +45,7 @@ class StopAndStationMapper {
private final StationMapper stationMapper;
private final StopMapper stopMapper;
private final TariffZoneMapper tariffZoneMapper;
private final StopPlaceTypeMapper stopPlaceTypeMapper = new StopPlaceTypeMapper();
private final DataImportIssueStore issueStore;


Expand Down Expand Up @@ -82,12 +85,15 @@ void mapParentAndChildStops(final Collection<StopPlace> stopPlaces) {

Station station = mapStopPlaceAllVersionsToStation(selectedStopPlace);
Collection<FareZone> fareZones = mapTariffZones(selectedStopPlace);
TransitMode transitMode = TransitModeMapper.mapMode(
stopPlaceTypeMapper.getTransportMode(selectedStopPlace)
);

// Loop through all versions of the StopPlace in order to collect all quays, even if they
// were deleted in never versions of the StopPlace
for (StopPlace stopPlace : stopPlaceAllVersions) {
for (Quay quay : listOfQuays(stopPlace)) {
addNewStopToParentIfNotPresent(quay, station, fareZones);
addNewStopToParentIfNotPresent(quay, station, fareZones, transitMode);
}
}
}
Expand Down Expand Up @@ -144,9 +150,10 @@ private List<StopPlace> sortStopPlacesByValidityAndVersionDesc(Collection<StopPl
private void addNewStopToParentIfNotPresent(
Quay quay,
Station station,
Collection<FareZone> fareZones
Collection<FareZone> fareZones,
TransitMode transitMode
) {
// TODO OTP2 - This assumtion is only valid because Norway have a
// TODO OTP2 - This assumption is only valid because Norway have a
// - national stop register, we should add all stops/quays
// - for version resolution.
// Continue if this is not newest version of quay
Expand All @@ -157,7 +164,7 @@ private void addNewStopToParentIfNotPresent(
return;
}

Stop stop = stopMapper.mapQuayToStop(quay, station, fareZones);
Stop stop = stopMapper.mapQuayToStop(quay, station, fareZones, transitMode);
if (stop == null) return;

station.addChildStop(stop);
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/org/opentripplanner/netex/mapping/StopMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.opentripplanner.model.FareZone;
import org.opentripplanner.model.Station;
import org.opentripplanner.model.Stop;
import org.opentripplanner.model.TransitMode;
import org.opentripplanner.model.WgsCoordinate;
import org.opentripplanner.netex.issues.QuayWithoutCoordinates;
import org.opentripplanner.netex.mapping.support.FeedScopedIdFactory;
Expand All @@ -29,7 +30,12 @@ class StopMapper {
* Map Netex Quay to OTP Stop
*/
@Nullable
Stop mapQuayToStop(Quay quay, Station parentStation, Collection<FareZone> fareZones) {
Stop mapQuayToStop(
Quay quay,
Station parentStation,
Collection<FareZone> fareZones,
TransitMode transitMode
) {
WgsCoordinate coordinate = WgsCoordinateMapper.mapToDomain(quay.getCentroid());

if (coordinate == null) {
Expand All @@ -49,7 +55,7 @@ Stop mapQuayToStop(Quay quay, Station parentStation, Collection<FareZone> fareZo
fareZones,
null,
null,
null
transitMode
);
stop.setParentStation(parentStation);

Expand Down

0 comments on commit 1e4c584

Please sign in to comment.