minotor 4.0.0 → 5.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +3 -8
  2. package/dist/cli.mjs +128 -249
  3. package/dist/cli.mjs.map +1 -1
  4. package/dist/gtfs/parser.d.ts +0 -3
  5. package/dist/gtfs/stops.d.ts +1 -2
  6. package/dist/gtfs/trips.d.ts +6 -5
  7. package/dist/parser.cjs.js +127 -248
  8. package/dist/parser.cjs.js.map +1 -1
  9. package/dist/parser.esm.js +127 -248
  10. package/dist/parser.esm.js.map +1 -1
  11. package/dist/router.cjs.js +1 -1
  12. package/dist/router.cjs.js.map +1 -1
  13. package/dist/router.d.ts +2 -2
  14. package/dist/router.esm.js +1 -1
  15. package/dist/router.esm.js.map +1 -1
  16. package/dist/router.umd.js +1 -1
  17. package/dist/router.umd.js.map +1 -1
  18. package/dist/routing/route.d.ts +3 -3
  19. package/dist/timetable/io.d.ts +5 -4
  20. package/dist/timetable/proto/timetable.d.ts +5 -15
  21. package/dist/timetable/route.d.ts +1 -1
  22. package/dist/timetable/timetable.d.ts +7 -5
  23. package/package.json +1 -1
  24. package/src/__e2e__/timetable/stops.bin +2 -2
  25. package/src/__e2e__/timetable/timetable.bin +2 -2
  26. package/src/gtfs/__tests__/parser.test.ts +2 -2
  27. package/src/gtfs/__tests__/routes.test.ts +3 -0
  28. package/src/gtfs/__tests__/stops.test.ts +6 -13
  29. package/src/gtfs/__tests__/trips.test.ts +122 -154
  30. package/src/gtfs/parser.ts +6 -11
  31. package/src/gtfs/profiles/__tests__/ch.test.ts +0 -28
  32. package/src/gtfs/profiles/ch.ts +1 -18
  33. package/src/gtfs/profiles/standard.ts +0 -9
  34. package/src/gtfs/routes.ts +1 -0
  35. package/src/gtfs/stops.ts +2 -12
  36. package/src/gtfs/trips.ts +21 -19
  37. package/src/router.ts +2 -2
  38. package/src/routing/__tests__/route.test.ts +3 -3
  39. package/src/routing/__tests__/router.test.ts +186 -203
  40. package/src/routing/route.ts +3 -3
  41. package/src/routing/router.ts +1 -1
  42. package/src/timetable/__tests__/io.test.ts +52 -64
  43. package/src/timetable/__tests__/timetable.test.ts +9 -13
  44. package/src/timetable/io.ts +20 -19
  45. package/src/timetable/proto/timetable.proto +5 -8
  46. package/src/timetable/proto/timetable.ts +78 -201
  47. package/src/timetable/route.ts +1 -1
  48. package/src/timetable/timetable.ts +20 -16
@@ -24,6 +24,18 @@ PERFORMANCE OF THIS SOFTWARE.
24
24
  /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
25
25
 
26
26
 
27
+ function __rest(s, e) {
28
+ var t = {};
29
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
30
+ t[p] = s[p];
31
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
32
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
33
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
34
+ t[p[i]] = s[p[i]];
35
+ }
36
+ return t;
37
+ }
38
+
27
39
  function __awaiter(thisArg, _arguments, P, generator) {
28
40
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
29
41
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -12311,148 +12323,6 @@ const Route$1 = {
12311
12323
  return message;
12312
12324
  },
12313
12325
  };
