From f3ed9bad39f1fdcb94b292b88d7dcef97affcdbc Mon Sep 17 00:00:00 2001 From: Cristen Jones Date: Tue, 7 Nov 2023 17:35:16 -0500 Subject: [PATCH] feat(OpenTripPlanner): add stop ID to response --- .../lib/trip_plan/api/open_trip_planner.ex | 6 ++++++ .../lib/trip_plan/api/open_trip_planner/parser.ex | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/apps/trip_plan/lib/trip_plan/api/open_trip_planner.ex b/apps/trip_plan/lib/trip_plan/api/open_trip_planner.ex index 366069eecc..74463876ba 100644 --- a/apps/trip_plan/lib/trip_plan/api/open_trip_planner.ex +++ b/apps/trip_plan/lib/trip_plan/api/open_trip_planner.ex @@ -178,6 +178,9 @@ defmodule TripPlan.Api.OpenTripPlanner do lon departureTime arrivalTime + stop { + gtfsId + } } to { name @@ -185,6 +188,9 @@ defmodule TripPlan.Api.OpenTripPlanner do lon departureTime arrivalTime + stop { + gtfsId + } } route { gtfsId diff --git a/apps/trip_plan/lib/trip_plan/api/open_trip_planner/parser.ex b/apps/trip_plan/lib/trip_plan/api/open_trip_planner/parser.ex index 2d08da1a39..51ac52c463 100644 --- a/apps/trip_plan/lib/trip_plan/api/open_trip_planner/parser.ex +++ b/apps/trip_plan/lib/trip_plan/api/open_trip_planner/parser.ex @@ -97,8 +97,8 @@ defmodule TripPlan.Api.OpenTripPlanner.Parser do start: parse_time(json["startTime"]), stop: parse_time(json["endTime"]), mode: parse_mode(json), - from: parse_named_position(json["from"], "stopId"), - to: parse_named_position(json["to"], "stopId"), + from: parse_named_position(json["from"], "stop"), + to: parse_named_position(json["to"], "stop"), polyline: json["legGeometry"]["points"], name: json["route"], long_name: json["routeLongName"], @@ -108,6 +108,17 @@ defmodule TripPlan.Api.OpenTripPlanner.Parser do } end + def parse_named_position(json, "stop") do + stop = json["stop"] + + %NamedPosition{ + name: json["name"], + stop_id: if(stop, do: id_after_colon(stop["gtfsId"])), + longitude: json["lon"], + latitude: json["lat"] + } + end + def parse_named_position(json, id_field) do %NamedPosition{ name: json["name"],