minotor 4.0.0 → 5.0.0

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +4 -3
  2. package/dist/cli.mjs +122 -212
  3. package/dist/cli.mjs.map +1 -1
  4. package/dist/gtfs/trips.d.ts +6 -5
  5. package/dist/parser.cjs.js +121 -211
  6. package/dist/parser.cjs.js.map +1 -1
  7. package/dist/parser.esm.js +121 -211
  8. package/dist/parser.esm.js.map +1 -1
  9. package/dist/router.cjs.js +1 -1
  10. package/dist/router.cjs.js.map +1 -1
  11. package/dist/router.d.ts +2 -2
  12. package/dist/router.esm.js +1 -1
  13. package/dist/router.esm.js.map +1 -1
  14. package/dist/router.umd.js +1 -1
  15. package/dist/router.umd.js.map +1 -1
  16. package/dist/routing/route.d.ts +3 -3
  17. package/dist/timetable/io.d.ts +5 -4
  18. package/dist/timetable/proto/timetable.d.ts +5 -15
  19. package/dist/timetable/route.d.ts +1 -1
  20. package/dist/timetable/timetable.d.ts +7 -5
  21. package/package.json +1 -1
  22. package/src/__e2e__/timetable/timetable.bin +2 -2
  23. package/src/gtfs/__tests__/parser.test.ts +2 -2
  24. package/src/gtfs/__tests__/routes.test.ts +3 -0
  25. package/src/gtfs/__tests__/trips.test.ts +122 -154
  26. package/src/gtfs/parser.ts +2 -1
  27. package/src/gtfs/routes.ts +1 -0
  28. package/src/gtfs/trips.ts +21 -19
  29. package/src/router.ts +2 -2
  30. package/src/routing/__tests__/route.test.ts +3 -3
  31. package/src/routing/__tests__/router.test.ts +186 -203
  32. package/src/routing/route.ts +3 -3
  33. package/src/routing/router.ts +1 -1
  34. package/src/timetable/__tests__/io.test.ts +52 -64
  35. package/src/timetable/__tests__/timetable.test.ts +9 -13
  36. package/src/timetable/io.ts +20 -19
  37. package/src/timetable/proto/timetable.proto +5 -8
  38. package/src/timetable/proto/timetable.ts +78 -201
  39. package/src/timetable/route.ts +1 -1
  40. package/src/timetable/timetable.ts +20 -16
@@ -22,6 +22,18 @@ PERFORMANCE OF THIS SOFTWARE.
22
22
  /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
23
23
 
24
24
 
25
+ function __rest(s, e) {
26
+ var t = {};
27
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
28
+ t[p] = s[p];
29
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
30
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
31
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
32
+ t[p[i]] = s[p[i]];
33
+ }
34
+ return t;
35
+ }
36
+
25
37
  function __awaiter(thisArg, _arguments, P, generator) {
26
38
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
39
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -12309,148 +12321,6 @@ const Route$1 = {
12309
12321
  return message;
12310
12322
  },
12311
12323
  };
