diff --git a/constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/AbsoluteInterval.java b/constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/AbsoluteInterval.java index 271135147c..e0bd37c997 100644 --- a/constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/AbsoluteInterval.java +++ b/constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/AbsoluteInterval.java @@ -25,15 +25,15 @@ public record AbsoluteInterval( public Interval evaluate(final SimulationResults results, final Interval bounds, final EvaluationEnvironment environment) { final Duration relativeStart = start .map(instant -> Duration.of(results.planStart.until(instant, ChronoUnit.MICROS), Duration.MICROSECOND)) - .orElse(Duration.MIN_VALUE); + .orElse(results.bounds.start); final Duration relativeEnd = end .map(instant -> Duration.of(results.planStart.until(instant, ChronoUnit.MICROS), Duration.MICROSECOND)) - .orElse(Duration.MAX_VALUE); + .orElse(results.bounds.end); return Interval.between( relativeStart, - startInclusivity.orElse(Interval.Inclusivity.Inclusive), + startInclusivity.orElse(start.isPresent() ? Interval.Inclusivity.Inclusive : results.bounds.startInclusivity), relativeEnd, - endInclusivity.orElse(Interval.Inclusivity.Inclusive) + endInclusivity.orElse(end.isPresent() ? Interval.Inclusivity.Inclusive : results.bounds.endInclusivity) ); } diff --git a/constraints/src/test/java/gov/nasa/jpl/aerie/constraints/tree/ASTTests.java b/constraints/src/test/java/gov/nasa/jpl/aerie/constraints/tree/ASTTests.java index 20bf3c10db..f719a08f97 100644 --- a/constraints/src/test/java/gov/nasa/jpl/aerie/constraints/tree/ASTTests.java +++ b/constraints/src/test/java/gov/nasa/jpl/aerie/constraints/tree/ASTTests.java @@ -1058,6 +1058,24 @@ public void testSpansFromInterval() { assertEquals(expected, result); } + @Test + public void testHorizonInterval() { + final var simResults = new SimulationResults( + Instant.EPOCH, Interval.between(0, Inclusive, 20, Exclusive, SECONDS), + List.of(), + Map.of(), + Map.of() + ); + + final var interval = new AbsoluteInterval(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + + final var result = interval.evaluate(simResults); + + final var expected = Interval.between(0, Inclusive, 20, Exclusive, SECONDS); + + assertEquals(expected, result); + } + @Test public void testShiftByBoundsAdjustment() { final var simResults = new SimulationResults(