Skip to content

Commit

Permalink
Remove stop_sequence from output
Browse files Browse the repository at this point in the history
PubTrans has the equivalent of stop_sequence for via point stops, as
well. The GTFS file released by HSL does not include via points so the
stop_sequences did not match. Let's remove the incorrect stop_sequence.
  • Loading branch information
haphut committed Mar 25, 2018
1 parent 52d7053 commit bb40234
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/run.js
Expand Up @@ -6,6 +6,15 @@ const { createFeedBuilder, getFeedMessage } = require("./gtfsrt");
const { transformMonoMessage } = require("./mono");
const { startPublishing, startSubscription } = require("./mqtt");

const removeStopSequence = feedEntity => {
const censored = _.cloneDeep(feedEntity);
censored.tripUpdate.stopTimeUpdate = _.map(
censored.tripUpdate.stopTimeUpdate,
stopTimeUpdate => _.omit(stopTimeUpdate, "stopSequence")
);
return censored;
};

const createMessageHandler = (log, cache, buildFeed, publish) => {
const handleMessage = (topic, input) => {
const feedEntityFragments = transformMonoMessage(log, input);
Expand All @@ -20,6 +29,13 @@ const createMessageHandler = (log, cache, buildFeed, publish) => {
* out nulls just in case.
*/
.filter()
/**
* As via points in PubTrans have their own stopSequence, stopSequence
* does not match the published GTFS. stopSequence should be removed only
* after updateCache where it is used for retaining order in
* stopTimeUpdate.
*/
.map(feedEntity => removeStopSequence(feedEntity))
// Publish each trip separately.
.map(feedEntity => buildFeed([feedEntity]))
.forEach(feed => publish(feed))
Expand Down

0 comments on commit bb40234

Please sign in to comment.