12312
- function createBaseRoutesAdjacency() {
12313
- return { routes: {} };
12314
- }
12315
- const RoutesAdjacency = {
12316
- encode(message, writer = new BinaryWriter()) {
12317
- Object.entries(message.routes).forEach(([key, value]) => {
12318
- RoutesAdjacency_RoutesEntry.encode({ key: key, value }, writer.uint32(10).fork()).join();
12319
- });
12320
- return writer;
12321
- },
12322
- decode(input, length) {
12323
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
12324
- const end = length === undefined ? reader.len : reader.pos + length;
12325
- const message = createBaseRoutesAdjacency();
12326
- while (reader.pos < end) {
12327
- const tag = reader.uint32();
12328
- switch (tag >>> 3) {
12329
- case 1: {
12330
- if (tag !== 10) {
12331
- break;
12332
- }
12333
- const entry1 = RoutesAdjacency_RoutesEntry.decode(reader, reader.uint32());
12334
- if (entry1.value !== undefined) {
12335
- message.routes[entry1.key] = entry1.value;
12336
- }
12337
- continue;
12338
- }
12339
- }
12340
- if ((tag & 7) === 4 || tag === 0) {
12341
- break;
12342
- }
12343
- reader.skip(tag & 7);
12344
- }
12345
- return message;
12346
- },
12347
- fromJSON(object) {
12348
- return {
12349
- routes: isObject(object.routes)
12350
- ? Object.entries(object.routes).reduce((acc, [key, value]) => {
12351
- acc[key] = Route$1.fromJSON(value);
12352
- return acc;
12353
- }, {})
12354
- : {},
12355
- };
12356
- },
12357
- toJSON(message) {
12358
- const obj = {};
12359
- if (message.routes) {
12360
- const entries = Object.entries(message.routes);
12361
- if (entries.length > 0) {
12362
- obj.routes = {};
12363
- entries.forEach(([k, v]) => {
12364
- obj.routes[k] = Route$1.toJSON(v);
12365
- });
12366
- }
12367
- }
12368
- return obj;
12369
- },
12370
- create(base) {
12371
- return RoutesAdjacency.fromPartial(base !== null && base !== void 0 ? base : {});
12372
- },
12373
- fromPartial(object) {
12374
- var _a;
12375
- const message = createBaseRoutesAdjacency();
12376
- message.routes = Object.entries((_a = object.routes) !== null && _a !== void 0 ? _a : {}).reduce((acc, [key, value]) => {
12377
- if (value !== undefined) {
12378
- acc[key] = Route$1.fromPartial(value);
12379
- }
12380
- return acc;
12381
- }, {});
12382
- return message;
12383
- },
12384
- };
12385
- function createBaseRoutesAdjacency_RoutesEntry() {
12386
- return { key: "", value: undefined };
12387
- }
12388
- const RoutesAdjacency_RoutesEntry = {
12389
- encode(message, writer = new BinaryWriter()) {
12390
- if (message.key !== "") {
12391
- writer.uint32(10).string(message.key);
12392
- }
12393
- if (message.value !== undefined) {
12394
- Route$1.encode(message.value, writer.uint32(18).fork()).join();
12395
- }
12396
- return writer;
12397
- },
12398
- decode(input, length) {
12399
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
12400
- const end = length === undefined ? reader.len : reader.pos + length;
12401
- const message = createBaseRoutesAdjacency_RoutesEntry();
12402
- while (reader.pos < end) {
12403
- const tag = reader.uint32();
12404
- switch (tag >>> 3) {
12405
- case 1: {
12406
- if (tag !== 10) {
12407
- break;
12408
- }
12409
- message.key = reader.string();
12410
- continue;
12411
- }
12412
- case 2: {
12413
- if (tag !== 18) {
12414
- break;
12415
- }
12416
- message.value = Route$1.decode(reader, reader.uint32());
12417
- continue;
12418
- }
12419
- }
12420
- if ((tag & 7) === 4 || tag === 0) {
12421
- break;
12422
- }
12423
- reader.skip(tag & 7);
12424
- }
12425
- return message;
12426
- },
12427
- fromJSON(object) {
12428
- return {
12429
- key: isSet(object.key) ? globalThis.String(object.key) : "",
12430
- value: isSet(object.value) ? Route$1.fromJSON(object.value) : undefined,
12431
- };
12432
- },
12433
- toJSON(message) {
12434
- const obj = {};
12435
- if (message.key !== "") {
12436
- obj.key = message.key;
12437
- }
12438
- if (message.value !== undefined) {
12439
- obj.value = Route$1.toJSON(message.value);
12440
- }
12441
- return obj;
12442
- },
12443
- create(base) {
12444
- return RoutesAdjacency_RoutesEntry.fromPartial(base !== null && base !== void 0 ? base : {});
12445
- },
12446
- fromPartial(object) {
12447
- var _a;
12448
- const message = createBaseRoutesAdjacency_RoutesEntry();
12449
- message.key = (_a = object.key) !== null && _a !== void 0 ? _a : "";
12450
- message.value = (object.value !== undefined && object.value !== null) ? Route$1.fromPartial(object.value) : undefined;
12451
- return message;
12452
- },
12453
- };
12454
12324
  function createBaseTransfer() {
12455
12325
  return { destination: 0, type: 0, minTransferTime: undefined };
12456
12326
  }
@@ -12463,7 +12333,7 @@ const Transfer = {
12463
12333
  writer.uint32(16).int32(message.type);
12464
12334
  }
12465
12335
  if (message.minTransferTime !== undefined) {
12466
- writer.uint32(24).int32(message.minTransferTime);
12336
+ writer.uint32(24).uint32(message.minTransferTime);
12467
12337
  }
12468
12338
  return writer;
12469
12339
  },
@@ -12492,7 +12362,7 @@ const Transfer = {
12492
12362
  if (tag !== 24) {
12493
12363
  break;
12494
12364
  }
12495
- message.minTransferTime = reader.int32();
12365
+ message.minTransferTime = reader.uint32();
12496
12366
  continue;
12497
12367
  }
