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
@@ -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) {
@@ -13931,12 +13839,6 @@ const standardProfile = {
13931
13839
  return undefined;
13932
13840
  }
13933
13841
  },
13934
- platformParser: (stopEntry) => {
13935
- if (stopEntry.platform_code) {
13936
- return stopEntry.platform_code;
13937
- }
13938
- return undefined;
13939
- },
13940
13842
  };
13941
13843
 
13942
13844
  const is_object = function (obj) {
@@ -15895,6 +15797,7 @@ const parseRoutes = (routesStream_1, ...args_1) => __awaiter(void 0, [routesStre
15895
15797
  routes.set(line.route_id, {
15896
15798
  name: line.route_short_name,
15897
15799
  type: routeType,
15800
+ routes: [],
15898
15801
  });
15899
15802
  }
15900
15803
  }
@@ -16033,7 +15936,7 @@ const parseCalendarDates = (calendarDatesStream, serviceIds, date) => __awaiter(
16033
15936
  * @param stopsStream The readable stream containing the stops data.
16034
15937
  * @return A mapping of stop IDs to corresponding stop details.
16035
15938
  */
16036
- const parseStops = (stopsStream, platformParser) => __awaiter(void 0, void 0, void 0, function* () {
15939
+ const parseStops = (stopsStream) => __awaiter(void 0, void 0, void 0, function* () {
16037
15940
  var _a, e_1, _b, _c;
16038
15941
  const parsedStops = new Map();
16039
15942
  let i = 0;
@@ -16047,20 +15950,9 @@ const parseStops = (stopsStream, platformParser) => __awaiter(void 0, void 0, vo
16047
15950
  _d = false;
16048
15951
  const rawLine = _c;
16049
15952
  const line = rawLine;
16050
- 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
15953
+ 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
16051
15954
  ? parseGtfsLocationType(line.location_type)
16052
- : 'SIMPLE_STOP_OR_PLATFORM', children: [] }, (line.parent_station && { parentSourceId: line.parent_station }));
16053
- if (platformParser) {
16054
- try {
16055
- const platform = platformParser(line);
16056
- if (platform) {
16057
- stop.platform = platform;
16058
- }
16059
- }
16060
- catch (_g) {
16061
- console.info(`Could not parse platform for stop ${line.stop_id}.`);
16062
- }
16063
- }
15955
+ : 'SIMPLE_STOP_OR_PLATFORM' }, (line.platform_code && { platform: line.platform_code })), { children: [] }), (line.parent_station && { parentSourceId: line.parent_station }));
16064
15956
  parsedStops.set(line.stop_id, stop);
16065
15957
  i = i + 1;
16066
15958
  }
