Skip to content

Commit

Permalink
feat(OpenTripPlanner): add stop ID to response
Browse files Browse the repository at this point in the history
  • Loading branch information
thecristen committed Nov 7, 2023
1 parent 7efbea4 commit f3ed9ba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
6 changes: 6 additions & 0 deletions apps/trip_plan/lib/trip_plan/api/open_trip_planner.ex
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,19 @@ defmodule TripPlan.Api.OpenTripPlanner do
lon
departureTime
arrivalTime
stop {
gtfsId
}
}
to {
name
lat
lon
departureTime
arrivalTime
stop {
gtfsId
}
}
route {
gtfsId
Expand Down
15 changes: 13 additions & 2 deletions apps/trip_plan/lib/trip_plan/api/open_trip_planner/parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand All @@ -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"],
Expand Down

0 comments on commit f3ed9ba

Please sign in to comment.