Skip to content

Commit

Permalink
Add delay and stayOnBusForTransfer to merged dirs (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
alanna-zhou authored Sep 30, 2019
1 parent 6282bec commit 2e042f3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
- /usr/src/app/node_modules

ghopper:
image: cornellappdev/transit-ghopper:v1.0.0
image: cornellappdev/transit-ghopper:v1.0.2
ports:
- "8988:8988"

Expand All @@ -28,7 +28,7 @@ services:
- "8987:8987"

live-tracking:
image: cornellappdev/transit-python:v1.0.0
image: cornellappdev/transit-python:v1.0.2
env_file: python.envrc
ports:
- "5000:5000"
20 changes: 20 additions & 0 deletions src/utils/ParseRouteUtils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @flow
import createGpx from 'gps-to-gpx';

import { isNullOrUndefined } from 'util';
import { MAP_MATCHING } from './EnvUtils';
import AllStopUtils from './AllStopUtils';
import GTFSUtils from './GTFSUtils';
Expand Down Expand Up @@ -65,7 +66,25 @@ function mergeDirections(first, second): Object {
const stops = first.stops.concat(second.stops);
const tripIDs = first.tripIdentifiers.concat(second.tripIdentifiers);

// The combined delay is only the first bus route's delay, because that is
// how much the combined route is initially delayed by and is what the user
// needs to know in order to board the route on time.
const delay = isNullOrUndefined(first.delay) ? null : first.delay;

// If there is any part of the bus route that a passenger does not stay on for
// transfer, then the passenger has to get off the bus at some point, so
// stayOnBusForTransfer is false if either route's stayOnBusForTransfer is false.
const firstStayOnBusForTransfer = isNullOrUndefined(
first.stayOnBusForTransfer,
) ? false : first.stayOnBusForTransfer;
const secondStayOnBusForTransfer = isNullOrUndefined(
second.stayOnBusForTransfer,
) ? false : second.stayOnBusForTransfer;
const stayOnBusForTransfer = firstStayOnBusForTransfer
&& secondStayOnBusForTransfer;

return {
delay,
distance,
endLocation: second.endLocation,
endTime: second.endTime,
Expand All @@ -74,6 +93,7 @@ function mergeDirections(first, second): Object {
routeNumber: first.routeNumber,
startLocation: first.startLocation,
startTime: first.startTime,
stayOnBusForTransfer,
stops,
tripIdentifiers: tripIDs,
type: first.type,
Expand Down

0 comments on commit 2e042f3

Please sign in to comment.