12498
12368
  }
@@ -12574,7 +12444,7 @@ const StopsAdjacency = {
12574
12444
  return {
12575
12445
  stops: isObject(object.stops)
12576
12446
  ? Object.entries(object.stops).reduce((acc, [key, value]) => {
12577
- acc[key] = StopsAdjacency_StopAdjacency.fromJSON(value);
12447
+ acc[globalThis.Number(key)] = StopsAdjacency_StopAdjacency.fromJSON(value);
12578
12448
  return acc;
12579
12449
  }, {})
12580
12450
  : {},
@@ -12601,7 +12471,7 @@ const StopsAdjacency = {
12601
12471
  const message = createBaseStopsAdjacency();
12602
12472
  message.stops = Object.entries((_a = object.stops) !== null && _a !== void 0 ? _a : {}).reduce((acc, [key, value]) => {
12603
12473
  if (value !== undefined) {
12604
- acc[key] = StopsAdjacency_StopAdjacency.fromPartial(value);
12474
+ acc[globalThis.Number(key)] = StopsAdjacency_StopAdjacency.fromPartial(value);
12605
12475
  }
12606
12476
  return acc;
12607
12477
  }, {});
@@ -12616,9 +12486,11 @@ const StopsAdjacency_StopAdjacency = {
12616
12486
  for (const v of message.transfers) {
12617
12487
  Transfer.encode(v, writer.uint32(10).fork()).join();
12618
12488
  }
12489
+ writer.uint32(18).fork();
12619
12490
  for (const v of message.routes) {
12620
- writer.uint32(18).string(v);
12491
+ writer.int32(v);
12621
12492
  }
12493
+ writer.join();
12622
12494
  return writer;
12623
12495
  },
12624
12496
  decode(input, length) {
@@ -12636,11 +12508,18 @@ const StopsAdjacency_StopAdjacency = {
12636
12508
  continue;
12637
12509
  }
12638
12510
  case 2: {
12639
- if (tag !== 18) {
12640
- break;
12511
+ if (tag === 16) {
12512
+ message.routes.push(reader.int32());
12513
+ continue;
12641
12514
  }
12642
- message.routes.push(reader.string());
12643
- continue;
12515
+ if (tag === 18) {
12516
+ const end2 = reader.uint32() + reader.pos;
12517
+ while (reader.pos < end2) {
12518
+ message.routes.push(reader.int32());
12519
+ }
12520
+ continue;
12521
+ }
12522
+ break;
12644
12523
  }
12645
12524
  }
12646
12525
  if ((tag & 7) === 4 || tag === 0) {
@@ -12655,7 +12534,7 @@ const StopsAdjacency_StopAdjacency = {
12655
12534
  transfers: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.transfers)
12656
12535
  ? object.transfers.map((e) => Transfer.fromJSON(e))
12657
12536
  : [],
12658
- routes: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.routes) ? object.routes.map((e) => globalThis.String(e)) : [],
12537
+ routes: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.routes) ? object.routes.map((e) => globalThis.Number(e)) : [],
12659
12538
  };
12660
12539
  },
12661
12540
  toJSON(message) {
@@ -12665,7 +12544,7 @@ const StopsAdjacency_StopAdjacency = {
12665
12544
  obj.transfers = message.transfers.map((e) => Transfer.toJSON(e));
12666
12545
  }
12667
12546
  if ((_b = message.routes) === null || _b === void 0 ? void 0 : _b.length) {
12668
- obj.routes = message.routes;
12547
+ obj.routes = message.routes.map((e) => Math.round(e));
12669
12548
  }
12670
12549
  return obj;
12671
12550
  },
@@ -12681,12 +12560,12 @@ const StopsAdjacency_StopAdjacency = {
12681
12560
  },
12682
12561
  };
12683
12562
  function createBaseStopsAdjacency_StopsEntry() {
12684
- return { key: "", value: undefined };
12563
+ return { key: 0, value: undefined };
12685
12564
  }
