From b40ea4b09b200663c5022bc59d12a007a74934f8 Mon Sep 17 00:00:00 2001 From: Leonard Ehrenfried Date: Thu, 12 Sep 2024 10:56:08 +0200 Subject: [PATCH] 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()); } }