@@ -16289,10 +16181,10 @@ const finalizeRouteFromBuilder = (builder) => {
16289
16181
  *
16290
16182
  * @param tripsStream The readable stream containing the trips data.
16291
16183
  * @param serviceIds A mapping of service IDs to corresponding route IDs.
16292
- * @param routeIds A mapping of route IDs to route details.
16184
+ * @param serviceRoutes A mapping of route IDs to route details.
16293
16185
  * @returns A mapping of trip IDs to corresponding route IDs.
16294
16186
  */
16295
- const parseTrips = (tripsStream, serviceIds, routeIds) => __awaiter(void 0, void 0, void 0, function* () {
16187
+ const parseTrips = (tripsStream, serviceIds, serviceRoutes) => __awaiter(void 0, void 0, void 0, function* () {
16296
16188
  var _a, e_1, _b, _c;
16297
16189
  const trips = new Map();
16298
16190
  try {
@@ -16305,7 +16197,7 @@ const parseTrips = (tripsStream, serviceIds, routeIds) => __awaiter(void 0, void
16305
16197
  // The trip doesn't correspond to an active service
16306
16198
  continue;
16307
16199
  }
16308
- if (!routeIds.get(line.route_id)) {
16200
+ if (!serviceRoutes.get(line.route_id)) {
16309
16201
  // The trip doesn't correspond to a supported route
16310
16202
  continue;
16311
16203
  }
@@ -16321,21 +16213,22 @@ const parseTrips = (tripsStream, serviceIds, routeIds) => __awaiter(void 0, void
16321
16213
  }
16322
16214
  return trips;
16323
16215
  });
16324
- const buildStopsAdjacencyStructure = (validStops, routes, transfersMap) => {
16325
- var _a;
16216
+ const buildStopsAdjacencyStructure = (validStops, serviceRoutes, routes, transfersMap) => {
16326
16217
  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
- }
16218
+ routes.forEach((route, index) => {
16219
+ var _a;
16332
16220
  for (const stop of route.stopsIterator()) {
16333
16221
  if (!stopsAdjacency.get(stop) && validStops.has(stop)) {
16334
16222
  stopsAdjacency.set(stop, { routes: [], transfers: [] });
16335
16223
  }
16336
- (_a = stopsAdjacency.get(stop)) === null || _a === void 0 ? void 0 : _a.routes.push(routeId);
16224
+ (_a = stopsAdjacency.get(stop)) === null || _a === void 0 ? void 0 : _a.routes.push(index);
16337
16225
  }
16338
- }
16226
+ const serviceRoute = serviceRoutes.get(route.serviceRoute());
16227
+ if (!serviceRoute) {
16228
+ throw new Error(`Service route ${route.serviceRoute()} not found for route ${index}.`);
16229
+ }
16230
+ serviceRoute.routes.push(index);
16231
+ });
16339
16232
  for (const [stop, transfers] of transfersMap) {
16340
16233
  const s = stopsAdjacency.get(stop);
16341
16234
  if (s) {
@@ -16467,10 +16360,10 @@ const parseStopTimes = (stopTimesStream, stopsMap, validTripIds, validStopIds) =
16467
16360
  if (currentTripId) {
16468
16361
  addTrip(currentTripId);
16469
16362
  }
16470
- const routesAdjacency = new Map();
16471
- for (const [routeId, routeBuilder] of routeBuilders) {
16363
+ const routesAdjacency = [];
16364
+ for (const [, routeBuilder] of routeBuilders) {
16472
16365
  const routeData = finalizeRouteFromBuilder(routeBuilder);
16473
- routesAdjacency.set(routeId, new Route(routeData.stopTimes, routeData.pickUpDropOffTypes, routeData.stops, routeData.serviceRouteId));
16366
+ routesAdjacency.push(new Route(routeData.stopTimes, routeData.pickUpDropOffTypes, routeData.stops, routeData.serviceRouteId));
16474
16367
  }
16475
16368
  return routesAdjacency;
16476
16369
  });
@@ -16521,7 +16414,7 @@ class GtfsParser {
16521
16414
  log.info(`Parsing ${STOPS_FILE}`);
16522
16415
  const stopsStart = performance.now();
16523
16416
  const stopsStream = yield zip.stream(STOPS_FILE);
16524
- const parsedStops = yield parseStops(stopsStream, this.profile.platformParser);
16417
+ const parsedStops = yield parseStops(stopsStream);
16525
16418
  const stopsEnd = performance.now();
16526
16419
  log.info(`${parsedStops.size} parsed stops. (${(stopsEnd - stopsStart).toFixed(2)}ms)`);
16527
16420
  if (entries[CALENDAR_FILE]) {
@@ -16565,9 +16458,9 @@ class GtfsParser {
16565
16458
  const stopTimesStart = performance.now();
16566
16459
  const stopTimesStream = yield zip.stream(STOP_TIMES_FILE);
16567
16460
  const routesAdjacency = yield parseStopTimes(stopTimesStream, parsedStops, trips, validStopIds);
16568
- const stopsAdjacency = buildStopsAdjacencyStructure(validStopIds, routesAdjacency, transfers);
16461
+ const stopsAdjacency = buildStopsAdjacencyStructure(validStopIds, validGtfsRoutes, routesAdjacency, transfers);
16569
16462
  const stopTimesEnd = performance.now();
16570
- log.info(`${routesAdjacency.size} valid unique routes. (${(stopTimesEnd - stopTimesStart).toFixed(2)}ms)`);
16463
+ log.info(`${routesAdjacency.length} valid unique routes. (${(stopTimesEnd - stopTimesStart).toFixed(2)}ms)`);
16571
16464
  log.info(`Removing unused stops.`);
16572
16465
  const indexStopsStart = performance.now();
16573
16466
  const stops = indexStops(parsedStops, validStopIds);
@@ -16597,7 +16490,7 @@ class GtfsParser {
16597
16490
  log.info(`Parsing ${STOPS_FILE}`);
16598
16491
  const stopsStart = performance.now();
16599
16492
  const stopsStream = yield zip.stream(STOPS_FILE);
16600
- const stops = indexStops(yield parseStops(stopsStream, this.profile.platformParser));
16493
+ const stops = indexStops(yield parseStops(stopsStream));
16601
16494
  const stopsEnd = performance.now();
16602
16495
  log.info(`${stops.size} parsed stops. (${(stopsEnd - stopsStart).toFixed(2)}ms)`);
16603
16496
  yield zip.close();
@@ -16606,19 +16499,6 @@ class GtfsParser {
16606
16499
  }
16607
16500
  }
16608
16501
 
16609
- /**
16610
- * Parses the platform number from a stop entry.
16611
- * @param stopEntry The stop entry.
16612
- * @returns The platform corresponding to this stop.
16613
- */
16614
- const platformParser = (stopEntry) => {
16615
- const stopId = stopEntry.stop_id;
16616
- const stopParts = stopId.split(':');
16617
- if (stopParts.length > 2) {
16618
- return stopParts[2];
16619
- }
16620
- return undefined;
16621
- };
16622
16502
  /**
16623
16503
  * Parses the SBB extended route type and returns the corresponding basic GTFS route type.
16624
16504
  * @param routeType The SBB route type to parse.
@@ -16645,6 +16525,7 @@ const routeTypeParser = (routeType) => {
16645
16525
  return 'FERRY'; // Boat
16646
16526
  case 900: // Tram
16647
16527
  return 'TRAM'; // Tram
16528
+ case 116: // ??? train TODO figure out what this means
16648
16529
  case 117: // Special train
16649
16530
  case 102: // International train
16650
16531
  case 104: // Car train
@@ -16656,7 +16537,6 @@ const routeTypeParser = (routeType) => {
16656
16537
  case 100: // No guaranteed train
16657
16538
  case 106: // Regional train
16658
16539
  case 109: // Urban train
16659
- case 116: // ??? train TODO figure out what this means
16660
16540
  return 'RAIL'; // Train
16661
16541
  case 1100: // Aircraft
16662
16542
  case 1500: // Taxi
@@ -16666,7 +16546,6 @@ const routeTypeParser = (routeType) => {
16666
16546
  };
16667
16547
  const chGtfsProfile = {
16668
16548
  routeTypeParser,
16669
- platformParser,
16670
16549
  };
16671
16550
 
16672
16551
  export { GtfsParser, chGtfsProfile };