Skip to content

Commit

Permalink
Merge pull request opentripplanner#6059 from ibi-group/fix-flex-safe-…
Browse files Browse the repository at this point in the history
…duration

Fix incorrect mapping of flex safe duration offset
  • Loading branch information
leonardehrenfried authored Sep 16, 2024
2 parents 069ddda + b40ea4b commit 43a136e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private Optional<TimePenalty> 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()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}
}

0 comments on commit 43a136e

Please sign in to comment.