12314
- function createBaseRoutesAdjacency() {
12315
- return { routes: {} };
12316
- }
12317
- const RoutesAdjacency = {
12318
- encode(message, writer = new BinaryWriter()) {
12319
- Object.entries(message.routes).forEach(([key, value]) => {
12320
- RoutesAdjacency_RoutesEntry.encode({ key: key, value }, writer.uint32(10).fork()).join();
12321
- });
12322
- return writer;
12323
- },
12324
- decode(input, length) {
12325
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
12326
- const end = length === undefined ? reader.len : reader.pos + length;
12327
- const message = createBaseRoutesAdjacency();
12328
- while (reader.pos < end) {
12329
- const tag = reader.uint32();
12330
- switch (tag >>> 3) {
12331
- case 1: {
12332
- if (tag !== 10) {
12333
- break;
12334
- }
12335
- const entry1 = RoutesAdjacency_RoutesEntry.decode(reader, reader.uint32());
12336
- if (entry1.value !== undefined) {
12337
- message.routes[entry1.key] = entry1.value;
12338
- }
12339
- continue;
12340
- }
12341
- }
12342
- if ((tag & 7) === 4 || tag === 0) {
12343
- break;
12344
- }
12345
- reader.skip(tag & 7);
12346
- }
12347
- return message;
12348
- },
12349
- fromJSON(object) {
12350
- return {
12351
- routes: isObject(object.routes)
12352
- ? Object.entries(object.routes).reduce((acc, [key, value]) => {
12353
- acc[key] = Route$1.fromJSON(value);
12354
- return acc;
12355
- }, {})
12356
- : {},
12357
- };
12358
- },
12359
- toJSON(message) {
12360
- const obj = {};
12361
- if (message.routes) {
12362
- const entries = Object.entries(message.routes);
12363
- if (entries.length > 0) {
12364
- obj.routes = {};
12365
- entries.forEach(([k, v]) => {
12366
- obj.routes[k] = Route$1.toJSON(v);
12367
- });
12368
- }
12369
- }
12370
- return obj;
12371
- },
12372
- create(base) {
12373
- return RoutesAdjacency.fromPartial(base !== null && base !== void 0 ? base : {});
12374
- },
12375
- fromPartial(object) {
12376
- var _a;
12377
- const message = createBaseRoutesAdjacency();
12378
- message.routes = Object.entries((_a = object.routes) !== null && _a !== void 0 ? _a : {}).reduce((acc, [key, value]) => {
12379
- if (value !== undefined) {
12380
- acc[key] = Route$1.fromPartial(value);
12381
- }
12382
- return acc;
12383
- }, {});
12384
- return message;
12385
- },
12386
- };
12387
- function createBaseRoutesAdjacency_RoutesEntry() {
12388
- return { key: "", value: undefined };
12389
- }
12390
- const RoutesAdjacency_RoutesEntry = {
12391
- encode(message, writer = new BinaryWriter()) {
12392
- if (message.key !== "") {
12393
- writer.uint32(10).string(message.key);
12394
- }
12395
- if (message.value !== undefined) {
12396
- Route$1.encode(message.value, writer.uint32(18).fork()).join();
12397
- }
12398
- return writer;
12399
- },
12400
- decode(input, length) {
12401
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
12402
- const end = length === undefined ? reader.len : reader.pos + length;
12403
- const message = createBaseRoutesAdjacency_RoutesEntry();
12404
- while (reader.pos < end) {
12405
- const tag = reader.uint32();
12406
- switch (tag >>> 3) {
12407
- case 1: {
12408
- if (tag !== 10) {
12409
- break;
12410
- }
12411
- message.key = reader.string();
12412
- continue;
12413
- }
12414
- case 2: {
12415
- if (tag !== 18) {
12416
- break;
12417
- }
12418
- message.value = Route$1.decode(reader, reader.uint32());
12419
- continue;
12420
- }
12421
- }
12422
- if ((tag & 7) === 4 || tag === 0) {
12423
- break;
12424
- }
12425
- reader.skip(tag & 7);
12426
- }
12427
- return message;
12428
- },
12429
- fromJSON(object) {
12430
- return {
12431
- key: isSet(object.key) ? globalThis.String(object.key) : "",
12432
- value: isSet(object.value) ? Route$1.fromJSON(object.value) : undefined,
12433
- };
12434
- },
12435
- toJSON(message) {
12436
- const obj = {};
12437
- if (message.key !== "") {
12438
- obj.key = message.key;
12439
- }
12440
- if (message.value !== undefined) {
12441
- obj.value = Route$1.toJSON(message.value);
12442
- }
12443
- return obj;
12444
- },
12445
- create(base) {
12446
- return RoutesAdjacency_RoutesEntry.fromPartial(base !== null && base !== void 0 ? base : {});
12447
- },
12448
- fromPartial(object) {
12449
- var _a;
12450
- const message = createBaseRoutesAdjacency_RoutesEntry();
12451
- message.key = (_a = object.key) !== null && _a !== void 0 ? _a : "";
12452
- message.value = (object.value !== undefined && object.value !== null) ? Route$1.fromPartial(object.value) : undefined;
12453
- return message;
12454
- },
12455
- };
12456
12326
  function createBaseTransfer() {
12457
12327
  return { destination: 0, type: 0, minTransferTime: undefined };
12458
12328
  }
@@ -12465,7 +12335,7 @@ const Transfer = {
12465
12335
  writer.uint32(16).int32(message.type);
12466
12336
  }
12467
12337
  if (message.minTransferTime !== undefined) {
12468
- writer.uint32(24).int32(message.minTransferTime);
12338
+ writer.uint32(24).uint32(message.minTransferTime);
12469
12339
  }
12470
12340
  return writer;
12471
12341
  },
@@ -12494,7 +12364,7 @@ const Transfer = {
12494
12364
  if (tag !== 24) {
12495
12365
  break;
12496
12366
  }
12497
- message.minTransferTime = reader.int32();
12367
+ message.minTransferTime = reader.uint32();
12498
12368
  continue;
12499
12369
  }
12500
12370
  }
