From b40ea4b09b200663c5022bc59d12a007a74934f8 Mon Sep 17 00:00:00 2001 From: Leonard Ehrenfried Date: Thu, 12 Sep 2024 10:56:08 +0200 Subject: [PATCH 1/2] Fix incorrect flex safe duration offset --- .../java/org/opentripplanner/gtfs/mapping/TripMapper.java | 2 +- .../org/opentripplanner/gtfs/mapping/TripMapperTest.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) 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()); } } From ea461af28a14047f097d1ca111253bec143d7ffa Mon Sep 17 00:00:00 2001 From: OTP Changelog Bot Date: Mon, 16 Sep 2024 14:29:45 +0000 Subject: [PATCH 2/2] Add changelog entry for #6059 [ci skip] --- doc/user/Changelog.md | 1 + 1 file changed, 1 insertion(+) 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)