12686
12565
  const StopsAdjacency_StopsEntry = {
12687
12566
  encode(message, writer = new BinaryWriter()) {
12688
- if (message.key !== "") {
12689
- writer.uint32(10).string(message.key);
12567
+ if (message.key !== 0) {
12568
+ writer.uint32(8).uint32(message.key);
12690
12569
  }
12691
12570
  if (message.value !== undefined) {
12692
12571
  StopsAdjacency_StopAdjacency.encode(message.value, writer.uint32(18).fork()).join();
@@ -12701,10 +12580,10 @@ const StopsAdjacency_StopsEntry = {
12701
12580
  const tag = reader.uint32();
12702
12581
  switch (tag >>> 3) {
12703
12582
  case 1: {
12704
- if (tag !== 10) {
12583
+ if (tag !== 8) {
12705
12584
  break;
12706
12585
  }
12707
- message.key = reader.string();
12586
+ message.key = reader.uint32();
12708
12587
  continue;
12709
12588
  }
12710
12589
  case 2: {
@@ -12724,14 +12603,14 @@ const StopsAdjacency_StopsEntry = {
12724
12603
  },
12725
12604
  fromJSON(object) {
12726
12605
  return {
12727
- key: isSet(object.key) ? globalThis.String(object.key) : "",
12606
+ key: isSet(object.key) ? globalThis.Number(object.key) : 0,
12728
12607
  value: isSet(object.value) ? StopsAdjacency_StopAdjacency.fromJSON(object.value) : undefined,
12729
12608
  };
12730
12609
  },
12731
12610
  toJSON(message) {
12732
12611
  const obj = {};
12733
- if (message.key !== "") {
12734
- obj.key = message.key;
12612
+ if (message.key !== 0) {
12613
+ obj.key = Math.round(message.key);
12735
12614
  }
12736
12615
  if (message.value !== undefined) {
12737
12616
  obj.value = StopsAdjacency_StopAdjacency.toJSON(message.value);
@@ -12744,7 +12623,7 @@ const StopsAdjacency_StopsEntry = {
12744
12623
  fromPartial(object) {
12745
12624
  var _a;
12746
12625
  const message = createBaseStopsAdjacency_StopsEntry();
12747
- message.key = (_a = object.key) !== null && _a !== void 0 ? _a : "";
12626
+ message.key = (_a = object.key) !== null && _a !== void 0 ? _a : 0;
12748
12627
  message.value = (object.value !== undefined && object.value !== null)
12749
12628
  ? StopsAdjacency_StopAdjacency.fromPartial(object.value)
12750
12629
  : undefined;
@@ -12752,7 +12631,7 @@ const StopsAdjacency_StopsEntry = {
12752
12631
  },
12753
12632
  };
12754
12633
  function createBaseServiceRoute() {
12755
- return { type: 0, name: "" };
12634
+ return { type: 0, name: "", routes: [] };
12756
12635
  }
12757
12636
  const ServiceRoute = {
12758
12637
  encode(message, writer = new BinaryWriter()) {
@@ -12762,6 +12641,11 @@ const ServiceRoute = {
12762
12641
  if (message.name !== "") {
12763
12642
  writer.uint32(18).string(message.name);
12764
12643
  }
12644
+ writer.uint32(26).fork();
12645
+ for (const v of message.routes) {
12646
+ writer.int32(v);
12647
+ }
12648
+ writer.join();
12765
12649
  return writer;
12766
12650
  },
12767
12651
  decode(input, length) {
@@ -12785,6 +12669,20 @@ const ServiceRoute = {
12785
12669
  message.name = reader.string();
12786
12670
  continue;
12787
12671
  }
12672
+ case 3: {
12673
+ if (tag === 24) {
12674
+ message.routes.push(reader.int32());
12675
+ continue;
12676
+ }
12677
+ if (tag === 26) {
12678
+ const end2 = reader.uint32() + reader.pos;
12679
+ while (reader.pos < end2) {
12680
+ message.routes.push(reader.int32());
12681
+ }
12682
+ continue;
12683
+ }
12684
+ break;
12685
+ }
12788
12686
  }
12789
12687
  if ((tag & 7) === 4 || tag === 0) {
12790
12688
  break;
@@ -12797,9 +12695,11 @@ const ServiceRoute = {
12797
12695
  return {
12798
12696
  type: isSet(object.type) ? routeTypeFromJSON(object.type) : 0,
12799
12697
  name: isSet(object.name) ? globalThis.String(object.name) : "",
12698
+ routes: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.routes) ? object.routes.map((e) => globalThis.Number(e)) : [],
12800
12699
  };
12801
12700
  },
12802
12701
  toJSON(message) {
12702
+ var _a;
12803
12703
  const obj = {};
12804
12704
  if (message.type !== 0) {
12805
12705
  obj.type = routeTypeToJSON(message.type);
@@ -12807,16 +12707,20 @@ const ServiceRoute = {
12807
12707
  if (message.name !== "") {
12808
12708
  obj.name = message.name;
12809
12709
  }
12710
+ if ((_a = message.routes) === null || _a === void 0 ? void 0 : _a.length) {
12711
+ obj.routes = message.routes.map((e) => Math.round(e));
12712
+ }
12810
12713
  return obj;
12811
12714
  },
12812
12715
  create(base) {
12813
12716
  return ServiceRoute.fromPartial(base !== null && base !== void 0 ? base : {});
12814
12717
  },
12815
12718
  fromPartial(object) {
12816
- var _a, _b;
12719
+ var _a, _b, _c;
12817
12720
  const message = createBaseServiceRoute();
12818
12721
  message.type = (_a = object.type) !== null && _a !== void 0 ? _a : 0;
12819
12722
  message.name = (_b = object.name) !== null && _b !== void 0 ? _b : "";
12723
+ message.routes = ((_c = object.routes) === null || _c === void 0 ? void 0 : _c.map((e) => e)) || [];
12820
12724
  return message;
12821
12725
  },
12822
12726
  };
@@ -12965,7 +12869,7 @@ const ServiceRoutesMap_RoutesEntry = {
12965
12869
  },
12966
12870
  };
12967
12871
  function createBaseTimetable() {
12968
- return { version: "", stopsAdjacency: undefined, routesAdjacency: undefined, routes: undefined };
12872
+ return { version: "", stopsAdjacency: undefined, routesAdjacency: [], routes: undefined };
12969
12873
  }
12970
12874
  const Timetable$1 = {
12971
12875
  encode(message, writer = new BinaryWriter()) {
@@ -12975,8 +12879,8 @@ const Timetable$1 = {
12975
12879
  if (message.stopsAdjacency !== undefined) {
12976
12880
  StopsAdjacency.encode(message.stopsAdjacency, writer.uint32(18).fork()).join();
12977
12881
  }
12978
- if (message.routesAdjacency !== undefined) {
12979
- RoutesAdjacency.encode(message.routesAdjacency, writer.uint32(26).fork()).join();
12882
+ for (const v of message.routesAdjacency) {
12883
+ Route$1.encode(v, writer.uint32(26).fork()).join();
12980
12884
  }
12981
12885
  if (message.routes !== undefined) {
12982
12886
  ServiceRoutesMap.encode(message.routes, writer.uint32(34).fork()).join();
@@ -13008,7 +12912,7 @@ const Timetable$1 = {
13008
12912
  if (tag !== 26) {
13009
12913
  break;
13010
12914
  }
13011
- message.routesAdjacency = RoutesAdjacency.decode(reader, reader.uint32());
12915
+ message.routesAdjacency.push(Route$1.decode(reader, reader.uint32()));
13012
12916
  continue;
13013
12917
  }
13014
12918
  case 4: {
@@ -13030,11 +12934,14 @@ const Timetable$1 = {
13030
12934
  return {
13031
12935
  version: isSet(object.version) ? globalThis.String(object.version) : "",
13032
12936
  stopsAdjacency: isSet(object.stopsAdjacency) ? StopsAdjacency.fromJSON(object.stopsAdjacency) : undefined,
13033
- routesAdjacency: isSet(object.routesAdjacency) ? RoutesAdjacency.fromJSON(object.routesAdjacency) : undefined,
12937
+ routesAdjacency: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.routesAdjacency)
12938
+ ? object.routesAdjacency.map((e) => Route$1.fromJSON(e))
12939
+ : [],
13034
12940
  routes: isSet(object.routes) ? ServiceRoutesMap.fromJSON(object.routes) : undefined,
13035
12941
  };
13036
12942
  },
13037
12943
  toJSON(message) {
12944
+ var _a;
13038
12945
  const obj = {};
13039
12946
  if (message.version !== "") {
13040
12947
  obj.version = message.version;
@@ -13042,8 +12949,8 @@ const Timetable$1 = {
13042
12949
  if (message.stopsAdjacency !== undefined) {
13043
12950
  obj.stopsAdjacency = StopsAdjacency.toJSON(message.stopsAdjacency);
13044
12951
  }
13045
- if (message.routesAdjacency !== undefined) {
13046
- obj.routesAdjacency = RoutesAdjacency.toJSON(message.routesAdjacency);
12952
+ if ((_a = message.routesAdjacency) === null || _a === void 0 ? void 0 : _a.length) {
12953
+ obj.routesAdjacency = message.routesAdjacency.map((e) => Route$1.toJSON(e));
13047
12954
  }
13048
12955
  if (message.routes !== undefined) {
13049
12956
  obj.routes = ServiceRoutesMap.toJSON(message.routes);
@@ -13054,15 +12961,13 @@ const Timetable$1 = {
13054
12961
  return Timetable$1.fromPartial(base !== null && base !== void 0 ? base : {});
13055
12962
  },
13056
12963
  fromPartial(object) {
13057
- var _a;
12964
+ var _a, _b;
13058
12965
  const message = createBaseTimetable();
13059
12966
  message.version = (_a = object.version) !== null && _a !== void 0 ? _a : "";
13060
12967
  message.stopsAdjacency = (object.stopsAdjacency !== undefined && object.stopsAdjacency !== null)
13061
12968
  ? StopsAdjacency.fromPartial(object.stopsAdjacency)
13062
12969
  : undefined;
13063
- message.routesAdjacency = (object.routesAdjacency !== undefined && object.routesAdjacency !== null)
13064
- ? RoutesAdjacency.fromPartial(object.routesAdjacency)
13065
- : undefined;
12970
+ message.routesAdjacency = ((_b = object.routesAdjacency) === null || _b === void 0 ? void 0 : _b.map((e) => Route$1.fromPartial(e))) || [];
13066
12971
  message.routes = (object.routes !== undefined && object.routes !== null)
13067
12972
  ? ServiceRoutesMap.fromPartial(object.routes)
13068
12973
  : undefined;
@@ -13626,17 +13531,15 @@ const serializeStopsAdjacency = (stopsAdjacency) => {
13626
13531
  return protoStopsAdjacency;
13627
13532
  };
13628
13533
  const serializeRoutesAdjacency = (routesAdjacency) => {
13629
- const protoRoutesAdjacency = {
13630
- routes: {},
13631
- };
13632
- routesAdjacency.forEach((route, key) => {
13534
+ const protoRoutesAdjacency = [];
13535
+ routesAdjacency.forEach((route) => {
13633
13536
  const routeData = route.serialize();
13634
- protoRoutesAdjacency.routes[key] = {
13537
+ protoRoutesAdjacency.push({
13635
13538
  stopTimes: uint16ArrayToBytes(routeData.stopTimes),
13636
13539
  pickUpDropOffTypes: routeData.pickUpDropOffTypes,
13637
13540
  stops: uint32ArrayToBytes(routeData.stops),
13638
13541
  serviceRouteId: routeData.serviceRouteId,
13639
- };
13542
+ });
13640
13543
  });
13641
13544
  return protoRoutesAdjacency;
13642
13545
  };
@@ -13648,6 +13551,7 @@ const serializeServiceRoutesMap = (serviceRoutesMap) => {
13648
13551
  protoServiceRoutesMap.routes[key] = {
13649
13552
  type: serializeRouteType(value.type),
13650
13553
  name: value.name,
13554
+ routes: value.routes,
13651
13555
  };
13652
13556
  });
13653
13557
  return protoServiceRoutesMap;
@@ -13666,10 +13570,10 @@ const deserializeStopsAdjacency = (protoStopsAdjacency) => {
13666
13570
  return stopsAdjacency;
13667
13571
  };
13668
13572
  const deserializeRoutesAdjacency = (protoRoutesAdjacency) => {
13669
- const routesAdjacency = new Map();
13670
- Object.entries(protoRoutesAdjacency.routes).forEach(([key, value]) => {
13573
+ const routesAdjacency = [];
13574
+ protoRoutesAdjacency.forEach((value) => {
13671
13575
  const stops = bytesToUint32Array(value.stops);
13672
- routesAdjacency.set(key, new Route(bytesToUint16Array(value.stopTimes), value.pickUpDropOffTypes, stops, value.serviceRouteId));
13576
+ routesAdjacency.push(new Route(bytesToUint16Array(value.stopTimes), value.pickUpDropOffTypes, stops, value.serviceRouteId));
13673
13577
  });
13674
13578
  return routesAdjacency;
13675
13579
  };
@@ -13679,6 +13583,7 @@ const deserializeServiceRoutesMap = (protoServiceRoutesMap) => {
13679
13583
  serviceRoutesMap.set(key, {
13680
13584
  type: parseRouteType(value.type),
13681
13585
  name: value.name,
13586
+ routes: value.routes,
13682
13587
  });
13683
13588
  });
13684
13589
  return serviceRoutesMap;
@@ -13773,7 +13678,7 @@ const ALL_TRANSPORT_MODES = new Set([
13773
13678
  'TROLLEYBUS',
13774
13679
  'MONORAIL',
13775
13680
  ]);
13776
- const CURRENT_VERSION = '0.0.4';
13681
+ const CURRENT_VERSION = '0.0.5';
13777
13682
  /**
13778
13683
  * The internal transit timetable format.
13779
13684
  */
@@ -13813,9 +13718,7 @@ class Timetable {
13813
13718
  }
13814
13719
  return new Timetable(
13815
13720
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
13816
- deserializeStopsAdjacency(protoTimetable.stopsAdjacency), deserializeRoutesAdjacency(
13817
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
13818
- protoTimetable.routesAdjacency),
13721
+ deserializeStopsAdjacency(protoTimetable.stopsAdjacency), deserializeRoutesAdjacency(protoTimetable.routesAdjacency),
13819
13722
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
13820
13723
  deserializeServiceRoutesMap(protoTimetable.routes));
13821
13724
  }
@@ -13827,7 +13730,7 @@ class Timetable {
13827
13730
  * or undefined if no such route exists.
13828
13731
  */
13829
13732
  getRoute(routeId) {
13830
- return this.routesAdjacency.get(routeId);
13733
+ return this.routesAdjacency[routeId];
13831
13734
  }
13832
13735
  /**
13833
13736
  * Retrieves all transfer options available at the specified stop.
@@ -13847,9 +13750,14 @@ class Timetable {
13847
13750
  * @param route - The route for which the service route is to be retrieved.
13848
13751
  * @returns The service route corresponding to the provided route.
13849
13752
  */
13850
- getServiceRoute(route) {
13851
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
13852
- return this.routes.get(route.serviceRoute());
13753
+ getServiceRouteInfo(route) {
13754
+ const serviceRoute = this.routes.get(route.serviceRoute());
13755
+ if (!serviceRoute) {
13756
+ throw new Error(`Service route not found for route ID: ${route.serviceRoute()}`);
13757
+ }
13758
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
13759
+ const { routes } = serviceRoute, serviceRouteInfo = __rest(serviceRoute, ["routes"]);
13760
+ return serviceRouteInfo;
13853
13761
  }
13854
13762
  /**
13855
13763
  * Finds all routes passing through a stop.
@@ -13864,7 +13772,7 @@ class Timetable {
13864
13772
  }
13865
13773
  const routes = [];
13866
13774
  for (const routeId of stopData.routes) {
13867
- const route = this.routesAdjacency.get(routeId);
13775
+ const route = this.routesAdjacency[routeId];
13868
13776
  if (route) {
13869
13777
  routes.push(route);
13870
13778
  }
@@ -13884,7 +13792,7 @@ class Timetable {
13884
13792
  const reachableRoutes = new Map();
13885
13793
  for (const originStop of fromStops) {
13886
13794
  const validRoutes = this.routesPassingThrough(originStop).filter((route) => {
13887
- const serviceRoute = this.getServiceRoute(route);
13795
+ const serviceRoute = this.getServiceRouteInfo(route);
13888
13796
  return transportModes.has(serviceRoute.type);
13889
13797
  });
13890
13798
  for (const route of validRoutes) {
@@ -15895,6 +15803,7 @@ const parseRoutes = (routesStream_1, ...args_1) => __awaiter(void 0, [routesStre
15895
15803
  routes.set(line.route_id, {
15896
15804
  name: line.route_short_name,
15897
15805
  type: routeType,
15806
+ routes: [],
15898
15807
  });
15899
15808
  }
15900
15809
  }
@@ -16289,10 +16198,10 @@ const finalizeRouteFromBuilder = (builder) => {
16289
16198
  *
16290
16199
  * @param tripsStream The readable stream containing the trips data.
16291
16200
  * @param serviceIds A mapping of service IDs to corresponding route IDs.
16292
- * @param routeIds A mapping of route IDs to route details.
16201
+ * @param serviceRoutes A mapping of route IDs to route details.
16293
16202
  * @returns A mapping of trip IDs to corresponding route IDs.
16294
16203
  */
16295
- const parseTrips = (tripsStream, serviceIds, routeIds) => __awaiter(void 0, void 0, void 0, function* () {
16204
+ const parseTrips = (tripsStream, serviceIds, serviceRoutes) => __awaiter(void 0, void 0, void 0, function* () {
16296
16205
  var _a, e_1, _b, _c;
16297
16206
  const trips = new Map();
16298
16207
  try {
@@ -16305,7 +16214,7 @@ const parseTrips = (tripsStream, serviceIds, routeIds) => __awaiter(void 0, void
16305
16214
  // The trip doesn't correspond to an active service
16306
16215
  continue;
16307
16216
  }
16308
- if (!routeIds.get(line.route_id)) {
16217
+ if (!serviceRoutes.get(line.route_id)) {
16309
16218
  // The trip doesn't correspond to a supported route
16310
16219
  continue;
16311
16220
  }
@@ -16321,21 +16230,22 @@ const parseTrips = (tripsStream, serviceIds, routeIds) => __awaiter(void 0, void
16321
16230
  }
16322
16231
  return trips;
16323
16232
  });
16324
- const buildStopsAdjacencyStructure = (validStops, routes, transfersMap) => {
16325
- var _a;
16233
+ const buildStopsAdjacencyStructure = (validStops, serviceRoutes, routes, transfersMap) => {
16326
16234
  const stopsAdjacency = new Map();
16327
- for (const routeId of routes.keys()) {
16328
- const route = routes.get(routeId);
16329
- if (!route) {
16330
- throw new Error(`Route ${routeId} not found`);
16331
- }
16235
+ routes.forEach((route, index) => {
16236
+ var _a;
16332
16237
  for (const stop of route.stopsIterator()) {
16333
16238
  if (!stopsAdjacency.get(stop) && validStops.has(stop)) {
16334
16239
  stopsAdjacency.set(stop, { routes: [], transfers: [] });
16335
16240
  }
16336
- (_a = stopsAdjacency.get(stop)) === null || _a === void 0 ? void 0 : _a.routes.push(routeId);
16241
+ (_a = stopsAdjacency.get(stop)) === null || _a === void 0 ? void 0 : _a.routes.push(index);
16337
16242
  }
16338
- }
16243
+ const serviceRoute = serviceRoutes.get(route.serviceRoute());
16244
+ if (!serviceRoute) {
16245
+ throw new Error(`Service route ${route.serviceRoute()} not found for route ${index}.`);
16246
+ }
16247
+ serviceRoute.routes.push(index);
16248
+ });
16339
16249
  for (const [stop, transfers] of transfersMap) {
16340
16250
  const s = stopsAdjacency.get(stop);
16341
16251
  if (s) {
@@ -16467,10 +16377,10 @@ const parseStopTimes = (stopTimesStream, stopsMap, validTripIds, validStopIds) =
16467
16377
  if (currentTripId) {
16468
16378
  addTrip(currentTripId);
16469
16379
  }
16470
- const routesAdjacency = new Map();
16471
- for (const [routeId, routeBuilder] of routeBuilders) {
16380
+ const routesAdjacency = [];
16381
+ for (const [, routeBuilder] of routeBuilders) {
16472
16382
  const routeData = finalizeRouteFromBuilder(routeBuilder);
16473
- routesAdjacency.set(routeId, new Route(routeData.stopTimes, routeData.pickUpDropOffTypes, routeData.stops, routeData.serviceRouteId));
16383
+ routesAdjacency.push(new Route(routeData.stopTimes, routeData.pickUpDropOffTypes, routeData.stops, routeData.serviceRouteId));
16474
16384
  }
16475
16385
  return routesAdjacency;
16476
16386
  });
@@ -16565,9 +16475,9 @@ class GtfsParser {
16565
16475
  const stopTimesStart = performance.now();
16566
16476
  const stopTimesStream = yield zip.stream(STOP_TIMES_FILE);
16567
16477
  const routesAdjacency = yield parseStopTimes(stopTimesStream, parsedStops, trips, validStopIds);
16568
- const stopsAdjacency = buildStopsAdjacencyStructure(validStopIds, routesAdjacency, transfers);
16478
+ const stopsAdjacency = buildStopsAdjacencyStructure(validStopIds, validGtfsRoutes, routesAdjacency, transfers);
16569
16479
  const stopTimesEnd = performance.now();
16570
- log.info(`${routesAdjacency.size} valid unique routes. (${(stopTimesEnd - stopTimesStart).toFixed(2)}ms)`);
16480
+ log.info(`${routesAdjacency.length} valid unique routes. (${(stopTimesEnd - stopTimesStart).toFixed(2)}ms)`);
16571
16481
  log.info(`Removing unused stops.`);
16572
16482
  const indexStopsStart = performance.now();
16573
16483
  const stops = indexStops(parsedStops, validStopIds);