From e098c41c135846a71c0c97bd480537817e5dc096 Mon Sep 17 00:00:00 2001 From: Josef Petrak Date: Thu, 21 Mar 2024 01:37:25 +0100 Subject: [PATCH] #30 plan() method to return Route, Trip, Agency gtfsId --- .../java/org/opentripplanner/client/model/Agency.java | 4 +++- src/main/java/org/opentripplanner/client/model/Leg.java | 1 + .../java/org/opentripplanner/client/model/Route.java | 7 ++++++- src/main/java/org/opentripplanner/client/model/Trip.java | 9 +++++++++ src/main/resources/queries/plan.graphql | 5 +++++ 5 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 src/main/java/org/opentripplanner/client/model/Trip.java diff --git a/src/main/java/org/opentripplanner/client/model/Agency.java b/src/main/java/org/opentripplanner/client/model/Agency.java index 02476d5..02dc34f 100644 --- a/src/main/java/org/opentripplanner/client/model/Agency.java +++ b/src/main/java/org/opentripplanner/client/model/Agency.java @@ -1,3 +1,5 @@ package org.opentripplanner.client.model; -public record Agency(String name) {} +import com.fasterxml.jackson.annotation.JsonProperty; + +public record Agency(@JsonProperty("gtfsId") String id, String name) {} diff --git a/src/main/java/org/opentripplanner/client/model/Leg.java b/src/main/java/org/opentripplanner/client/model/Leg.java index fd1662f..c5d3748 100644 --- a/src/main/java/org/opentripplanner/client/model/Leg.java +++ b/src/main/java/org/opentripplanner/client/model/Leg.java @@ -14,6 +14,7 @@ public record Leg( Duration duration, double distance, Route route, + Trip trip, List fareProducts, OptionalDouble accessibilityScore) { diff --git a/src/main/java/org/opentripplanner/client/model/Route.java b/src/main/java/org/opentripplanner/client/model/Route.java index 7ae7d60..c5ea36b 100644 --- a/src/main/java/org/opentripplanner/client/model/Route.java +++ b/src/main/java/org/opentripplanner/client/model/Route.java @@ -1,9 +1,14 @@ package org.opentripplanner.client.model; +import com.fasterxml.jackson.annotation.JsonProperty; import java.util.Optional; public record Route( - Optional shortName, Optional longName, TransitMode mode, Agency agency) { + @JsonProperty("gtfsId") String id, + Optional shortName, + Optional longName, + TransitMode mode, + Agency agency) { /** * Either the short name (if it has one) or the long name. diff --git a/src/main/java/org/opentripplanner/client/model/Trip.java b/src/main/java/org/opentripplanner/client/model/Trip.java new file mode 100644 index 0000000..082f0fc --- /dev/null +++ b/src/main/java/org/opentripplanner/client/model/Trip.java @@ -0,0 +1,9 @@ +package org.opentripplanner.client.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Optional; + +public record Trip( + @JsonProperty("gtfsId") String id, + Optional tripShortName, + Optional tripHeadsign) {} diff --git a/src/main/resources/queries/plan.graphql b/src/main/resources/queries/plan.graphql index ffb654d..19722e8 100644 --- a/src/main/resources/queries/plan.graphql +++ b/src/main/resources/queries/plan.graphql @@ -36,12 +36,17 @@ query { } mode route { + gtfsId shortName longName agency { + gtfsId name } } + trip { + gtfsId tripShortName tripHeadsign + } duration distance intermediatePlaces {