diff --git a/src/main/java/org/opentripplanner/netex/mapping/MultiModalStationMapper.java b/src/main/java/org/opentripplanner/netex/mapping/MultiModalStationMapper.java index ef4b0a25cfd..5a4fb23bbb9 100644 --- a/src/main/java/org/opentripplanner/netex/mapping/MultiModalStationMapper.java +++ b/src/main/java/org/opentripplanner/netex/mapping/MultiModalStationMapper.java @@ -1,6 +1,7 @@ package org.opentripplanner.netex.mapping; import java.util.Collection; +import javax.annotation.Nullable; import org.opentripplanner.framework.geometry.WgsCoordinate; import org.opentripplanner.framework.i18n.NonLocalizedString; import org.opentripplanner.graph_builder.issue.api.DataImportIssueStore; @@ -21,6 +22,7 @@ public MultiModalStationMapper(DataImportIssueStore issueStore, FeedScopedIdFact this.idFactory = idFactory; } + @Nullable MultiModalStation map(StopPlace stopPlace, Collection childStations) { MultiModalStationBuilder multiModalStation = MultiModalStation .of(idFactory.createId(stopPlace.getId())) @@ -34,13 +36,13 @@ MultiModalStation map(StopPlace stopPlace, Collection childStations) { if (coordinate == null) { issueStore.add( "MultiModalStationWithoutCoordinates", - "MultiModal station {} does not contain any coordinates.", + "MultiModal station %s does not contain any coordinates.", multiModalStation.getId() ); + return null; } else { multiModalStation.withCoordinate(coordinate); + return multiModalStation.build(); } - - return multiModalStation.build(); } } diff --git a/src/main/java/org/opentripplanner/netex/mapping/NetexMapper.java b/src/main/java/org/opentripplanner/netex/mapping/NetexMapper.java index c3c9ad2d0ae..991c0477266 100644 --- a/src/main/java/org/opentripplanner/netex/mapping/NetexMapper.java +++ b/src/main/java/org/opentripplanner/netex/mapping/NetexMapper.java @@ -332,8 +332,9 @@ private void mapMultiModalStopPlaces() { .getStationsByMultiModalStationRfs() .get(multiModalStopPlace.getId()); var multiModalStation = mapper.map(multiModalStopPlace, stations); - - transitBuilder.stopModel().withMultiModalStation(multiModalStation); + if (multiModalStation != null) { + transitBuilder.stopModel().withMultiModalStation(multiModalStation); + } } } diff --git a/src/main/java/org/opentripplanner/transit/model/site/MultiModalStation.java b/src/main/java/org/opentripplanner/transit/model/site/MultiModalStation.java index 749b156656e..70f4924e8e1 100644 --- a/src/main/java/org/opentripplanner/transit/model/site/MultiModalStation.java +++ b/src/main/java/org/opentripplanner/transit/model/site/MultiModalStation.java @@ -37,11 +37,11 @@ public class MultiModalStation super(builder.getId()); // Required fields this.childStations = Objects.requireNonNull(builder.childStations()); + this.coordinate = Objects.requireNonNull(builder.coordinate()); this.name = I18NString.assertHasValue(builder.name()); // Optional fields // TODO Make required - this.coordinate = builder.coordinate(); this.code = builder.code(); this.description = builder.description(); this.url = builder.url(); diff --git a/src/test/java/org/opentripplanner/transit/model/site/MultiModalStationTest.java b/src/test/java/org/opentripplanner/transit/model/site/MultiModalStationTest.java index 4ca8e8d33ea..615b0c49674 100644 --- a/src/test/java/org/opentripplanner/transit/model/site/MultiModalStationTest.java +++ b/src/test/java/org/opentripplanner/transit/model/site/MultiModalStationTest.java @@ -8,6 +8,7 @@ import java.util.Set; import org.junit.jupiter.api.Test; +import org.opentripplanner.framework.geometry.WgsCoordinate; import org.opentripplanner.framework.i18n.I18NString; import org.opentripplanner.framework.i18n.NonLocalizedString; import org.opentripplanner.transit.model._data.TransitModelForTest; @@ -26,6 +27,7 @@ class MultiModalStationTest { .of(TransitModelForTest.id(ID)) .withName(NAME) .withChildStations(CHILD_STATIONS) + .withCoordinate(new WgsCoordinate(1, 1)) .build(); @Test