diff --git a/doc/user/Changelog.md b/doc/user/Changelog.md index 404c27a9070..8e4b10a6f62 100644 --- a/doc/user/Changelog.md +++ b/doc/user/Changelog.md @@ -66,6 +66,7 @@ based on merged pull requests. Search GitHub issues and pull requests for smalle - Add Javadoc for Trip [#6022](https://github.com/opentripplanner/OpenTripPlanner/pull/6022) - Add Iceland to the list of deployments [ci skip] [#6057](https://github.com/opentripplanner/OpenTripPlanner/pull/6057) - Use correct HEAD request when fetching HTTP headers [#6063](https://github.com/opentripplanner/OpenTripPlanner/pull/6063) +- Fix incorrect mapping of flex safe duration offset [#6059](https://github.com/opentripplanner/OpenTripPlanner/pull/6059) [](AUTOMATIC_CHANGELOG_PLACEHOLDER_DO_NOT_REMOVE) ## 2.5.0 (2024-03-13) diff --git a/src/main/java/org/opentripplanner/gtfs/mapping/TripMapper.java b/src/main/java/org/opentripplanner/gtfs/mapping/TripMapper.java index 3a62ba2b269..593c73f58d8 100644 --- a/src/main/java/org/opentripplanner/gtfs/mapping/TripMapper.java +++ b/src/main/java/org/opentripplanner/gtfs/mapping/TripMapper.java @@ -81,7 +81,7 @@ private Optional mapSafeTimePenalty(org.onebusaway.gtfs.model.Trip if (rhs.getSafeDurationFactor() == null && rhs.getSafeDurationOffset() == null) { return Optional.empty(); } else { - var offset = Duration.ofSeconds(rhs.getSafeDurationOffset().longValue()); + var offset = Duration.ofMinutes(rhs.getSafeDurationOffset().longValue()); return Optional.of(TimePenalty.of(offset, rhs.getSafeDurationFactor().doubleValue())); } } diff --git a/src/test/java/org/opentripplanner/gtfs/mapping/TripMapperTest.java b/src/test/java/org/opentripplanner/gtfs/mapping/TripMapperTest.java index 964c3d8155e..c438fb2fd06 100644 --- a/src/test/java/org/opentripplanner/gtfs/mapping/TripMapperTest.java +++ b/src/test/java/org/opentripplanner/gtfs/mapping/TripMapperTest.java @@ -6,6 +6,7 @@ import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertTrue; +import java.time.Duration; import java.util.Collection; import java.util.Collections; import org.junit.jupiter.api.Test; @@ -122,12 +123,12 @@ void flexTimePenalty() { var flexTrip = new Trip(); flexTrip.setId(new AgencyAndId("1", "1")); flexTrip.setSafeDurationFactor(1.5); - flexTrip.setSafeDurationOffset(600d); + flexTrip.setSafeDurationOffset(60d); flexTrip.setRoute(new GtfsTestData().route); var mapper = defaultTripMapper(); var mapped = mapper.map(flexTrip); var penalty = mapper.flexSafeTimePenalties().get(mapped); assertEquals(1.5f, penalty.coefficient()); - assertEquals(600, penalty.constant().toSeconds()); + assertEquals(Duration.ofHours(1), penalty.constant()); } }