@@ -12576,7 +12446,7 @@ const StopsAdjacency = {
12576
12446
  return {
12577
12447
  stops: isObject(object.stops)
12578
12448
  ? Object.entries(object.stops).reduce((acc, [key, value]) => {
12579
- acc[key] = StopsAdjacency_StopAdjacency.fromJSON(value);
12449
+ acc[globalThis.Number(key)] = StopsAdjacency_StopAdjacency.fromJSON(value);
12580
12450
  return acc;
12581
12451
  }, {})
12582
12452
  : {},
@@ -12603,7 +12473,7 @@ const StopsAdjacency = {
12603
12473
  const message = createBaseStopsAdjacency();
12604
12474
  message.stops = Object.entries((_a = object.stops) !== null && _a !== void 0 ? _a : {}).reduce((acc, [key, value]) => {
12605
12475
  if (value !== undefined) {
12606
- acc[key] = StopsAdjacency_StopAdjacency.fromPartial(value);
12476
+ acc[globalThis.Number(key)] = StopsAdjacency_StopAdjacency.fromPartial(value);
12607
12477
  }
12608
12478
  return acc;
12609
12479
  }, {});
@@ -12618,9 +12488,11 @@ const StopsAdjacency_StopAdjacency = {
12618
12488
  for (const v of message.transfers) {
12619
12489
  Transfer.encode(v, writer.uint32(10).fork()).join();
12620
12490
  }
12491
+ writer.uint32(18).fork();
12621
12492
  for (const v of message.routes) {
12622
- writer.uint32(18).string(v);
12493
+ writer.int32(v);
12623
12494
  }
12495
+ writer.join();
12624
12496
  return writer;
12625
12497
  },
12626
12498
  decode(input, length) {
@@ -12638,11 +12510,18 @@ const StopsAdjacency_StopAdjacency = {
12638
12510
  continue;
12639
12511
  }
12640
12512
  case 2: {
12641
- if (tag !== 18) {
12642
- break;
12513
+ if (tag === 16) {
12514
+ message.routes.push(reader.int32());
12515
+ continue;
12643
12516
  }
12644
- message.routes.push(reader.string());
12645
- continue;
12517
+ if (tag === 18) {
12518
+ const end2 = reader.uint32() + reader.pos;
12519
+ while (reader.pos < end2) {
12520
+ message.routes.push(reader.int32());
12521
+ }
12522
+ continue;
12523
+ }
12524
+ break;
12646
12525
  }
12647
12526
  }
12648
12527
  if ((tag & 7) === 4 || tag === 0) {
@@ -12657,7 +12536,7 @@ const StopsAdjacency_StopAdjacency = {
12657
12536
  transfers: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.transfers)
12658
12537
  ? object.transfers.map((e) => Transfer.fromJSON(e))
12659
12538
  : [],
12660
- routes: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.routes) ? object.routes.map((e) => globalThis.String(e)) : [],
12539
+ routes: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.routes) ? object.routes.map((e) => globalThis.Number(e)) : [],
12661
12540
  };
12662
12541
  },
12663
12542
  toJSON(message) {
@@ -12667,7 +12546,7 @@ const StopsAdjacency_StopAdjacency = {
12667
12546
  obj.transfers = message.transfers.map((e) => Transfer.toJSON(e));
12668
12547
  }
12669
12548
  if ((_b = message.routes) === null || _b === void 0 ? void 0 : _b.length) {
12670
- obj.routes = message.routes;
12549
+ obj.routes = message.routes.map((e) => Math.round(e));
12671
12550
  }
12672
12551
  return obj;
12673
12552
  },
@@ -12683,12 +12562,12 @@ const StopsAdjacency_StopAdjacency = {
12683
12562
  },
12684
12563
  };
12685
12564
  function createBaseStopsAdjacency_StopsEntry() {
12686
- return { key: "", value: undefined };
12565
+ return { key: 0, value: undefined };
12687
12566
  }
