Skip to content

Commit

Permalink
Merge pull request #4493 from entur/otp2_flex_patterns
Browse files Browse the repository at this point in the history
Remove filtering of flex patterns in NeTEX import
  • Loading branch information
hannesj authored Oct 4, 2022
2 parents 3d31c0f + bcf6806 commit ffe9990
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import graphql.schema.GraphQLTypeReference;
import org.opentripplanner.ext.transmodelapi.support.GqlUtil;
import org.opentripplanner.model.PickDrop;
import org.opentripplanner.model.StopTime;
import org.opentripplanner.model.TripTimeOnDate;

public class TimetabledPassingTimeType {
Expand Down Expand Up @@ -44,7 +45,7 @@ public static GraphQLObjectType create(
.type(gqlUtil.timeScalar)
.description("Scheduled time of arrival at quay")
.dataFetcher(environment ->
((TripTimeOnDate) environment.getSource()).getScheduledArrival()
missingValueToNull(((TripTimeOnDate) environment.getSource()).getScheduledArrival())
)
.build()
)
Expand All @@ -55,7 +56,7 @@ public static GraphQLObjectType create(
.type(gqlUtil.timeScalar)
.description("Scheduled time of departure from quay")
.dataFetcher(environment ->
((TripTimeOnDate) environment.getSource()).getScheduledDeparture()
missingValueToNull(((TripTimeOnDate) environment.getSource()).getScheduledDeparture())
)
.build()
)
Expand Down Expand Up @@ -145,4 +146,16 @@ public static GraphQLObjectType create(
)
.build();
}

/**
* Generally the missing values are removed during the graph build. However, for flex trips they
* are not and have to be converted to null here.
*/
private static Integer missingValueToNull(int value) {
if (value == StopTime.MISSING_VALUE) {
return null;
} else {
return value;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -204,17 +204,6 @@ TripPatternMapperResult mapTripPattern(JourneyPattern journeyPattern) {
return result;
}

// TODO OTP2 - Trips containing AreaStops are not added to StopPatterns until support
// - for this is added.
if (
result.tripStopTimes
.get(trips.get(0))
.stream()
.anyMatch(t -> t.getStop() instanceof AreaStop || t.getStop() instanceof GroupStop)
) {
return result;
}

// Create StopPattern from any trip (since they are part of the same JourneyPattern)
StopPattern stopPattern = deduplicator.deduplicateObject(
StopPattern.class,
Expand Down

0 comments on commit ffe9990

Please sign in to comment.