diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StoptimeImpl.java b/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StoptimeImpl.java index bc14d15fbf2..d7c8e97e255 100644 --- a/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StoptimeImpl.java +++ b/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StoptimeImpl.java @@ -90,6 +90,11 @@ public DataFetcher stopPosition() { return environment -> getSource(environment).getGtfsSequence(); } + @Override + public DataFetcher stopPositionInPattern() { + return environment -> getSource(environment).getStopIndex(); + } + @Override public DataFetcher serviceDay() { return environment -> getSource(environment).getServiceDayMidnight(); diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLDataFetchers.java b/application/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLDataFetchers.java index 7532faf28bd..dffd892e7ee 100644 --- a/application/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLDataFetchers.java +++ b/application/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLDataFetchers.java @@ -1095,6 +1095,8 @@ public interface GraphQLStoptime { public DataFetcher stopPosition(); + public DataFetcher stopPositionInPattern(); + public DataFetcher timepoint(); public DataFetcher trip(); diff --git a/application/src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls b/application/src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls index de1230b9eca..e3871a5ed6c 100644 --- a/application/src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls +++ b/application/src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls @@ -2195,10 +2195,10 @@ type Stoptime { "The stop where this arrival/departure happens" stop: Stop """ - The sequence of the stop in the pattern. This is not required to start from 0 or be consecutive - any + The sequence of the stop in the trip. This is not required to start from 0 or be consecutive - any increasing integer sequence along the stops is valid. - The purpose of this field is to identify the stop within the pattern so it can be cross-referenced + The purpose of this field is to identify the stop within the trip so it can be cross-referenced between it and the itinerary. It is safe to cross-reference when done quickly, i.e. within seconds. However, it should be noted that real-time updates can change the values, so don't store it for longer amounts of time. @@ -2207,6 +2207,15 @@ type Stoptime { even generated. """ stopPosition: Int + """ + The position of the stop in the pattern. This is required to start from 0 and be consecutive along + the pattern, up to n-1 for a pattern with n stops. + + The purpose of this field is to identify the position of the stop within the pattern so it can be + cross-referenced between different trips on the same pattern, as stopPosition can be different + between trips even within the same pattern. + """ + stopPositionInPattern: Int! "true, if this stop is used as a time equalization stop. false otherwise." timepoint: Boolean "Trip which this stoptime is for" diff --git a/application/src/test/resources/org/opentripplanner/apis/gtfs/expectations/patterns.json b/application/src/test/resources/org/opentripplanner/apis/gtfs/expectations/patterns.json index b23ced4f954..08bcc490e0f 100644 --- a/application/src/test/resources/org/opentripplanner/apis/gtfs/expectations/patterns.json +++ b/application/src/test/resources/org/opentripplanner/apis/gtfs/expectations/patterns.json @@ -17,6 +17,7 @@ "scheduledArrival" : 39600, "scheduledDeparture" : 39600, "stopPosition" : 10, + "stopPositionInPattern" : 0, "realtimeState" : "SCHEDULED", "pickupType" : "SCHEDULED", "dropoffType" : "SCHEDULED" @@ -30,6 +31,7 @@ "scheduledArrival" : 39900, "scheduledDeparture" : 39900, "stopPosition" : 20, + "stopPositionInPattern" : 1, "realtimeState" : "SCHEDULED", "pickupType" : "SCHEDULED", "dropoffType" : "SCHEDULED" @@ -43,6 +45,7 @@ "scheduledArrival" : 40200, "scheduledDeparture" : 40200, "stopPosition" : 30, + "stopPositionInPattern" : 2, "realtimeState" : "SCHEDULED", "pickupType" : "SCHEDULED", "dropoffType" : "SCHEDULED" diff --git a/application/src/test/resources/org/opentripplanner/apis/gtfs/queries/patterns.graphql b/application/src/test/resources/org/opentripplanner/apis/gtfs/queries/patterns.graphql index 090473cfc7a..b5af7df47d4 100644 --- a/application/src/test/resources/org/opentripplanner/apis/gtfs/queries/patterns.graphql +++ b/application/src/test/resources/org/opentripplanner/apis/gtfs/queries/patterns.graphql @@ -13,6 +13,7 @@ scheduledArrival scheduledDeparture stopPosition + stopPositionInPattern realtimeState pickupType dropoffType