12688
12567
  const StopsAdjacency_StopsEntry = {
12689
12568
  encode(message, writer = new BinaryWriter()) {
12690
- if (message.key !== "") {
12691
- writer.uint32(10).string(message.key);
12569
+ if (message.key !== 0) {
12570
+ writer.uint32(8).uint32(message.key);
12692
12571
  }
12693
12572
  if (message.value !== undefined) {
12694
12573
  StopsAdjacency_StopAdjacency.encode(message.value, writer.uint32(18).fork()).join();
@@ -12703,10 +12582,10 @@ const StopsAdjacency_StopsEntry = {
12703
12582
  const tag = reader.uint32();
12704
12583
  switch (tag >>> 3) {
12705
12584
  case 1: {
12706
- if (tag !== 10) {
12585
+ if (tag !== 8) {
12707
12586
  break;
12708
12587
  }
12709
- message.key = reader.string();
12588
+ message.key = reader.uint32();
12710
12589
  continue;
12711
12590
  }
12712
12591
  case 2: {
@@ -12726,14 +12605,14 @@ const StopsAdjacency_StopsEntry = {
12726
12605
  },
12727
12606
  fromJSON(object) {
12728
12607
  return {
12729
- key: isSet(object.key) ? globalThis.String(object.key) : "",
12608
+ key: isSet(object.key) ? globalThis.Number(object.key) : 0,
12730
12609
  value: isSet(object.value) ? StopsAdjacency_StopAdjacency.fromJSON(object.value) : undefined,
12731
12610
  };
12732
12611
  },
12733
12612
  toJSON(message) {
12734
12613
  const obj = {};
12735
- if (message.key !== "") {
12736
- obj.key = message.key;
12614
+ if (message.key !== 0) {
12615
+ obj.key = Math.round(message.key);
12737
12616
  }
12738
12617
  if (message.value !== undefined) {
12739
12618
  obj.value = StopsAdjacency_StopAdjacency.toJSON(message.value);
@@ -12746,7 +12625,7 @@ const StopsAdjacency_StopsEntry = {
12746
12625
  fromPartial(object) {
12747
12626
  var _a;
12748
12627
  const message = createBaseStopsAdjacency_StopsEntry();
12749
- message.key = (_a = object.key) !== null && _a !== void 0 ? _a : "";
12628
+ message.key = (_a = object.key) !== null && _a !== void 0 ? _a : 0;
12750
12629
  message.value = (object.value !== undefined && object.value !== null)
12751
12630
  ? StopsAdjacency_StopAdjacency.fromPartial(object.value)
12752
12631
  : undefined;
@@ -12754,7 +12633,7 @@ const StopsAdjacency_StopsEntry = {
12754
12633
  },
12755
12634
  };
12756
12635
  function createBaseServiceRoute() {
12757
- return { type: 0, name: "" };
12636
+ return { type: 0, name: "", routes: [] };
12758
12637
  }
12759
12638
  const ServiceRoute = {
12760
12639
  encode(message, writer = new BinaryWriter()) {
@@ -12764,6 +12643,11 @@ const ServiceRoute = {
12764
12643
  if (message.name !== "") {
12765
12644
  writer.uint32(18).string(message.name);
12766
12645
  }
12646
+ writer.uint32(26).fork();
12647
+ for (const v of message.routes) {
12648
+ writer.int32(v);
12649
+ }
12650
+ writer.join();
12767
12651
  return writer;
12768
12652
  },
12769
12653
  decode(input, length) {
@@ -12787,6 +12671,20 @@ const ServiceRoute = {
12787
12671
  message.name = reader.string();
12788
12672
  continue;
12789
12673
  }
12674
+ case 3: {
12675
+ if (tag === 24) {
12676
+ message.routes.push(reader.int32());
12677
+ continue;
12678
+ }
12679
+ if (tag === 26) {
12680
+ const end2 = reader.uint32() + reader.pos;
12681
+ while (reader.pos < end2) {
12682
+ message.routes.push(reader.int32());
12683
+ }
12684
+ continue;
12685
+ }
12686
+ break;
12687
+ }
12790
12688
  }
12791
12689
  if ((tag & 7) === 4 || tag === 0) {
12792
12690
  break;
@@ -12799,9 +12697,11 @@ const ServiceRoute = {
12799
12697
  return {
12800
12698
  type: isSet(object.type) ? routeTypeFromJSON(object.type) : 0,
12801
12699
  name: isSet(object.name) ? globalThis.String(object.name) : "",
12700
+ routes: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.routes) ? object.routes.map((e) => globalThis.Number(e)) : [],
12802
12701
  };
12803
12702
  },
12804
12703
  toJSON(message) {
12704
+ var _a;
12805
12705
  const obj = {};
12806
12706
  if (message.type !== 0) {
12807
12707
  obj.type = routeTypeToJSON(message.type);
@@ -12809,16 +12709,20 @@ const ServiceRoute = {
12809
12709
  if (message.name !== "") {
12810
12710
  obj.name = message.name;
12811
12711
  }
12712
+ if ((_a = message.routes) === null || _a === void 0 ? void 0 : _a.length) {
12713
+ obj.routes = message.routes.map((e) => Math.round(e));
12714
+ }
12812
12715
  return obj;
12813
12716
  },
12814
12717
  create(base) {
12815
12718
  return ServiceRoute.fromPartial(base !== null && base !== void 0 ? base : {});
12816
12719
  },
12817
12720
  fromPartial(object) {
12818
- var _a, _b;
12721
+ var _a, _b, _c;
12819
12722
  const message = createBaseServiceRoute();
12820
12723
  message.type = (_a = object.type) !== null && _a !== void 0 ? _a : 0;
12821
12724
  message.name = (_b = object.name) !== null && _b !== void 0 ? _b : "";
12725
+ message.routes = ((_c = object.routes) === null || _c === void 0 ? void 0 : _c.map((e) => e)) || [];
12822
12726
  return message;
12823
12727
  },
12824
12728
  };
@@ -12967,7 +12871,7 @@ const ServiceRoutesMap_RoutesEntry = {
12967
12871
  },
12968
12872
  };
12969
12873
  function createBaseTimetable() {
12970
- return { version: "", stopsAdjacency: undefined, routesAdjacency: undefined, routes: undefined };
12874
+ return { version: "", stopsAdjacency: undefined, routesAdjacency: [], routes: undefined };
12971
12875
  }
12972
12876
  const Timetable$1 = {
12973
12877
  encode(message, writer = new BinaryWriter()) {
@@ -12977,8 +12881,8 @@ const Timetable$1 = {
12977
12881
  if (message.stopsAdjacency !== undefined) {
12978
12882
  StopsAdjacency.encode(message.stopsAdjacency, writer.uint32(18).fork()).join();
12979
12883
  }
12980
- if (message.routesAdjacency !== undefined) {
12981
- RoutesAdjacency.encode(message.routesAdjacency, writer.uint32(26).fork()).join();
12884
+ for (const v of message.routesAdjacency) {
12885
+ Route$1.encode(v, writer.uint32(26).fork()).join();
12982
12886
  }
12983
12887
  if (message.routes !== undefined) {
12984
12888
  ServiceRoutesMap.encode(message.routes, writer.uint32(34).fork()).join();
@@ -13010,7 +12914,7 @@ const Timetable$1 = {
13010
12914
  if (tag !== 26) {
13011
12915
  break;
13012
12916
  }
13013
- message.routesAdjacency = RoutesAdjacency.decode(reader, reader.uint32());
12917
+ message.routesAdjacency.push(Route$1.decode(reader, reader.uint32()));
13014
12918
  continue;
13015
12919
  }
13016
12920
  case 4: {
@@ -13032,11 +12936,14 @@ const Timetable$1 = {
13032
12936
  return {
13033
12937
  version: isSet(object.version) ? globalThis.String(object.version) : "",
13034
12938
  stopsAdjacency: isSet(object.stopsAdjacency) ? StopsAdjacency.fromJSON(object.stopsAdjacency) : undefined,
13035
- routesAdjacency: isSet(object.routesAdjacency) ? RoutesAdjacency.fromJSON(object.routesAdjacency) : undefined,
12939
+ routesAdjacency: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.routesAdjacency)
12940
+ ? object.routesAdjacency.map((e) => Route$1.fromJSON(e))
12941
+ : [],
13036
12942
  routes: isSet(object.routes) ? ServiceRoutesMap.fromJSON(object.routes) : undefined,
13037
12943
  };
13038
12944
  },
13039
12945
  toJSON(message) {
12946
+ var _a;
13040
12947
  const obj = {};
13041
12948
  if (message.version !== "") {
13042
12949
  obj.version = message.version;
@@ -13044,8 +12951,8 @@ const Timetable$1 = {
13044
12951
  if (message.stopsAdjacency !== undefined) {
13045
12952
  obj.stopsAdjacency = StopsAdjacency.toJSON(message.stopsAdjacency);
13046
12953
  }
13047
- if (message.routesAdjacency !== undefined) {
13048
- obj.routesAdjacency = RoutesAdjacency.toJSON(message.routesAdjacency);
12954
+ if ((_a = message.routesAdjacency) === null || _a === void 0 ? void 0 : _a.length) {
12955
+ obj.routesAdjacency = message.routesAdjacency.map((e) => Route$1.toJSON(e));
13049
12956
  }
13050
12957
  if (message.routes !== undefined) {
13051
12958
  obj.routes = ServiceRoutesMap.toJSON(message.routes);
@@ -13056,15 +12963,13 @@ const Timetable$1 = {
13056
12963
  return Timetable$1.fromPartial(base !== null && base !== void 0 ? base : {});
13057
12964
  },
13058
12965
  fromPartial(object) {
13059
- var _a;
12966
+ var _a, _b;
13060
12967
  const message = createBaseTimetable();
13061
12968
  message.version = (_a = object.version) !== null && _a !== void 0 ? _a : "";
13062
12969
  message.stopsAdjacency = (object.stopsAdjacency !== undefined && object.stopsAdjacency !== null)
13063
12970
  ? StopsAdjacency.fromPartial(object.stopsAdjacency)
13064
12971
  : undefined;
13065
- message.routesAdjacency = (object.routesAdjacency !== undefined && object.routesAdjacency !== null)
13066
- ? RoutesAdjacency.fromPartial(object.routesAdjacency)
13067
- : undefined;
12972
+ message.routesAdjacency = ((_b = object.routesAdjacency) === null || _b === void 0 ? void 0 : _b.map((e) => Route$1.fromPartial(e))) || [];
13068
12973
  message.routes = (object.routes !== undefined && object.routes !== null)
13069
12974
  ? ServiceRoutesMap.fromPartial(object.routes)
13070
12975
  : undefined;
@@ -13628,17 +13533,15 @@ const serializeStopsAdjacency = (stopsAdjacency) => {
13628
13533
  return protoStopsAdjacency;
13629
13534
  };
13630
13535
  const serializeRoutesAdjacency = (routesAdjacency) => {
13631
- const protoRoutesAdjacency = {
13632
- routes: {},
13633
- };
13634
- routesAdjacency.forEach((route, key) => {
13536
+ const protoRoutesAdjacency = [];
13537
+ routesAdjacency.forEach((route) => {
13635
13538
  const routeData = route.serialize();
13636
- protoRoutesAdjacency.routes[key] = {
13539
+ protoRoutesAdjacency.push({
13637
13540
  stopTimes: uint16ArrayToBytes(routeData.stopTimes),
13638
13541
  pickUpDropOffTypes: routeData.pickUpDropOffTypes,
13639
13542
  stops: uint32ArrayToBytes(routeData.stops),
13640
13543
  serviceRouteId: routeData.serviceRouteId,
13641
- };
13544
+ });
13642
13545
  });
13643
13546
  return protoRoutesAdjacency;
13644
13547
  };
@@ -13650,6 +13553,7 @@ const serializeServiceRoutesMap = (serviceRoutesMap) => {
13650
13553
  protoServiceRoutesMap.routes[key] = {
13651
13554
  type: serializeRouteType(value.type),
13652
13555
  name: value.name,
13556
+ routes: value.routes,
13653
13557
  };
13654
13558
  });
13655
13559
  return protoServiceRoutesMap;
@@ -13668,10 +13572,10 @@ const deserializeStopsAdjacency = (protoStopsAdjacency) => {
13668
13572
  return stopsAdjacency;
13669
13573
  };
13670
13574
  const deserializeRoutesAdjacency = (protoRoutesAdjacency) => {
13671
- const routesAdjacency = new Map();
13672
- Object.entries(protoRoutesAdjacency.routes).forEach(([key, value]) => {
13575
+ const routesAdjacency = [];
13576
+ protoRoutesAdjacency.forEach((value) => {
13673
13577
  const stops = bytesToUint32Array(value.stops);
13674
- routesAdjacency.set(key, new Route(bytesToUint16Array(value.stopTimes), value.pickUpDropOffTypes, stops, value.serviceRouteId));
13578
+ routesAdjacency.push(new Route(bytesToUint16Array(value.stopTimes), value.pickUpDropOffTypes, stops, value.serviceRouteId));
13675
13579
  });
13676
13580
  return routesAdjacency;
13677
13581
  };
@@ -13681,6 +13585,7 @@ const deserializeServiceRoutesMap = (protoServiceRoutesMap) => {
13681
13585
  serviceRoutesMap.set(key, {
13682
13586
  type: parseRouteType(value.type),
13683
13587
  name: value.name,
13588
+ routes: value.routes,
13684
13589
  });
13685
13590
  });
13686
13591
  return serviceRoutesMap;
@@ -13775,7 +13680,7 @@ const ALL_TRANSPORT_MODES = new Set([
13775
13680
  'TROLLEYBUS',
13776
13681
  'MONORAIL',
13777
13682
  ]);
13778
- const CURRENT_VERSION = '0.0.4';
13683
+ const CURRENT_VERSION = '0.0.5';
13779
13684
  /**
13780
13685
  * The internal transit timetable format.
13781
13686
  */
@@ -13815,9 +13720,7 @@ class Timetable {
13815
13720
  }
13816
13721
  return new Timetable(
13817
13722
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
13818
- deserializeStopsAdjacency(protoTimetable.stopsAdjacency), deserializeRoutesAdjacency(
13819
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
13820
- protoTimetable.routesAdjacency),
13723
+ deserializeStopsAdjacency(protoTimetable.stopsAdjacency), deserializeRoutesAdjacency(protoTimetable.routesAdjacency),
13821
13724
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
13822
13725
  deserializeServiceRoutesMap(protoTimetable.routes));
13823
13726
  }
@@ -13829,7 +13732,7 @@ class Timetable {
13829
13732
  * or undefined if no such route exists.
13830
13733
  */
13831
13734
  getRoute(routeId) {
13832
- return this.routesAdjacency.get(routeId);
13735
+ return this.routesAdjacency[routeId];
13833
13736
  }
13834
13737
  /**
13835
13738
  * Retrieves all transfer options available at the specified stop.
@@ -13849,9 +13752,14 @@ class Timetable {
13849
13752
  * @param route - The route for which the service route is to be retrieved.
13850
13753
  * @returns The service route corresponding to the provided route.
13851
13754
  */
13852
- getServiceRoute(route) {
13853
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
13854
- return this.routes.get(route.serviceRoute());
13755
+ getServiceRouteInfo(route) {
13756
+ const serviceRoute = this.routes.get(route.serviceRoute());
13757
+ if (!serviceRoute) {
13758
+ throw new Error(`Service route not found for route ID: ${route.serviceRoute()}`);
13759
+ }
13760
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
13761
+ const { routes } = serviceRoute, serviceRouteInfo = __rest(serviceRoute, ["routes"]);
13762
+ return serviceRouteInfo;
13855
13763
  }
13856
13764
  /**
13857
13765
  * Finds all routes passing through a stop.
@@ -13866,7 +13774,7 @@ class Timetable {
13866
13774
  }
13867
13775
  const routes = [];
13868
13776
  for (const routeId of stopData.routes) {
13869
- const route = this.routesAdjacency.get(routeId);
13777
+ const route = this.routesAdjacency[routeId];
13870
13778
  if (route) {
13871
13779
  routes.push(route);
13872
13780
  }
@@ -13886,7 +13794,7 @@ class Timetable {
13886
13794
  const reachableRoutes = new Map();
13887
13795
  for (const originStop of fromStops) {
13888
13796
  const validRoutes = this.routesPassingThrough(originStop).filter((route) => {
13889
- const serviceRoute = this.getServiceRoute(route);
13797
+ const serviceRoute = this.getServiceRouteInfo(route);
13890
13798
  return transportModes.has(serviceRoute.type);
13891
13799
  });
13892
13800
  for (const route of validRoutes) {
@@ -13933,12 +13841,6 @@ const standardProfile = {
13933
13841
  return undefined;
13934
13842
  }
13935
13843
  },
13936
- platformParser: (stopEntry) => {
13937
- if (stopEntry.platform_code) {
13938
- return stopEntry.platform_code;
13939
- }
13940
- return undefined;
13941
- },
13942
13844
  };
13943
13845
 
13944
13846
  const is_object = function (obj) {
@@ -15897,6 +15799,7 @@ const parseRoutes = (routesStream_1, ...args_1) => __awaiter(void 0, [routesStre
15897
15799
  routes.set(line.route_id, {
15898
15800
  name: line.route_short_name,
15899
15801
  type: routeType,
15802
+ routes: [],
15900
15803
  });
15901
15804
  }
15902
15805
  }
@@ -16035,7 +15938,7 @@ const parseCalendarDates = (calendarDatesStream, serviceIds, date) => __awaiter(
16035
15938
  * @param stopsStream The readable stream containing the stops data.
16036
15939
  * @return A mapping of stop IDs to corresponding stop details.
16037
15940
  */
16038
- const parseStops = (stopsStream, platformParser) => __awaiter(void 0, void 0, void 0, function* () {
15941
+ const parseStops = (stopsStream) => __awaiter(void 0, void 0, void 0, function* () {
16039
15942
  var _a, e_1, _b, _c;
16040
15943
  const parsedStops = new Map();
16041
15944
  let i = 0;
@@ -16049,20 +15952,9 @@ const parseStops = (stopsStream, platformParser) => __awaiter(void 0, void 0, vo
16049
15952
  _d = false;
16050
15953
  const rawLine = _c;
16051
15954
  const line = rawLine;
16052
- const stop = Object.assign({ id: i, sourceStopId: line.stop_id, name: line.stop_name, lat: line.stop_lat, lon: line.stop_lon, locationType: line.location_type
15955
+ const stop = Object.assign(Object.assign(Object.assign({ id: i, sourceStopId: line.stop_id, name: line.stop_name, lat: line.stop_lat, lon: line.stop_lon, locationType: line.location_type
16053
15956
  ? parseGtfsLocationType(line.location_type)
16054
- : 'SIMPLE_STOP_OR_PLATFORM', children: [] }, (line.parent_station && { parentSourceId: line.parent_station }));
16055
- if (platformParser) {
16056
- try {
16057
- const platform = platformParser(line);
16058
- if (platform) {
16059
- stop.platform = platform;
16060
- }
16061
- }
16062
- catch (_g) {
16063
- console.info(`Could not parse platform for stop ${line.stop_id}.`);
16064
- }
16065
- }
15957
+ : 'SIMPLE_STOP_OR_PLATFORM' }, (line.platform_code && { platform: line.platform_code })), { children: [] }), (line.parent_station && { parentSourceId: line.parent_station }));
16066
15958
  parsedStops.set(line.stop_id, stop);
16067
15959
  i = i + 1;
16068
15960
  }
@@ -16291,10 +16183,10 @@ const finalizeRouteFromBuilder = (builder) => {
16291
16183
  *
16292
16184
  * @param tripsStream The readable stream containing the trips data.
16293
16185
  * @param serviceIds A mapping of service IDs to corresponding route IDs.
16294
- * @param routeIds A mapping of route IDs to route details.
16186
+ * @param serviceRoutes A mapping of route IDs to route details.
16295
16187
  * @returns A mapping of trip IDs to corresponding route IDs.
16296
16188
  */
16297
- const parseTrips = (tripsStream, serviceIds, routeIds) => __awaiter(void 0, void 0, void 0, function* () {
16189
+ const parseTrips = (tripsStream, serviceIds, serviceRoutes) => __awaiter(void 0, void 0, void 0, function* () {
16298
16190
  var _a, e_1, _b, _c;
16299
16191
  const trips = new Map();
16300
16192
  try {
@@ -16307,7 +16199,7 @@ const parseTrips = (tripsStream, serviceIds, routeIds) => __awaiter(void 0, void
16307
16199
  // The trip doesn't correspond to an active service
16308
16200
  continue;
16309
16201
  }
16310
- if (!routeIds.get(line.route_id)) {
16202
+ if (!serviceRoutes.get(line.route_id)) {
16311
16203
  // The trip doesn't correspond to a supported route
16312
16204
  continue;
16313
16205
  }
@@ -16323,21 +16215,22 @@ const parseTrips = (tripsStream, serviceIds, routeIds) => __awaiter(void 0, void
16323
16215
  }
16324
16216
  return trips;
16325
16217
  });
16326
- const buildStopsAdjacencyStructure = (validStops, routes, transfersMap) => {
16327
- var _a;
16218
+ const buildStopsAdjacencyStructure = (validStops, serviceRoutes, routes, transfersMap) => {
16328
16219
  const stopsAdjacency = new Map();
16329
- for (const routeId of routes.keys()) {
16330
- const route = routes.get(routeId);
16331
- if (!route) {
16332
- throw new Error(`Route ${routeId} not found`);
16333
- }
16220
+ routes.forEach((route, index) => {
16221
+ var _a;
16334
16222
  for (const stop of route.stopsIterator()) {
16335
16223
  if (!stopsAdjacency.get(stop) && validStops.has(stop)) {
16336
16224
  stopsAdjacency.set(stop, { routes: [], transfers: [] });
16337
16225
  }
16338
- (_a = stopsAdjacency.get(stop)) === null || _a === void 0 ? void 0 : _a.routes.push(routeId);
16226
+ (_a = stopsAdjacency.get(stop)) === null || _a === void 0 ? void 0 : _a.routes.push(index);
16339
16227
  }
16340
- }
16228
+ const serviceRoute = serviceRoutes.get(route.serviceRoute());
16229
+ if (!serviceRoute) {
16230
+ throw new Error(`Service route ${route.serviceRoute()} not found for route ${index}.`);
16231
+ }
16232
+ serviceRoute.routes.push(index);
16233
+ });
16341
16234
  for (const [stop, transfers] of transfersMap) {
16342
16235
  const s = stopsAdjacency.get(stop);
16343
16236
  if (s) {
@@ -16469,10 +16362,10 @@ const parseStopTimes = (stopTimesStream, stopsMap, validTripIds, validStopIds) =
16469
16362
  if (currentTripId) {
16470
16363
  addTrip(currentTripId);
16471
16364
  }
16472
- const routesAdjacency = new Map();
16473
- for (const [routeId, routeBuilder] of routeBuilders) {
16365
+ const routesAdjacency = [];
16366
+ for (const [, routeBuilder] of routeBuilders) {
16474
16367
  const routeData = finalizeRouteFromBuilder(routeBuilder);
16475
- routesAdjacency.set(routeId, new Route(routeData.stopTimes, routeData.pickUpDropOffTypes, routeData.stops, routeData.serviceRouteId));
16368
+ routesAdjacency.push(new Route(routeData.stopTimes, routeData.pickUpDropOffTypes, routeData.stops, routeData.serviceRouteId));
16476
16369
  }
16477
16370
  return routesAdjacency;
16478
16371
  });
@@ -16523,7 +16416,7 @@ class GtfsParser {
16523
16416
  log.info(`Parsing ${STOPS_FILE}`);
16524
16417
  const stopsStart = performance.now();
16525
16418
  const stopsStream = yield zip.stream(STOPS_FILE);
16526
- const parsedStops = yield parseStops(stopsStream, this.profile.platformParser);
16419
+ const parsedStops = yield parseStops(stopsStream);
16527
16420
  const stopsEnd = performance.now();
16528
16421
  log.info(`${parsedStops.size} parsed stops. (${(stopsEnd - stopsStart).toFixed(2)}ms)`);
16529
16422
  if (entries[CALENDAR_FILE]) {
@@ -16567,9 +16460,9 @@ class GtfsParser {
16567
16460
  const stopTimesStart = performance.now();
16568
16461
  const stopTimesStream = yield zip.stream(STOP_TIMES_FILE);
16569
16462
  const routesAdjacency = yield parseStopTimes(stopTimesStream, parsedStops, trips, validStopIds);
16570
- const stopsAdjacency = buildStopsAdjacencyStructure(validStopIds, routesAdjacency, transfers);
16463
+ const stopsAdjacency = buildStopsAdjacencyStructure(validStopIds, validGtfsRoutes, routesAdjacency, transfers);
16571
16464
  const stopTimesEnd = performance.now();
16572
- log.info(`${routesAdjacency.size} valid unique routes. (${(stopTimesEnd - stopTimesStart).toFixed(2)}ms)`);
16465
+ log.info(`${routesAdjacency.length} valid unique routes. (${(stopTimesEnd - stopTimesStart).toFixed(2)}ms)`);
16573
16466
  log.info(`Removing unused stops.`);
16574
16467
  const indexStopsStart = performance.now();
16575
16468
  const stops = indexStops(parsedStops, validStopIds);
@@ -16599,7 +16492,7 @@ class GtfsParser {
16599
16492
  log.info(`Parsing ${STOPS_FILE}`);
16600
16493
  const stopsStart = performance.now();
16601
16494
  const stopsStream = yield zip.stream(STOPS_FILE);
16602
- const stops = indexStops(yield parseStops(stopsStream, this.profile.platformParser));
16495
+ const stops = indexStops(yield parseStops(stopsStream));
16603
16496
  const stopsEnd = performance.now();
16604
16497
  log.info(`${stops.size} parsed stops. (${(stopsEnd - stopsStart).toFixed(2)}ms)`);
16605
16498
  yield zip.close();
@@ -16608,19 +16501,6 @@ class GtfsParser {
16608
16501
  }
16609
16502
  }
16610
16503
 
16611
- /**
16612
- * Parses the platform number from a stop entry.
16613
- * @param stopEntry The stop entry.
16614
- * @returns The platform corresponding to this stop.
16615
- */
16616
- const platformParser = (stopEntry) => {
16617
- const stopId = stopEntry.stop_id;
16618
- const stopParts = stopId.split(':');
16619
- if (stopParts.length > 2) {
16620
- return stopParts[2];
16621
- }
16622
- return undefined;
16623
- };
16624
16504
  /**
16625
16505
  * Parses the SBB extended route type and returns the corresponding basic GTFS route type.
16626
16506
  * @param routeType The SBB route type to parse.
@@ -16647,6 +16527,7 @@ const routeTypeParser = (routeType) => {
16647
16527
  return 'FERRY'; // Boat
16648
16528
  case 900: // Tram
16649
16529
  return 'TRAM'; // Tram
16530
+ case 116: // ??? train TODO figure out what this means
16650
16531
  case 117: // Special train
16651
16532
  case 102: // International train
16652
16533
  case 104: // Car train
@@ -16658,7 +16539,6 @@ const routeTypeParser = (routeType) => {
16658
16539
  case 100: // No guaranteed train
16659
16540
  case 106: // Regional train
16660
16541
  case 109: // Urban train
16661
- case 116: // ??? train TODO figure out what this means
16662
16542
  return 'RAIL'; // Train
16663
16543
  case 1100: // Aircraft
16664
16544
  case 1500: // Taxi
@@ -16668,7 +16548,6 @@ const routeTypeParser = (routeType) => {
16668
16548
  };
16669
16549
  const chGtfsProfile = {
16670
16550
  routeTypeParser,
16671
- platformParser,
16672
16551
  };
16673
16552
 
16674
16553
  exports.GtfsParser = GtfsParser;