Skip to content

Commit 8379e40

Browse files
Merge pull request #64 from linkedconnections/development
v2.0.3
2 parents 00544ca + b41c51e commit 8379e40

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed

lib/Gtfsrt2LC.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,14 @@ class Gtfsrt2LC {
150150

151151
// Check if this is a new update based on recorded Connections history (if any)
152152
// and skip it if is not new.
153-
if (this.historyDB && !(await this.differentiaUpdate({
153+
if (this.historyDB && !(await this.differentialUpdate({
154154
route: r,
155155
trip: t,
156156
stopTimes: st,
157-
cu,
158-
ncu: completedUpdates[j + 1],
157+
cu: await this.getStop(cu.stopId),
158+
ncu: await this.getStop(completedUpdates[j + 1].stopId),
159159
pdIndex,
160-
startTime: tripUpdate.trip.startTime,
160+
startTime: format(tripStartTime, 'H:mm:ss'),
161161
startDate,
162162
departureDelay,
163163
arrivalDelay,
@@ -626,7 +626,7 @@ class Gtfsrt2LC {
626626
return update;
627627
}
628628

629-
async differentiaUpdate(params) {
629+
async differentialUpdate(params) {
630630
const {
631631
route,
632632
trip,
@@ -642,11 +642,16 @@ class Gtfsrt2LC {
642642
} = params;
643643

644644
// Build Connection's original rule as in gtfs2lc
645+
const depStopId = cu['stop_code'] && cu['stop_code'] !== '' ?
646+
cu['stop_code'] : cu['stop_id'];
647+
const arrStopId = ncu['stop_code'] && ncu['stop_code'] !== '' ?
648+
ncu['stop_code'] : ncu['stop_id'];
649+
645650
const uniqueId = [
646651
route['route_long_name'].replace(/\s/g, ''),
647652
trip['trip_short_name'],
648-
cu['stopId'],
649-
ncu['stopId'],
653+
depStopId,
654+
arrStopId,
650655
startTime,
651656
stopTimes[pdIndex]['departure_time'],
652657
stopTimes[pdIndex + 1]['arrival_time'],

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gtfsrt2lc",
3-
"version": "2.0.2",
3+
"version": "2.0.3",
44
"description": "Converts the GTFS-RT to Linked Connections",
55
"main": "./Gtfsrt2LC.js",
66
"bin": {

test/gtfsrt2lc.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,4 +582,19 @@ test('Cover GtfsIndex functions', async () => {
582582
try {
583583
await gti.getIndexes();
584584
} catch (err) { }
585+
});
586+
587+
test('Cover Gtfsrt2LC functions', async () => {
588+
grt = new Gtfsrt2lc({ path: rt_path, uris: mock_uris, headers: {} });
589+
// Test for resolveScheduleRelationship
590+
const notAvailable = grt.resolveScheduleRelationship(1, 1);
591+
const mustPhone = grt.resolveScheduleRelationship(0, 2);
592+
const mustCoordinate = grt.resolveScheduleRelationship(0, 3);
593+
// Test for getting headers
594+
const headers = grt.headers;
595+
596+
expect(notAvailable).toBe('gtfs:NotAvailable');
597+
expect(mustPhone).toBe('gtfs:MustPhone');
598+
expect(mustCoordinate).toBe('gtfs:MustCoordinateWithDriver');
599+
expect(headers).toBeDefined();
585600
});

0 commit comments

Comments
 (0)