minotor 1.0.7 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -2
- package/README.md +3 -2
- package/dist/cli.mjs +604 -531
- package/dist/cli.mjs.map +1 -1
- package/dist/gtfs/stops.d.ts +19 -5
- package/dist/gtfs/transfers.d.ts +5 -4
- package/dist/gtfs/trips.d.ts +7 -5
- package/dist/gtfs/utils.d.ts +7 -8
- package/dist/parser.cjs.js +569 -501
- package/dist/parser.cjs.js.map +1 -1
- package/dist/parser.esm.js +569 -501
- package/dist/parser.esm.js.map +1 -1
- package/dist/router.cjs.js +1 -1
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.d.ts +3 -3
- package/dist/router.esm.js +1 -1
- package/dist/router.esm.js.map +1 -1
- package/dist/router.umd.js +1 -1
- package/dist/router.umd.js.map +1 -1
- package/dist/routing/__tests__/route.test.d.ts +1 -0
- package/dist/routing/query.d.ts +7 -7
- package/dist/routing/result.d.ts +3 -3
- package/dist/routing/route.d.ts +1 -0
- package/dist/stops/proto/stops.d.ts +5 -4
- package/dist/stops/stops.d.ts +10 -1
- package/dist/stops/stopsIndex.d.ts +21 -4
- package/dist/timetable/proto/timetable.d.ts +21 -18
- package/dist/timetable/timetable.d.ts +38 -14
- package/package.json +4 -3
- package/src/cli/repl.ts +13 -10
- package/src/gtfs/__tests__/parser.test.ts +50 -579
- package/src/gtfs/__tests__/stops.test.ts +181 -112
- package/src/gtfs/__tests__/transfers.test.ts +170 -12
- package/src/gtfs/__tests__/trips.test.ts +212 -141
- package/src/gtfs/__tests__/utils.test.ts +4 -4
- package/src/gtfs/parser.ts +22 -13
- package/src/gtfs/stops.ts +63 -28
- package/src/gtfs/transfers.ts +14 -6
- package/src/gtfs/trips.ts +110 -47
- package/src/gtfs/utils.ts +11 -11
- package/src/router.ts +2 -3
- package/src/routing/__tests__/route.test.ts +112 -0
- package/src/routing/__tests__/router.test.ts +234 -244
- package/src/routing/query.ts +7 -7
- package/src/routing/result.ts +9 -6
- package/src/routing/route.ts +11 -0
- package/src/routing/router.ts +26 -24
- package/src/stops/__tests__/io.test.ts +9 -8
- package/src/stops/__tests__/stopFinder.test.ts +45 -36
- package/src/stops/io.ts +8 -5
- package/src/stops/proto/stops.proto +8 -7
- package/src/stops/proto/stops.ts +68 -38
- package/src/stops/stops.ts +13 -1
- package/src/stops/stopsIndex.ts +50 -7
- package/src/timetable/__tests__/io.test.ts +40 -49
- package/src/timetable/__tests__/timetable.test.ts +50 -58
- package/src/timetable/io.ts +69 -56
- package/src/timetable/proto/timetable.proto +22 -17
- package/src/timetable/proto/timetable.ts +94 -184
- package/src/timetable/timetable.ts +62 -29
|
@@ -2,12 +2,12 @@ import assert from 'node:assert';
|
|
|
2
2
|
import { Readable } from 'node:stream';
|
|
3
3
|
import { describe, it } from 'node:test';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { StopId } from '../../stops/stops.js';
|
|
6
6
|
import { chGtfsProfile } from '../profiles/ch.js';
|
|
7
|
-
import { parseStops } from '../stops.js';
|
|
7
|
+
import { indexStops, ParsedStopsMap, parseStops } from '../stops.js';
|
|
8
8
|
|
|
9
9
|
describe('GTFS stops parser', () => {
|
|
10
|
-
describe('
|
|
10
|
+
describe('parseStops', () => {
|
|
11
11
|
it('should parse valid stops present in the source', async () => {
|
|
12
12
|
const mockedStream = new Readable();
|
|
13
13
|
mockedStream.push(
|
|
@@ -21,37 +21,34 @@ describe('GTFS stops parser', () => {
|
|
|
21
21
|
);
|
|
22
22
|
|
|
23
23
|
mockedStream.push(null);
|
|
24
|
-
const
|
|
24
|
+
const parsedStops = await parseStops(
|
|
25
25
|
mockedStream,
|
|
26
26
|
chGtfsProfile.platformParser,
|
|
27
27
|
);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
],
|
|
51
|
-
]);
|
|
52
|
-
|
|
53
|
-
assert.deepEqual(stops, expectedStops);
|
|
28
|
+
|
|
29
|
+
assert.equal(parsedStops.size, 2);
|
|
30
|
+
|
|
31
|
+
const stop1 = parsedStops.get('Parent8587255');
|
|
32
|
+
assert.ok(stop1);
|
|
33
|
+
assert.equal(stop1.id, 0);
|
|
34
|
+
assert.equal(stop1.sourceStopId, 'Parent8587255');
|
|
35
|
+
assert.equal(stop1.name, 'Fribourg, Tilleul/Cathédrale');
|
|
36
|
+
assert.equal(stop1.lat, 46.8061375857565);
|
|
37
|
+
assert.equal(stop1.lon, 7.16145029437328);
|
|
38
|
+
assert.equal(stop1.locationType, 'STATION');
|
|
39
|
+
assert.deepEqual(stop1.children, []);
|
|
40
|
+
|
|
41
|
+
const stop2 = parsedStops.get('Parent8504100');
|
|
42
|
+
assert.ok(stop2);
|
|
43
|
+
assert.equal(stop2.id, 1);
|
|
44
|
+
assert.equal(stop2.sourceStopId, 'Parent8504100');
|
|
45
|
+
assert.equal(stop2.name, 'Fribourg/Freiburg');
|
|
46
|
+
assert.equal(stop2.lat, 46.8031492395272);
|
|
47
|
+
assert.equal(stop2.lon, 7.15104780338173);
|
|
48
|
+
assert.equal(stop2.locationType, 'STATION');
|
|
49
|
+
assert.deepEqual(stop2.children, []);
|
|
54
50
|
});
|
|
51
|
+
|
|
55
52
|
it('should parse nested stops', async () => {
|
|
56
53
|
const mockedStream = new Readable();
|
|
57
54
|
mockedStream.push(
|
|
@@ -69,47 +66,30 @@ describe('GTFS stops parser', () => {
|
|
|
69
66
|
|
|
70
67
|
mockedStream.push(null);
|
|
71
68
|
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
95
|
-
children: [],
|
|
96
|
-
},
|
|
97
|
-
],
|
|
98
|
-
[
|
|
99
|
-
'Parent8504100',
|
|
100
|
-
{
|
|
101
|
-
id: 'Parent8504100',
|
|
102
|
-
children: ['8504100:0:1', '8504100:0:2'],
|
|
103
|
-
lat: 46.8031492395272,
|
|
104
|
-
locationType: 'STATION',
|
|
105
|
-
lon: 7.15104780338173,
|
|
106
|
-
name: 'Fribourg/Freiburg',
|
|
107
|
-
},
|
|
108
|
-
],
|
|
109
|
-
]);
|
|
110
|
-
|
|
111
|
-
assert.deepEqual(stops, expectedStops);
|
|
69
|
+
const parsedStops = await parseStops(mockedStream);
|
|
70
|
+
|
|
71
|
+
assert.equal(parsedStops.size, 3);
|
|
72
|
+
|
|
73
|
+
const parentStop = parsedStops.get('Parent8504100');
|
|
74
|
+
assert.ok(parentStop);
|
|
75
|
+
assert.equal(parentStop.id, 2);
|
|
76
|
+
assert.equal(parentStop.sourceStopId, 'Parent8504100');
|
|
77
|
+
assert.equal(parentStop.locationType, 'STATION');
|
|
78
|
+
assert.deepEqual(parentStop.children, [0, 1]);
|
|
79
|
+
|
|
80
|
+
const childStop1 = parsedStops.get('8504100:0:1');
|
|
81
|
+
assert.ok(childStop1);
|
|
82
|
+
assert.equal(childStop1.id, 0);
|
|
83
|
+
assert.equal(childStop1.parent, 2);
|
|
84
|
+
assert.equal(childStop1.locationType, 'SIMPLE_STOP_OR_PLATFORM');
|
|
85
|
+
|
|
86
|
+
const childStop2 = parsedStops.get('8504100:0:2');
|
|
87
|
+
assert.ok(childStop2);
|
|
88
|
+
assert.equal(childStop2.id, 1);
|
|
89
|
+
assert.equal(childStop2.parent, 2);
|
|
90
|
+
assert.equal(childStop2.locationType, 'SIMPLE_STOP_OR_PLATFORM');
|
|
112
91
|
});
|
|
92
|
+
|
|
113
93
|
it('should parse the platform', async () => {
|
|
114
94
|
const mockedStream = new Readable();
|
|
115
95
|
mockedStream.push(
|
|
@@ -127,51 +107,140 @@ describe('GTFS stops parser', () => {
|
|
|
127
107
|
|
|
128
108
|
mockedStream.push(null);
|
|
129
109
|
|
|
130
|
-
const
|
|
110
|
+
const parsedStops = await parseStops(
|
|
131
111
|
mockedStream,
|
|
132
112
|
chGtfsProfile.platformParser,
|
|
133
113
|
);
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
114
|
+
|
|
115
|
+
const childStop1 = parsedStops.get('8504100:0:1');
|
|
116
|
+
assert.ok(childStop1);
|
|
117
|
+
assert.equal(childStop1.platform, '1');
|
|
118
|
+
|
|
119
|
+
const childStop2 = parsedStops.get('8504100:0:2');
|
|
120
|
+
assert.ok(childStop2);
|
|
121
|
+
assert.equal(childStop2.platform, '2');
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
describe('indexStops', () => {
|
|
126
|
+
it('should correctly index parsed stops', () => {
|
|
127
|
+
const parsedStopsMap: ParsedStopsMap = new Map();
|
|
128
|
+
|
|
129
|
+
parsedStopsMap.set('Parent8504100', {
|
|
130
|
+
id: 0,
|
|
131
|
+
sourceStopId: 'Parent8504100',
|
|
132
|
+
name: 'Fribourg/Freiburg',
|
|
133
|
+
lat: 46.8031492395272,
|
|
134
|
+
lon: 7.15104780338173,
|
|
135
|
+
locationType: 'STATION',
|
|
136
|
+
children: [1, 2],
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
parsedStopsMap.set('8504100:0:1', {
|
|
140
|
+
id: 1,
|
|
141
|
+
sourceStopId: '8504100:0:1',
|
|
142
|
+
name: 'Fribourg/Freiburg',
|
|
143
|
+
lat: 46.8018210323626,
|
|
144
|
+
lon: 7.14993389242926,
|
|
145
|
+
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
146
|
+
children: [],
|
|
147
|
+
parent: 0,
|
|
148
|
+
platform: '1',
|
|
149
|
+
parentSourceId: 'Parent8504100',
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
parsedStopsMap.set('8504100:0:2', {
|
|
153
|
+
id: 2,
|
|
154
|
+
sourceStopId: '8504100:0:2',
|
|
155
|
+
name: 'Fribourg/Freiburg',
|
|
156
|
+
lat: 46.8010031847878,
|
|
157
|
+
lon: 7.14920625704902,
|
|
158
|
+
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
159
|
+
children: [],
|
|
160
|
+
parent: 0,
|
|
161
|
+
platform: '2',
|
|
162
|
+
parentSourceId: 'Parent8504100',
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
const indexedStops = indexStops(parsedStopsMap);
|
|
166
|
+
|
|
167
|
+
assert.equal(indexedStops.size, 3);
|
|
168
|
+
|
|
169
|
+
const station = indexedStops.get(0);
|
|
170
|
+
assert.ok(station);
|
|
171
|
+
assert.equal(station.sourceStopId, 'Parent8504100');
|
|
172
|
+
assert.deepEqual(station.children, [1, 2]);
|
|
173
|
+
|
|
174
|
+
const platform1 = indexedStops.get(1);
|
|
175
|
+
assert.ok(platform1);
|
|
176
|
+
assert.equal(platform1.sourceStopId, '8504100:0:1');
|
|
177
|
+
assert.equal(platform1.platform, '1');
|
|
178
|
+
assert.equal(platform1.parent, 0);
|
|
179
|
+
|
|
180
|
+
const platform2 = indexedStops.get(2);
|
|
181
|
+
assert.ok(platform2);
|
|
182
|
+
assert.equal(platform2.sourceStopId, '8504100:0:2');
|
|
183
|
+
assert.equal(platform2.platform, '2');
|
|
184
|
+
assert.equal(platform2.parent, 0);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it('should filter stops based on validStops set', () => {
|
|
188
|
+
const parsedStopsMap: ParsedStopsMap = new Map();
|
|
189
|
+
|
|
190
|
+
parsedStopsMap.set('Parent8504100', {
|
|
191
|
+
id: 0,
|
|
192
|
+
sourceStopId: 'Parent8504100',
|
|
193
|
+
name: 'Fribourg/Freiburg',
|
|
194
|
+
lat: 46.8031492395272,
|
|
195
|
+
lon: 7.15104780338173,
|
|
196
|
+
locationType: 'STATION',
|
|
197
|
+
children: [1, 2, 3],
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
parsedStopsMap.set('8504100:0:1', {
|
|
201
|
+
id: 1,
|
|
202
|
+
sourceStopId: '8504100:0:1',
|
|
203
|
+
name: 'Fribourg/Freiburg',
|
|
204
|
+
lat: 46.8018210323626,
|
|
205
|
+
lon: 7.14993389242926,
|
|
206
|
+
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
207
|
+
children: [],
|
|
208
|
+
parent: 0,
|
|
209
|
+
parentSourceId: 'Parent8504100',
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
parsedStopsMap.set('8504100:0:2', {
|
|
213
|
+
id: 2,
|
|
214
|
+
sourceStopId: '8504100:0:2',
|
|
215
|
+
name: 'Fribourg/Freiburg',
|
|
216
|
+
lat: 46.8010031847878,
|
|
217
|
+
lon: 7.14920625704902,
|
|
218
|
+
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
219
|
+
children: [],
|
|
220
|
+
parent: 0,
|
|
221
|
+
parentSourceId: 'Parent8504100',
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
parsedStopsMap.set('8504100:0:3', {
|
|
225
|
+
id: 3,
|
|
226
|
+
sourceStopId: '8504100:0:3',
|
|
227
|
+
name: 'Fribourg/Freiburg',
|
|
228
|
+
lat: 46.8,
|
|
229
|
+
lon: 7.14,
|
|
230
|
+
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
231
|
+
children: [],
|
|
232
|
+
parent: 0,
|
|
233
|
+
parentSourceId: 'Parent8504100',
|
|
234
|
+
});
|
|
235
|
+
const validStops = new Set<StopId>([1, 2]);
|
|
236
|
+
|
|
237
|
+
const indexedStops = indexStops(parsedStopsMap, validStops);
|
|
238
|
+
|
|
239
|
+
assert.equal(indexedStops.size, 3);
|
|
240
|
+
assert.ok(indexedStops.has(0));
|
|
241
|
+
assert.ok(indexedStops.has(1));
|
|
242
|
+
assert.ok(indexedStops.has(2));
|
|
243
|
+
assert.ok(!indexedStops.has(3));
|
|
175
244
|
});
|
|
176
245
|
});
|
|
177
246
|
});
|
|
@@ -3,6 +3,7 @@ import { Readable } from 'node:stream';
|
|
|
3
3
|
import { describe, it } from 'node:test';
|
|
4
4
|
|
|
5
5
|
import { Duration } from '../../timetable/duration.js';
|
|
6
|
+
import { ParsedStopsMap } from '../stops.js';
|
|
6
7
|
import { parseTransfers } from '../transfers.js';
|
|
7
8
|
|
|
8
9
|
describe('GTFS transfers parser', () => {
|
|
@@ -15,23 +16,66 @@ describe('GTFS transfers parser', () => {
|
|
|
15
16
|
mockedStream.push('"1100097","8014447","2","240"\n');
|
|
16
17
|
mockedStream.push(null);
|
|
17
18
|
|
|
18
|
-
const
|
|
19
|
-
const expectedTransfers = new Map([
|
|
19
|
+
const stopsMap: ParsedStopsMap = new Map([
|
|
20
20
|
[
|
|
21
21
|
'1100084',
|
|
22
|
+
{
|
|
23
|
+
id: 0,
|
|
24
|
+
sourceStopId: '1100084',
|
|
25
|
+
name: 'Test Stop 1',
|
|
26
|
+
children: [],
|
|
27
|
+
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
[
|
|
31
|
+
'8014440:0:1',
|
|
32
|
+
{
|
|
33
|
+
id: 1,
|
|
34
|
+
sourceStopId: '8014440:0:1',
|
|
35
|
+
name: 'Test Stop 2',
|
|
36
|
+
children: [],
|
|
37
|
+
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
[
|
|
41
|
+
'1100097',
|
|
42
|
+
{
|
|
43
|
+
id: 2,
|
|
44
|
+
sourceStopId: '1100097',
|
|
45
|
+
name: 'Test Stop 3',
|
|
46
|
+
children: [],
|
|
47
|
+
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
[
|
|
51
|
+
'8014447',
|
|
52
|
+
{
|
|
53
|
+
id: 3,
|
|
54
|
+
sourceStopId: '8014447',
|
|
55
|
+
name: 'Test Stop 4',
|
|
56
|
+
children: [],
|
|
57
|
+
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
]);
|
|
61
|
+
|
|
62
|
+
const transfers = await parseTransfers(mockedStream, stopsMap);
|
|
63
|
+
const expectedTransfers = new Map([
|
|
64
|
+
[
|
|
65
|
+
0, // Internal ID for stop '1100084'
|
|
22
66
|
[
|
|
23
67
|
{
|
|
24
|
-
destination: '8014440:0:1'
|
|
68
|
+
destination: 1, // Internal ID for stop '8014440:0:1'
|
|
25
69
|
type: 'REQUIRES_MINIMAL_TIME',
|
|
26
70
|
minTransferTime: Duration.fromSeconds(180),
|
|
27
71
|
},
|
|
28
72
|
],
|
|
29
73
|
],
|
|
30
74
|
[
|
|
31
|
-
'1100097'
|
|
75
|
+
2, // Internal ID for stop '1100097'
|
|
32
76
|
[
|
|
33
77
|
{
|
|
34
|
-
destination: '8014447'
|
|
78
|
+
destination: 3, // Internal ID for stop '8014447'
|
|
35
79
|
type: 'REQUIRES_MINIMAL_TIME',
|
|
36
80
|
minTransferTime: Duration.fromSeconds(240),
|
|
37
81
|
},
|
|
@@ -51,7 +95,50 @@ describe('GTFS transfers parser', () => {
|
|
|
51
95
|
mockedStream.push('"1100097","8014447","5","240"\n');
|
|
52
96
|
mockedStream.push(null);
|
|
53
97
|
|
|
54
|
-
const
|
|
98
|
+
const stopsMap: ParsedStopsMap = new Map([
|
|
99
|
+
[
|
|
100
|
+
'1100084',
|
|
101
|
+
{
|
|
102
|
+
id: 0,
|
|
103
|
+
sourceStopId: '1100084',
|
|
104
|
+
name: 'Test Stop 1',
|
|
105
|
+
children: [],
|
|
106
|
+
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
[
|
|
110
|
+
'8014440:0:1',
|
|
111
|
+
{
|
|
112
|
+
id: 1,
|
|
113
|
+
sourceStopId: '8014440:0:1',
|
|
114
|
+
name: 'Test Stop 2',
|
|
115
|
+
children: [],
|
|
116
|
+
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
[
|
|
120
|
+
'1100097',
|
|
121
|
+
{
|
|
122
|
+
id: 2,
|
|
123
|
+
sourceStopId: '1100097',
|
|
124
|
+
name: 'Test Stop 3',
|
|
125
|
+
children: [],
|
|
126
|
+
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
[
|
|
130
|
+
'8014447',
|
|
131
|
+
{
|
|
132
|
+
id: 3,
|
|
133
|
+
sourceStopId: '8014447',
|
|
134
|
+
name: 'Test Stop 4',
|
|
135
|
+
children: [],
|
|
136
|
+
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
]);
|
|
140
|
+
|
|
141
|
+
const transfers = await parseTransfers(mockedStream, stopsMap);
|
|
55
142
|
assert.deepEqual(transfers, new Map());
|
|
56
143
|
});
|
|
57
144
|
|
|
@@ -63,7 +150,30 @@ describe('GTFS transfers parser', () => {
|
|
|
63
150
|
mockedStream.push('"1100084","8014440","2","180"\n');
|
|
64
151
|
mockedStream.push(null);
|
|
65
152
|
|
|
66
|
-
const
|
|
153
|
+
const stopsMap: ParsedStopsMap = new Map([
|
|
154
|
+
[
|
|
155
|
+
'1100084',
|
|
156
|
+
{
|
|
157
|
+
id: 0,
|
|
158
|
+
sourceStopId: '1100084',
|
|
159
|
+
name: 'Test Stop 1',
|
|
160
|
+
children: [],
|
|
161
|
+
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
[
|
|
165
|
+
'8014440',
|
|
166
|
+
{
|
|
167
|
+
id: 1,
|
|
168
|
+
sourceStopId: '8014440',
|
|
169
|
+
name: 'Test Stop 2',
|
|
170
|
+
children: [],
|
|
171
|
+
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
]);
|
|
175
|
+
|
|
176
|
+
const transfers = await parseTransfers(mockedStream, stopsMap);
|
|
67
177
|
assert.deepEqual(transfers, new Map());
|
|
68
178
|
});
|
|
69
179
|
|
|
@@ -75,7 +185,30 @@ describe('GTFS transfers parser', () => {
|
|
|
75
185
|
mockedStream.push('"1100084","8014440","2","180"\n');
|
|
76
186
|
mockedStream.push(null);
|
|
77
187
|
|
|
78
|
-
const
|
|
188
|
+
const stopsMap: ParsedStopsMap = new Map([
|
|
189
|
+
[
|
|
190
|
+
'1100084',
|
|
191
|
+
{
|
|
192
|
+
id: 0,
|
|
193
|
+
sourceStopId: '1100084',
|
|
194
|
+
name: 'Test Stop 1',
|
|
195
|
+
children: [],
|
|
196
|
+
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
197
|
+
},
|
|
198
|
+
],
|
|
199
|
+
[
|
|
200
|
+
'8014440',
|
|
201
|
+
{
|
|
202
|
+
id: 1,
|
|
203
|
+
sourceStopId: '8014440',
|
|
204
|
+
name: 'Test Stop 2',
|
|
205
|
+
children: [],
|
|
206
|
+
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
]);
|
|
210
|
+
|
|
211
|
+
const transfers = await parseTransfers(mockedStream, stopsMap);
|
|
79
212
|
assert.deepEqual(transfers, new Map());
|
|
80
213
|
});
|
|
81
214
|
|
|
@@ -87,15 +220,38 @@ describe('GTFS transfers parser', () => {
|
|
|
87
220
|
mockedStream.push('"1100084","8014440:0:1","2"\n');
|
|
88
221
|
mockedStream.push(null);
|
|
89
222
|
|
|
90
|
-
const
|
|
223
|
+
const stopsMap: ParsedStopsMap = new Map([
|
|
224
|
+
[
|
|
225
|
+
'1100084',
|
|
226
|
+
{
|
|
227
|
+
id: 0,
|
|
228
|
+
sourceStopId: '1100084',
|
|
229
|
+
name: 'Test Stop 1',
|
|
230
|
+
children: [],
|
|
231
|
+
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
232
|
+
},
|
|
233
|
+
],
|
|
234
|
+
[
|
|
235
|
+
'8014440:0:1',
|
|
236
|
+
{
|
|
237
|
+
id: 1,
|
|
238
|
+
sourceStopId: '8014440:0:1',
|
|
239
|
+
name: 'Test Stop 2',
|
|
240
|
+
children: [],
|
|
241
|
+
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
242
|
+
},
|
|
243
|
+
],
|
|
244
|
+
]);
|
|
245
|
+
console.log(JSON.stringify(stopsMap));
|
|
246
|
+
const transfers = await parseTransfers(mockedStream, stopsMap);
|
|
91
247
|
assert.deepEqual(
|
|
92
248
|
transfers,
|
|
93
249
|
new Map([
|
|
94
250
|
[
|
|
95
|
-
'1100084'
|
|
251
|
+
0, // Internal ID for stop '1100084'
|
|
96
252
|
[
|
|
97
253
|
{
|
|
98
|
-
destination: '8014440:0:1'
|
|
254
|
+
destination: 1, // Internal ID for stop '8014440:0:1'
|
|
99
255
|
type: 'REQUIRES_MINIMAL_TIME',
|
|
100
256
|
},
|
|
101
257
|
],
|
|
@@ -111,7 +267,9 @@ describe('GTFS transfers parser', () => {
|
|
|
111
267
|
);
|
|
112
268
|
mockedStream.push(null);
|
|
113
269
|
|
|
114
|
-
const
|
|
270
|
+
const stopsMap: ParsedStopsMap = new Map();
|
|
271
|
+
|
|
272
|
+
const transfers = await parseTransfers(mockedStream, stopsMap);
|
|
115
273
|
assert.deepEqual(transfers, new Map());
|
|
116
274
|
});
|
|
117
275
|
});
|