minotor 5.0.1 → 7.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.
- package/CHANGELOG.md +8 -3
- package/dist/cli.mjs +282 -654
- package/dist/cli.mjs.map +1 -1
- package/dist/gtfs/parser.d.ts +4 -10
- package/dist/gtfs/routes.d.ts +16 -2
- package/dist/gtfs/stops.d.ts +3 -13
- package/dist/gtfs/transfers.d.ts +2 -2
- package/dist/gtfs/trips.d.ts +12 -8
- package/dist/parser.cjs.js +257 -644
- package/dist/parser.cjs.js.map +1 -1
- package/dist/parser.esm.js +257 -644
- package/dist/parser.esm.js.map +1 -1
- package/dist/router.cjs.js +1 -1
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.esm.js +1 -1
- package/dist/router.esm.js.map +1 -1
- package/dist/router.umd.js +1 -1
- package/dist/router.umd.js.map +1 -1
- package/dist/stops/io.d.ts +3 -3
- package/dist/stops/proto/stops.d.ts +1 -8
- package/dist/stops/stops.d.ts +0 -4
- package/dist/stops/stopsIndex.d.ts +3 -3
- package/dist/timetable/io.d.ts +6 -6
- package/dist/timetable/proto/timetable.d.ts +5 -27
- package/dist/timetable/route.d.ts +2 -11
- package/dist/timetable/timetable.d.ts +17 -9
- package/package.json +1 -1
- package/src/__e2e__/timetable/stops.bin +2 -2
- package/src/__e2e__/timetable/timetable.bin +2 -2
- package/src/cli/minotor.ts +3 -4
- package/src/gtfs/__tests__/parser.test.ts +5 -6
- package/src/gtfs/__tests__/routes.test.ts +0 -3
- package/src/gtfs/__tests__/stops.test.ts +1 -124
- package/src/gtfs/__tests__/transfers.test.ts +7 -7
- package/src/gtfs/__tests__/trips.test.ts +74 -45
- package/src/gtfs/parser.ts +32 -49
- package/src/gtfs/routes.ts +43 -5
- package/src/gtfs/stops.ts +2 -44
- package/src/gtfs/transfers.ts +2 -2
- package/src/gtfs/trips.ts +66 -43
- package/src/routing/__tests__/result.test.ts +48 -48
- package/src/routing/__tests__/router.test.ts +279 -363
- package/src/routing/router.ts +22 -8
- package/src/stops/__tests__/io.test.ts +25 -31
- package/src/stops/__tests__/stopFinder.test.ts +82 -103
- package/src/stops/io.ts +8 -17
- package/src/stops/proto/stops.proto +3 -3
- package/src/stops/proto/stops.ts +16 -120
- package/src/stops/stops.ts +0 -4
- package/src/stops/stopsIndex.ts +37 -41
- package/src/timetable/__tests__/io.test.ts +44 -54
- package/src/timetable/__tests__/route.test.ts +10 -29
- package/src/timetable/__tests__/timetable.test.ts +29 -37
- package/src/timetable/io.ts +66 -74
- package/src/timetable/proto/timetable.proto +7 -14
- package/src/timetable/proto/timetable.ts +49 -391
- package/src/timetable/route.ts +2 -32
- package/src/timetable/timetable.ts +51 -31
package/dist/parser.esm.js
CHANGED
|
@@ -11459,10 +11459,10 @@ const Stop = {
|
|
|
11459
11459
|
writer.uint32(18).string(message.sourceStopId);
|
|
11460
11460
|
}
|
|
11461
11461
|
if (message.lat !== undefined) {
|
|
11462
|
-
writer.uint32(
|
|
11462
|
+
writer.uint32(29).float(message.lat);
|
|
11463
11463
|
}
|
|
11464
11464
|
if (message.lon !== undefined) {
|
|
11465
|
-
writer.uint32(
|
|
11465
|
+
writer.uint32(37).float(message.lon);
|
|
11466
11466
|
}
|
|
11467
11467
|
writer.uint32(42).fork();
|
|
11468
11468
|
for (const v of message.children) {
|
|
@@ -11502,17 +11502,17 @@ const Stop = {
|
|
|
11502
11502
|
continue;
|
|
11503
11503
|
}
|
|
11504
11504
|
case 3: {
|
|
11505
|
-
if (tag !==
|
|
11505
|
+
if (tag !== 29) {
|
|
11506
11506
|
break;
|
|
11507
11507
|
}
|
|
11508
|
-
message.lat = reader.
|
|
11508
|
+
message.lat = reader.float();
|
|
11509
11509
|
continue;
|
|
11510
11510
|
}
|
|
11511
11511
|
case 4: {
|
|
11512
|
-
if (tag !==
|
|
11512
|
+
if (tag !== 37) {
|
|
11513
11513
|
break;
|
|
11514
11514
|
}
|
|
11515
|
-
message.lon = reader.
|
|
11515
|
+
message.lon = reader.float();
|
|
11516
11516
|
continue;
|
|
11517
11517
|
}
|
|
11518
11518
|
case 5: {
|
|
@@ -11617,16 +11617,16 @@ const Stop = {
|
|
|
11617
11617
|
},
|
|
11618
11618
|
};
|
|
11619
11619
|
function createBaseStopsMap() {
|
|
11620
|
-
return { version: "", stops:
|
|
11620
|
+
return { version: "", stops: [] };
|
|
11621
11621
|
}
|
|
11622
11622
|
const StopsMap = {
|
|
11623
11623
|
encode(message, writer = new BinaryWriter()) {
|
|
11624
11624
|
if (message.version !== "") {
|
|
11625
11625
|
writer.uint32(10).string(message.version);
|
|
11626
11626
|
}
|
|
11627
|
-
|
|
11628
|
-
|
|
11629
|
-
}
|
|
11627
|
+
for (const v of message.stops) {
|
|
11628
|
+
Stop.encode(v, writer.uint32(18).fork()).join();
|
|
11629
|
+
}
|
|
11630
11630
|
return writer;
|
|
11631
11631
|
},
|
|
11632
11632
|
decode(input, length) {
|
|
@@ -11647,10 +11647,7 @@ const StopsMap = {
|
|
|
11647
11647
|
if (tag !== 18) {
|
|
11648
11648
|
break;
|
|
11649
11649
|
}
|
|
11650
|
-
|
|
11651
|
-
if (entry2.value !== undefined) {
|
|
11652
|
-
message.stops[entry2.key] = entry2.value;
|
|
11653
|
-
}
|
|
11650
|
+
message.stops.push(Stop.decode(reader, reader.uint32()));
|
|
11654
11651
|
continue;
|
|
11655
11652
|
}
|
|
11656
11653
|
}
|
|
@@ -11664,27 +11661,17 @@ const StopsMap = {
|
|
|
11664
11661
|
fromJSON(object) {
|
|
11665
11662
|
return {
|
|
11666
11663
|
version: isSet$1(object.version) ? globalThis.String(object.version) : "",
|
|
11667
|
-
stops:
|
|
11668
|
-
? Object.entries(object.stops).reduce((acc, [key, value]) => {
|
|
11669
|
-
acc[globalThis.Number(key)] = Stop.fromJSON(value);
|
|
11670
|
-
return acc;
|
|
11671
|
-
}, {})
|
|
11672
|
-
: {},
|
|
11664
|
+
stops: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.stops) ? object.stops.map((e) => Stop.fromJSON(e)) : [],
|
|
11673
11665
|
};
|
|
11674
11666
|
},
|
|
11675
11667
|
toJSON(message) {
|
|
11668
|
+
var _a;
|
|
11676
11669
|
const obj = {};
|
|
11677
11670
|
if (message.version !== "") {
|
|
11678
11671
|
obj.version = message.version;
|
|
11679
11672
|
}
|
|
11680
|
-
if (message.stops) {
|
|
11681
|
-
|
|
11682
|
-
if (entries.length > 0) {
|
|
11683
|
-
obj.stops = {};
|
|
11684
|
-
entries.forEach(([k, v]) => {
|
|
11685
|
-
obj.stops[k] = Stop.toJSON(v);
|
|
11686
|
-
});
|
|
11687
|
-
}
|
|
11673
|
+
if ((_a = message.stops) === null || _a === void 0 ? void 0 : _a.length) {
|
|
11674
|
+
obj.stops = message.stops.map((e) => Stop.toJSON(e));
|
|
11688
11675
|
}
|
|
11689
11676
|
return obj;
|
|
11690
11677
|
},
|
|
@@ -11695,92 +11682,15 @@ const StopsMap = {
|
|
|
11695
11682
|
var _a, _b;
|
|
11696
11683
|
const message = createBaseStopsMap();
|
|
11697
11684
|
message.version = (_a = object.version) !== null && _a !== void 0 ? _a : "";
|
|
11698
|
-
message.stops =
|
|
11699
|
-
if (value !== undefined) {
|
|
11700
|
-
acc[globalThis.Number(key)] = Stop.fromPartial(value);
|
|
11701
|
-
}
|
|
11702
|
-
return acc;
|
|
11703
|
-
}, {});
|
|
11704
|
-
return message;
|
|
11705
|
-
},
|
|
11706
|
-
};
|
|
11707
|
-
function createBaseStopsMap_StopsEntry() {
|
|
11708
|
-
return { key: 0, value: undefined };
|
|
11709
|
-
}
|
|
11710
|
-
const StopsMap_StopsEntry = {
|
|
11711
|
-
encode(message, writer = new BinaryWriter()) {
|
|
11712
|
-
if (message.key !== 0) {
|
|
11713
|
-
writer.uint32(8).uint32(message.key);
|
|
11714
|
-
}
|
|
11715
|
-
if (message.value !== undefined) {
|
|
11716
|
-
Stop.encode(message.value, writer.uint32(18).fork()).join();
|
|
11717
|
-
}
|
|
11718
|
-
return writer;
|
|
11719
|
-
},
|
|
11720
|
-
decode(input, length) {
|
|
11721
|
-
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
11722
|
-
const end = length === undefined ? reader.len : reader.pos + length;
|
|
11723
|
-
const message = createBaseStopsMap_StopsEntry();
|
|
11724
|
-
while (reader.pos < end) {
|
|
11725
|
-
const tag = reader.uint32();
|
|
11726
|
-
switch (tag >>> 3) {
|
|
11727
|
-
case 1: {
|
|
11728
|
-
if (tag !== 8) {
|
|
11729
|
-
break;
|
|
11730
|
-
}
|
|
11731
|
-
message.key = reader.uint32();
|
|
11732
|
-
continue;
|
|
11733
|
-
}
|
|
11734
|
-
case 2: {
|
|
11735
|
-
if (tag !== 18) {
|
|
11736
|
-
break;
|
|
11737
|
-
}
|
|
11738
|
-
message.value = Stop.decode(reader, reader.uint32());
|
|
11739
|
-
continue;
|
|
11740
|
-
}
|
|
11741
|
-
}
|
|
11742
|
-
if ((tag & 7) === 4 || tag === 0) {
|
|
11743
|
-
break;
|
|
11744
|
-
}
|
|
11745
|
-
reader.skip(tag & 7);
|
|
11746
|
-
}
|
|
11747
|
-
return message;
|
|
11748
|
-
},
|
|
11749
|
-
fromJSON(object) {
|
|
11750
|
-
return {
|
|
11751
|
-
key: isSet$1(object.key) ? globalThis.Number(object.key) : 0,
|
|
11752
|
-
value: isSet$1(object.value) ? Stop.fromJSON(object.value) : undefined,
|
|
11753
|
-
};
|
|
11754
|
-
},
|
|
11755
|
-
toJSON(message) {
|
|
11756
|
-
const obj = {};
|
|
11757
|
-
if (message.key !== 0) {
|
|
11758
|
-
obj.key = Math.round(message.key);
|
|
11759
|
-
}
|
|
11760
|
-
if (message.value !== undefined) {
|
|
11761
|
-
obj.value = Stop.toJSON(message.value);
|
|
11762
|
-
}
|
|
11763
|
-
return obj;
|
|
11764
|
-
},
|
|
11765
|
-
create(base) {
|
|
11766
|
-
return StopsMap_StopsEntry.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
11767
|
-
},
|
|
11768
|
-
fromPartial(object) {
|
|
11769
|
-
var _a;
|
|
11770
|
-
const message = createBaseStopsMap_StopsEntry();
|
|
11771
|
-
message.key = (_a = object.key) !== null && _a !== void 0 ? _a : 0;
|
|
11772
|
-
message.value = (object.value !== undefined && object.value !== null) ? Stop.fromPartial(object.value) : undefined;
|
|
11685
|
+
message.stops = ((_b = object.stops) === null || _b === void 0 ? void 0 : _b.map((e) => Stop.fromPartial(e))) || [];
|
|
11773
11686
|
return message;
|
|
11774
11687
|
},
|
|
11775
11688
|
};
|
|
11776
|
-
function isObject$1(value) {
|
|
11777
|
-
return typeof value === "object" && value !== null;
|
|
11778
|
-
}
|
|
11779
11689
|
function isSet$1(value) {
|
|
11780
11690
|
return value !== null && value !== undefined;
|
|
11781
11691
|
}
|
|
11782
11692
|
|
|
11783
|
-
const CURRENT_VERSION$1 = '0.0.
|
|
11693
|
+
const CURRENT_VERSION$1 = '0.0.3';
|
|
11784
11694
|
const serializeStop = (stop) => {
|
|
11785
11695
|
return {
|
|
11786
11696
|
name: stop.name,
|
|
@@ -11793,14 +11703,11 @@ const serializeStop = (stop) => {
|
|
|
11793
11703
|
platform: stop.platform,
|
|
11794
11704
|
};
|
|
11795
11705
|
};
|
|
11796
|
-
const serializeStopsMap = (
|
|
11706
|
+
const serializeStopsMap = (stops) => {
|
|
11797
11707
|
const protoStopsMap = {
|
|
11798
11708
|
version: CURRENT_VERSION$1,
|
|
11799
|
-
stops:
|
|
11709
|
+
stops: stops.map((value) => serializeStop(value)),
|
|
11800
11710
|
};
|
|
11801
|
-
stopsMap.forEach((value, key) => {
|
|
11802
|
-
protoStopsMap.stops[key] = serializeStop(value);
|
|
11803
|
-
});
|
|
11804
11711
|
return protoStopsMap;
|
|
11805
11712
|
};
|
|
11806
11713
|
const deserializeStop = (stopId, protoStop) => {
|
|
@@ -11820,12 +11727,7 @@ const deserializeStopsMap = (protoStopsMap) => {
|
|
|
11820
11727
|
if (protoStopsMap.version !== CURRENT_VERSION$1) {
|
|
11821
11728
|
throw new Error(`Unsupported stopMap version ${protoStopsMap.version}`);
|
|
11822
11729
|
}
|
|
11823
|
-
|
|
11824
|
-
Object.entries(protoStopsMap.stops).forEach(([key, value]) => {
|
|
11825
|
-
const intKey = parseInt(key, 10);
|
|
11826
|
-
stopsMap.set(intKey, deserializeStop(intKey, value));
|
|
11827
|
-
});
|
|
11828
|
-
return stopsMap;
|
|
11730
|
+
return protoStopsMap.stops.map((value, intKey) => deserializeStop(intKey, value));
|
|
11829
11731
|
};
|
|
11830
11732
|
const parseProtoLocationType = (protoLocationType) => {
|
|
11831
11733
|
switch (protoLocationType) {
|
|
@@ -11864,45 +11766,44 @@ const serializeLocationType = (locationType) => {
|
|
|
11864
11766
|
* to efficiently find stops based on user queries.
|
|
11865
11767
|
*/
|
|
11866
11768
|
class StopsIndex {
|
|
11867
|
-
constructor(
|
|
11769
|
+
constructor(stops) {
|
|
11868
11770
|
var _a;
|
|
11869
|
-
this.
|
|
11771
|
+
this.stops = stops;
|
|
11870
11772
|
this.sourceStopsMap = new Map();
|
|
11871
|
-
for (const [id, stop] of stopsMap.entries()) {
|
|
11872
|
-
this.sourceStopsMap.set(stop.sourceStopId, id);
|
|
11873
|
-
}
|
|
11874
|
-
this.textIndex = lt({
|
|
11875
|
-
fields: ['name'],
|
|
11876
|
-
storeFields: ['id'],
|
|
11877
|
-
searchOptions: { prefix: true, fuzzy: 0.2 },
|
|
11878
|
-
processTerm: generateAccentVariants,
|
|
11879
|
-
});
|
|
11880
11773
|
const stopsSet = new Map();
|
|
11881
|
-
|
|
11774
|
+
this.stopPoints = [];
|
|
11775
|
+
for (let id = 0; id < stops.length; id++) {
|
|
11776
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
11777
|
+
const stop = stops[id];
|
|
11778
|
+
this.sourceStopsMap.set(stop.sourceStopId, id);
|
|
11882
11779
|
const effectiveStopId = (_a = stop.parent) !== null && _a !== void 0 ? _a : id;
|
|
11883
11780
|
if (!stopsSet.has(effectiveStopId)) {
|
|
11884
11781
|
stopsSet.set(effectiveStopId, {
|
|
11885
11782
|
id: effectiveStopId,
|
|
11886
11783
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
11887
|
-
name: stop.parent ? this.
|
|
11784
|
+
name: stop.parent ? this.stops[stop.parent].name : stop.name,
|
|
11785
|
+
});
|
|
11786
|
+
}
|
|
11787
|
+
if (stop.lat && stop.lon) {
|
|
11788
|
+
this.stopPoints.push({
|
|
11789
|
+
id: id,
|
|
11790
|
+
lat: stop.lat,
|
|
11791
|
+
lon: stop.lon,
|
|
11888
11792
|
});
|
|
11889
11793
|
}
|
|
11890
11794
|
}
|
|
11795
|
+
this.textIndex = lt({
|
|
11796
|
+
fields: ['name'],
|
|
11797
|
+
storeFields: ['id'],
|
|
11798
|
+
searchOptions: { prefix: true, fuzzy: 0.2 },
|
|
11799
|
+
processTerm: generateAccentVariants,
|
|
11800
|
+
});
|
|
11891
11801
|
const stopsArray = Array.from(stopsSet.values());
|
|
11892
11802
|
q(this.textIndex, stopsArray);
|
|
11893
|
-
this.stopPoints = Array.from(this.stopsMap.entries())
|
|
11894
|
-
.filter(([, stop]) => {
|
|
11895
|
-
if (stop.lat && stop.lon)
|
|
11896
|
-
return true;
|
|
11897
|
-
return false;
|
|
11898
|
-
})
|
|
11899
|
-
.map(([id, stop]) => ({
|
|
11900
|
-
id: id,
|
|
11901
|
-
lat: stop.lat,
|
|
11902
|
-
lon: stop.lon,
|
|
11903
|
-
}));
|
|
11904
11803
|
this.geoIndex = new KDBush(this.stopPoints.length);
|
|
11905
|
-
for (
|
|
11804
|
+
for (let i = 0; i < this.stopPoints.length; i++) {
|
|
11805
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
11806
|
+
const { lat, lon } = this.stopPoints[i];
|
|
11906
11807
|
this.geoIndex.add(lon, lat);
|
|
11907
11808
|
}
|
|
11908
11809
|
this.geoIndex.finish();
|
|
@@ -11924,7 +11825,7 @@ class StopsIndex {
|
|
|
11924
11825
|
* @returns The serialized binary data.
|
|
11925
11826
|
*/
|
|
11926
11827
|
serialize() {
|
|
11927
|
-
const protoStopsMap = serializeStopsMap(this.
|
|
11828
|
+
const protoStopsMap = serializeStopsMap(this.stops);
|
|
11928
11829
|
const writer = new BinaryWriter();
|
|
11929
11830
|
StopsMap.encode(protoStopsMap, writer);
|
|
11930
11831
|
return writer.finish();
|
|
@@ -11935,7 +11836,7 @@ class StopsIndex {
|
|
|
11935
11836
|
* @returns The total number of stops.
|
|
11936
11837
|
*/
|
|
11937
11838
|
size() {
|
|
11938
|
-
return this.
|
|
11839
|
+
return this.stops.length;
|
|
11939
11840
|
}
|
|
11940
11841
|
/**
|
|
11941
11842
|
* Finds stops by their name using a text search.
|
|
@@ -11945,7 +11846,7 @@ class StopsIndex {
|
|
|
11945
11846
|
* @returns An array of Stop objects that match the search query.
|
|
11946
11847
|
*/
|
|
11947
11848
|
findStopsByName(query, maxResults = 5) {
|
|
11948
|
-
const results = dt(this.textIndex, query).map((result) => this.
|
|
11849
|
+
const results = dt(this.textIndex, query).map((result) => this.stops[result.id]);
|
|
11949
11850
|
return results.slice(0, maxResults);
|
|
11950
11851
|
}
|
|
11951
11852
|
/**
|
|
@@ -11960,7 +11861,7 @@ class StopsIndex {
|
|
|
11960
11861
|
findStopsByLocation(lat, lon, maxResults = 5, radius = 0.5) {
|
|
11961
11862
|
const nearestStops = around(this.geoIndex, lon, lat, maxResults, radius).map((id) => {
|
|
11962
11863
|
const stopPoint = this.stopPoints[id];
|
|
11963
|
-
return this.
|
|
11864
|
+
return this.stops[stopPoint.id];
|
|
11964
11865
|
});
|
|
11965
11866
|
return nearestStops;
|
|
11966
11867
|
}
|
|
@@ -11971,7 +11872,7 @@ class StopsIndex {
|
|
|
11971
11872
|
* @returns The Stop object that matches the specified ID, or undefined if not found.
|
|
11972
11873
|
*/
|
|
11973
11874
|
findStopById(id) {
|
|
11974
|
-
return this.
|
|
11875
|
+
return this.stops[id];
|
|
11975
11876
|
}
|
|
11976
11877
|
/**
|
|
11977
11878
|
* Finds a stop by its ID in the transit data source (e.g. GTFS).
|
|
@@ -11995,14 +11896,14 @@ class StopsIndex {
|
|
|
11995
11896
|
if (id === undefined) {
|
|
11996
11897
|
return [];
|
|
11997
11898
|
}
|
|
11998
|
-
const stop = this.
|
|
11899
|
+
const stop = this.stops[id];
|
|
11999
11900
|
if (!stop) {
|
|
12000
11901
|
return [];
|
|
12001
11902
|
}
|
|
12002
11903
|
const equivalentStops = stop.parent
|
|
12003
|
-
? ((_b = (_a = this.
|
|
11904
|
+
? ((_b = (_a = this.stops[stop.parent]) === null || _a === void 0 ? void 0 : _a.children) !== null && _b !== void 0 ? _b : [])
|
|
12004
11905
|
: stop.children;
|
|
12005
|
-
return Array.from(new Set([id, ...equivalentStops])).map((stopId) => this.
|
|
11906
|
+
return Array.from(new Set([id, ...equivalentStops])).map((stopId) => this.stops[stopId]);
|
|
12006
11907
|
}
|
|
12007
11908
|
}
|
|
12008
11909
|
|
|
@@ -12220,7 +12121,7 @@ function createBaseRoute() {
|
|
|
12220
12121
|
stopTimes: new Uint8Array(0),
|
|
12221
12122
|
pickUpDropOffTypes: new Uint8Array(0),
|
|
12222
12123
|
stops: new Uint8Array(0),
|
|
12223
|
-
serviceRouteId:
|
|
12124
|
+
serviceRouteId: 0,
|
|
12224
12125
|
};
|
|
12225
12126
|
}
|
|
12226
12127
|
const Route$1 = {
|
|
@@ -12234,8 +12135,8 @@ const Route$1 = {
|
|
|
12234
12135
|
if (message.stops.length !== 0) {
|
|
12235
12136
|
writer.uint32(26).bytes(message.stops);
|
|
12236
12137
|
}
|
|
12237
|
-
if (message.serviceRouteId !==
|
|
12238
|
-
writer.uint32(
|
|
12138
|
+
if (message.serviceRouteId !== 0) {
|
|
12139
|
+
writer.uint32(32).uint32(message.serviceRouteId);
|
|
12239
12140
|
}
|
|
12240
12141
|
return writer;
|
|
12241
12142
|
},
|
|
@@ -12268,10 +12169,10 @@ const Route$1 = {
|
|
|
12268
12169
|
continue;
|
|
12269
12170
|
}
|
|
12270
12171
|
case 4: {
|
|
12271
|
-
if (tag !==
|
|
12172
|
+
if (tag !== 32) {
|
|
12272
12173
|
break;
|
|
12273
12174
|
}
|
|
12274
|
-
message.serviceRouteId = reader.
|
|
12175
|
+
message.serviceRouteId = reader.uint32();
|
|
12275
12176
|
continue;
|
|
12276
12177
|
}
|
|
12277
12178
|
}
|
|
@@ -12289,7 +12190,7 @@ const Route$1 = {
|
|
|
12289
12190
|
? bytesFromBase64(object.pickUpDropOffTypes)
|
|
12290
12191
|
: new Uint8Array(0),
|
|
12291
12192
|
stops: isSet(object.stops) ? bytesFromBase64(object.stops) : new Uint8Array(0),
|
|
12292
|
-
serviceRouteId: isSet(object.serviceRouteId) ? globalThis.
|
|
12193
|
+
serviceRouteId: isSet(object.serviceRouteId) ? globalThis.Number(object.serviceRouteId) : 0,
|
|
12293
12194
|
};
|
|
12294
12195
|
},
|
|
12295
12196
|
toJSON(message) {
|
|
@@ -12303,8 +12204,8 @@ const Route$1 = {
|
|
|
12303
12204
|
if (message.stops.length !== 0) {
|
|
12304
12205
|
obj.stops = base64FromBytes(message.stops);
|
|
12305
12206
|
}
|
|
12306
|
-
if (message.serviceRouteId !==
|
|
12307
|
-
obj.serviceRouteId = message.serviceRouteId;
|
|
12207
|
+
if (message.serviceRouteId !== 0) {
|
|
12208
|
+
obj.serviceRouteId = Math.round(message.serviceRouteId);
|
|
12308
12209
|
}
|
|
12309
12210
|
return obj;
|
|
12310
12211
|
},
|
|
@@ -12317,7 +12218,7 @@ const Route$1 = {
|
|
|
12317
12218
|
message.stopTimes = (_a = object.stopTimes) !== null && _a !== void 0 ? _a : new Uint8Array(0);
|
|
12318
12219
|
message.pickUpDropOffTypes = (_b = object.pickUpDropOffTypes) !== null && _b !== void 0 ? _b : new Uint8Array(0);
|
|
12319
12220
|
message.stops = (_c = object.stops) !== null && _c !== void 0 ? _c : new Uint8Array(0);
|
|
12320
|
-
message.serviceRouteId = (_d = object.serviceRouteId) !== null && _d !== void 0 ? _d :
|
|
12221
|
+
message.serviceRouteId = (_d = object.serviceRouteId) !== null && _d !== void 0 ? _d : 0;
|
|
12321
12222
|
return message;
|
|
12322
12223
|
},
|
|
12323
12224
|
};
|
|
@@ -12405,90 +12306,17 @@ const Transfer = {
|
|
|
12405
12306
|
return message;
|
|
12406
12307
|
},
|
|
12407
12308
|
};
|
|
12408
|
-
function
|
|
12409
|
-
return { stops: {} };
|
|
12410
|
-
}
|
|
12411
|
-
const StopsAdjacency = {
|
|
12412
|
-
encode(message, writer = new BinaryWriter()) {
|
|
12413
|
-
Object.entries(message.stops).forEach(([key, value]) => {
|
|
12414
|
-
StopsAdjacency_StopsEntry.encode({ key: key, value }, writer.uint32(10).fork()).join();
|
|
12415
|
-
});
|
|
12416
|
-
return writer;
|
|
12417
|
-
},
|
|
12418
|
-
decode(input, length) {
|
|
12419
|
-
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
12420
|
-
const end = length === undefined ? reader.len : reader.pos + length;
|
|
12421
|
-
const message = createBaseStopsAdjacency();
|
|
12422
|
-
while (reader.pos < end) {
|
|
12423
|
-
const tag = reader.uint32();
|
|
12424
|
-
switch (tag >>> 3) {
|
|
12425
|
-
case 1: {
|
|
12426
|
-
if (tag !== 10) {
|
|
12427
|
-
break;
|
|
12428
|
-
}
|
|
12429
|
-
const entry1 = StopsAdjacency_StopsEntry.decode(reader, reader.uint32());
|
|
12430
|
-
if (entry1.value !== undefined) {
|
|
12431
|
-
message.stops[entry1.key] = entry1.value;
|
|
12432
|
-
}
|
|
12433
|
-
continue;
|
|
12434
|
-
}
|
|
12435
|
-
}
|
|
12436
|
-
if ((tag & 7) === 4 || tag === 0) {
|
|
12437
|
-
break;
|
|
12438
|
-
}
|
|
12439
|
-
reader.skip(tag & 7);
|
|
12440
|
-
}
|
|
12441
|
-
return message;
|
|
12442
|
-
},
|
|
12443
|
-
fromJSON(object) {
|
|
12444
|
-
return {
|
|
12445
|
-
stops: isObject(object.stops)
|
|
12446
|
-
? Object.entries(object.stops).reduce((acc, [key, value]) => {
|
|
12447
|
-
acc[globalThis.Number(key)] = StopsAdjacency_StopAdjacency.fromJSON(value);
|
|
12448
|
-
return acc;
|
|
12449
|
-
}, {})
|
|
12450
|
-
: {},
|
|
12451
|
-
};
|
|
12452
|
-
},
|
|
12453
|
-
toJSON(message) {
|
|
12454
|
-
const obj = {};
|
|
12455
|
-
if (message.stops) {
|
|
12456
|
-
const entries = Object.entries(message.stops);
|
|
12457
|
-
if (entries.length > 0) {
|
|
12458
|
-
obj.stops = {};
|
|
12459
|
-
entries.forEach(([k, v]) => {
|
|
12460
|
-
obj.stops[k] = StopsAdjacency_StopAdjacency.toJSON(v);
|
|
12461
|
-
});
|
|
12462
|
-
}
|
|
12463
|
-
}
|
|
12464
|
-
return obj;
|
|
12465
|
-
},
|
|
12466
|
-
create(base) {
|
|
12467
|
-
return StopsAdjacency.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
12468
|
-
},
|
|
12469
|
-
fromPartial(object) {
|
|
12470
|
-
var _a;
|
|
12471
|
-
const message = createBaseStopsAdjacency();
|
|
12472
|
-
message.stops = Object.entries((_a = object.stops) !== null && _a !== void 0 ? _a : {}).reduce((acc, [key, value]) => {
|
|
12473
|
-
if (value !== undefined) {
|
|
12474
|
-
acc[globalThis.Number(key)] = StopsAdjacency_StopAdjacency.fromPartial(value);
|
|
12475
|
-
}
|
|
12476
|
-
return acc;
|
|
12477
|
-
}, {});
|
|
12478
|
-
return message;
|
|
12479
|
-
},
|
|
12480
|
-
};
|
|
12481
|
-
function createBaseStopsAdjacency_StopAdjacency() {
|
|
12309
|
+
function createBaseStopAdjacency() {
|
|
12482
12310
|
return { transfers: [], routes: [] };
|
|
12483
12311
|
}
|
|
12484
|
-
const
|
|
12312
|
+
const StopAdjacency = {
|
|
12485
12313
|
encode(message, writer = new BinaryWriter()) {
|
|
12486
12314
|
for (const v of message.transfers) {
|
|
12487
12315
|
Transfer.encode(v, writer.uint32(10).fork()).join();
|
|
12488
12316
|
}
|
|
12489
12317
|
writer.uint32(18).fork();
|
|
12490
12318
|
for (const v of message.routes) {
|
|
12491
|
-
writer.
|
|
12319
|
+
writer.uint32(v);
|
|
12492
12320
|
}
|
|
12493
12321
|
writer.join();
|
|
12494
12322
|
return writer;
|
|
@@ -12496,7 +12324,7 @@ const StopsAdjacency_StopAdjacency = {
|
|
|
12496
12324
|
decode(input, length) {
|
|
12497
12325
|
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
12498
12326
|
const end = length === undefined ? reader.len : reader.pos + length;
|
|
12499
|
-
const message =
|
|
12327
|
+
const message = createBaseStopAdjacency();
|
|
12500
12328
|
while (reader.pos < end) {
|
|
12501
12329
|
const tag = reader.uint32();
|
|
12502
12330
|
switch (tag >>> 3) {
|
|
@@ -12509,13 +12337,13 @@ const StopsAdjacency_StopAdjacency = {
|
|
|
12509
12337
|
}
|
|
12510
12338
|
case 2: {
|
|
12511
12339
|
if (tag === 16) {
|
|
12512
|
-
message.routes.push(reader.
|
|
12340
|
+
message.routes.push(reader.uint32());
|
|
12513
12341
|
continue;
|
|
12514
12342
|
}
|
|
12515
12343
|
if (tag === 18) {
|
|
12516
12344
|
const end2 = reader.uint32() + reader.pos;
|
|
12517
12345
|
while (reader.pos < end2) {
|
|
12518
|
-
message.routes.push(reader.
|
|
12346
|
+
message.routes.push(reader.uint32());
|
|
12519
12347
|
}
|
|
12520
12348
|
continue;
|
|
12521
12349
|
}
|
|
@@ -12549,87 +12377,16 @@ const StopsAdjacency_StopAdjacency = {
|
|
|
12549
12377
|
return obj;
|
|
12550
12378
|
},
|
|
12551
12379
|
create(base) {
|
|
12552
|
-
return
|
|
12380
|
+
return StopAdjacency.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
12553
12381
|
},
|
|
12554
12382
|
fromPartial(object) {
|
|
12555
12383
|
var _a, _b;
|
|
12556
|
-
const message =
|
|
12384
|
+
const message = createBaseStopAdjacency();
|
|
12557
12385
|
message.transfers = ((_a = object.transfers) === null || _a === void 0 ? void 0 : _a.map((e) => Transfer.fromPartial(e))) || [];
|
|
12558
12386
|
message.routes = ((_b = object.routes) === null || _b === void 0 ? void 0 : _b.map((e) => e)) || [];
|
|
12559
12387
|
return message;
|
|
12560
12388
|
},
|
|
12561
12389
|
};
|
|
12562
|
-
function createBaseStopsAdjacency_StopsEntry() {
|
|
12563
|
-
return { key: 0, value: undefined };
|
|
12564
|
-
}
|
|
12565
|
-
const StopsAdjacency_StopsEntry = {
|
|
12566
|
-
encode(message, writer = new BinaryWriter()) {
|
|
12567
|
-
if (message.key !== 0) {
|
|
12568
|
-
writer.uint32(8).uint32(message.key);
|
|
12569
|
-
}
|
|
12570
|
-
if (message.value !== undefined) {
|
|
12571
|
-
StopsAdjacency_StopAdjacency.encode(message.value, writer.uint32(18).fork()).join();
|
|
12572
|
-
}
|
|
12573
|
-
return writer;
|
|
12574
|
-
},
|
|
12575
|
-
decode(input, length) {
|
|
12576
|
-
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
12577
|
-
const end = length === undefined ? reader.len : reader.pos + length;
|
|
12578
|
-
const message = createBaseStopsAdjacency_StopsEntry();
|
|
12579
|
-
while (reader.pos < end) {
|
|
12580
|
-
const tag = reader.uint32();
|
|
12581
|
-
switch (tag >>> 3) {
|
|
12582
|
-
case 1: {
|
|
12583
|
-
if (tag !== 8) {
|
|
12584
|
-
break;
|
|
12585
|
-
}
|
|
12586
|
-
message.key = reader.uint32();
|
|
12587
|
-
continue;
|
|
12588
|
-
}
|
|
12589
|
-
case 2: {
|
|
12590
|
-
if (tag !== 18) {
|
|
12591
|
-
break;
|
|
12592
|
-
}
|
|
12593
|
-
message.value = StopsAdjacency_StopAdjacency.decode(reader, reader.uint32());
|
|
12594
|
-
continue;
|
|
12595
|
-
}
|
|
12596
|
-
}
|
|
12597
|
-
if ((tag & 7) === 4 || tag === 0) {
|
|
12598
|
-
break;
|
|
12599
|
-
}
|
|
12600
|
-
reader.skip(tag & 7);
|
|
12601
|
-
}
|
|
12602
|
-
return message;
|
|
12603
|
-
},
|
|
12604
|
-
fromJSON(object) {
|
|
12605
|
-
return {
|
|
12606
|
-
key: isSet(object.key) ? globalThis.Number(object.key) : 0,
|
|
12607
|
-
value: isSet(object.value) ? StopsAdjacency_StopAdjacency.fromJSON(object.value) : undefined,
|
|
12608
|
-
};
|
|
12609
|
-
},
|
|
12610
|
-
toJSON(message) {
|
|
12611
|
-
const obj = {};
|
|
12612
|
-
if (message.key !== 0) {
|
|
12613
|
-
obj.key = Math.round(message.key);
|
|
12614
|
-
}
|
|
12615
|
-
if (message.value !== undefined) {
|
|
12616
|
-
obj.value = StopsAdjacency_StopAdjacency.toJSON(message.value);
|
|
12617
|
-
}
|
|
12618
|
-
return obj;
|
|
12619
|
-
},
|
|
12620
|
-
create(base) {
|
|
12621
|
-
return StopsAdjacency_StopsEntry.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
12622
|
-
},
|
|
12623
|
-
fromPartial(object) {
|
|
12624
|
-
var _a;
|
|
12625
|
-
const message = createBaseStopsAdjacency_StopsEntry();
|
|
12626
|
-
message.key = (_a = object.key) !== null && _a !== void 0 ? _a : 0;
|
|
12627
|
-
message.value = (object.value !== undefined && object.value !== null)
|
|
12628
|
-
? StopsAdjacency_StopAdjacency.fromPartial(object.value)
|
|
12629
|
-
: undefined;
|
|
12630
|
-
return message;
|
|
12631
|
-
},
|
|
12632
|
-
};
|
|
12633
12390
|
function createBaseServiceRoute() {
|
|
12634
12391
|
return { type: 0, name: "", routes: [] };
|
|
12635
12392
|
}
|
|
@@ -12643,7 +12400,7 @@ const ServiceRoute = {
|
|
|
12643
12400
|
}
|
|
12644
12401
|
writer.uint32(26).fork();
|
|
12645
12402
|
for (const v of message.routes) {
|
|
12646
|
-
writer.
|
|
12403
|
+
writer.uint32(v);
|
|
12647
12404
|
}
|
|
12648
12405
|
writer.join();
|
|
12649
12406
|
return writer;
|
|
@@ -12671,13 +12428,13 @@ const ServiceRoute = {
|
|
|
12671
12428
|
}
|
|
12672
12429
|
case 3: {
|
|
12673
12430
|
if (tag === 24) {
|
|
12674
|
-
message.routes.push(reader.
|
|
12431
|
+
message.routes.push(reader.uint32());
|
|
12675
12432
|
continue;
|
|
12676
12433
|
}
|
|
12677
12434
|
if (tag === 26) {
|
|
12678
12435
|
const end2 = reader.uint32() + reader.pos;
|
|
12679
12436
|
while (reader.pos < end2) {
|
|
12680
|
-
message.routes.push(reader.
|
|
12437
|
+
message.routes.push(reader.uint32());
|
|
12681
12438
|
}
|
|
12682
12439
|
continue;
|
|
12683
12440
|
}
|
|
@@ -12724,166 +12481,22 @@ const ServiceRoute = {
|
|
|
12724
12481
|
return message;
|
|
12725
12482
|
},
|
|
12726
12483
|
};
|
|
12727
|
-
function createBaseServiceRoutesMap() {
|
|
12728
|
-
return { routes: {} };
|
|
12729
|
-
}
|
|
12730
|
-
const ServiceRoutesMap = {
|
|
12731
|
-
encode(message, writer = new BinaryWriter()) {
|
|
12732
|
-
Object.entries(message.routes).forEach(([key, value]) => {
|
|
12733
|
-
ServiceRoutesMap_RoutesEntry.encode({ key: key, value }, writer.uint32(10).fork()).join();
|
|
12734
|
-
});
|
|
12735
|
-
return writer;
|
|
12736
|
-
},
|
|
12737
|
-
decode(input, length) {
|
|
12738
|
-
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
12739
|
-
const end = length === undefined ? reader.len : reader.pos + length;
|
|
12740
|
-
const message = createBaseServiceRoutesMap();
|
|
12741
|
-
while (reader.pos < end) {
|
|
12742
|
-
const tag = reader.uint32();
|
|
12743
|
-
switch (tag >>> 3) {
|
|
12744
|
-
case 1: {
|
|
12745
|
-
if (tag !== 10) {
|
|
12746
|
-
break;
|
|
12747
|
-
}
|
|
12748
|
-
const entry1 = ServiceRoutesMap_RoutesEntry.decode(reader, reader.uint32());
|
|
12749
|
-
if (entry1.value !== undefined) {
|
|
12750
|
-
message.routes[entry1.key] = entry1.value;
|
|
12751
|
-
}
|
|
12752
|
-
continue;
|
|
12753
|
-
}
|
|
12754
|
-
}
|
|
12755
|
-
if ((tag & 7) === 4 || tag === 0) {
|
|
12756
|
-
break;
|
|
12757
|
-
}
|
|
12758
|
-
reader.skip(tag & 7);
|
|
12759
|
-
}
|
|
12760
|
-
return message;
|
|
12761
|
-
},
|
|
12762
|
-
fromJSON(object) {
|
|
12763
|
-
return {
|
|
12764
|
-
routes: isObject(object.routes)
|
|
12765
|
-
? Object.entries(object.routes).reduce((acc, [key, value]) => {
|
|
12766
|
-
acc[key] = ServiceRoute.fromJSON(value);
|
|
12767
|
-
return acc;
|
|
12768
|
-
}, {})
|
|
12769
|
-
: {},
|
|
12770
|
-
};
|
|
12771
|
-
},
|
|
12772
|
-
toJSON(message) {
|
|
12773
|
-
const obj = {};
|
|
12774
|
-
if (message.routes) {
|
|
12775
|
-
const entries = Object.entries(message.routes);
|
|
12776
|
-
if (entries.length > 0) {
|
|
12777
|
-
obj.routes = {};
|
|
12778
|
-
entries.forEach(([k, v]) => {
|
|
12779
|
-
obj.routes[k] = ServiceRoute.toJSON(v);
|
|
12780
|
-
});
|
|
12781
|
-
}
|
|
12782
|
-
}
|
|
12783
|
-
return obj;
|
|
12784
|
-
},
|
|
12785
|
-
create(base) {
|
|
12786
|
-
return ServiceRoutesMap.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
12787
|
-
},
|
|
12788
|
-
fromPartial(object) {
|
|
12789
|
-
var _a;
|
|
12790
|
-
const message = createBaseServiceRoutesMap();
|
|
12791
|
-
message.routes = Object.entries((_a = object.routes) !== null && _a !== void 0 ? _a : {}).reduce((acc, [key, value]) => {
|
|
12792
|
-
if (value !== undefined) {
|
|
12793
|
-
acc[key] = ServiceRoute.fromPartial(value);
|
|
12794
|
-
}
|
|
12795
|
-
return acc;
|
|
12796
|
-
}, {});
|
|
12797
|
-
return message;
|
|
12798
|
-
},
|
|
12799
|
-
};
|
|
12800
|
-
function createBaseServiceRoutesMap_RoutesEntry() {
|
|
12801
|
-
return { key: "", value: undefined };
|
|
12802
|
-
}
|
|
12803
|
-
const ServiceRoutesMap_RoutesEntry = {
|
|
12804
|
-
encode(message, writer = new BinaryWriter()) {
|
|
12805
|
-
if (message.key !== "") {
|
|
12806
|
-
writer.uint32(10).string(message.key);
|
|
12807
|
-
}
|
|
12808
|
-
if (message.value !== undefined) {
|
|
12809
|
-
ServiceRoute.encode(message.value, writer.uint32(18).fork()).join();
|
|
12810
|
-
}
|
|
12811
|
-
return writer;
|
|
12812
|
-
},
|
|
12813
|
-
decode(input, length) {
|
|
12814
|
-
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
12815
|
-
const end = length === undefined ? reader.len : reader.pos + length;
|
|
12816
|
-
const message = createBaseServiceRoutesMap_RoutesEntry();
|
|
12817
|
-
while (reader.pos < end) {
|
|
12818
|
-
const tag = reader.uint32();
|
|
12819
|
-
switch (tag >>> 3) {
|
|
12820
|
-
case 1: {
|
|
12821
|
-
if (tag !== 10) {
|
|
12822
|
-
break;
|
|
12823
|
-
}
|
|
12824
|
-
message.key = reader.string();
|
|
12825
|
-
continue;
|
|
12826
|
-
}
|
|
12827
|
-
case 2: {
|
|
12828
|
-
if (tag !== 18) {
|
|
12829
|
-
break;
|
|
12830
|
-
}
|
|
12831
|
-
message.value = ServiceRoute.decode(reader, reader.uint32());
|
|
12832
|
-
continue;
|
|
12833
|
-
}
|
|
12834
|
-
}
|
|
12835
|
-
if ((tag & 7) === 4 || tag === 0) {
|
|
12836
|
-
break;
|
|
12837
|
-
}
|
|
12838
|
-
reader.skip(tag & 7);
|
|
12839
|
-
}
|
|
12840
|
-
return message;
|
|
12841
|
-
},
|
|
12842
|
-
fromJSON(object) {
|
|
12843
|
-
return {
|
|
12844
|
-
key: isSet(object.key) ? globalThis.String(object.key) : "",
|
|
12845
|
-
value: isSet(object.value) ? ServiceRoute.fromJSON(object.value) : undefined,
|
|
12846
|
-
};
|
|
12847
|
-
},
|
|
12848
|
-
toJSON(message) {
|
|
12849
|
-
const obj = {};
|
|
12850
|
-
if (message.key !== "") {
|
|
12851
|
-
obj.key = message.key;
|
|
12852
|
-
}
|
|
12853
|
-
if (message.value !== undefined) {
|
|
12854
|
-
obj.value = ServiceRoute.toJSON(message.value);
|
|
12855
|
-
}
|
|
12856
|
-
return obj;
|
|
12857
|
-
},
|
|
12858
|
-
create(base) {
|
|
12859
|
-
return ServiceRoutesMap_RoutesEntry.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
12860
|
-
},
|
|
12861
|
-
fromPartial(object) {
|
|
12862
|
-
var _a;
|
|
12863
|
-
const message = createBaseServiceRoutesMap_RoutesEntry();
|
|
12864
|
-
message.key = (_a = object.key) !== null && _a !== void 0 ? _a : "";
|
|
12865
|
-
message.value = (object.value !== undefined && object.value !== null)
|
|
12866
|
-
? ServiceRoute.fromPartial(object.value)
|
|
12867
|
-
: undefined;
|
|
12868
|
-
return message;
|
|
12869
|
-
},
|
|
12870
|
-
};
|
|
12871
12484
|
function createBaseTimetable() {
|
|
12872
|
-
return { version: "", stopsAdjacency:
|
|
12485
|
+
return { version: "", stopsAdjacency: [], routesAdjacency: [], serviceRoutes: [] };
|
|
12873
12486
|
}
|
|
12874
12487
|
const Timetable$1 = {
|
|
12875
12488
|
encode(message, writer = new BinaryWriter()) {
|
|
12876
12489
|
if (message.version !== "") {
|
|
12877
12490
|
writer.uint32(10).string(message.version);
|
|
12878
12491
|
}
|
|
12879
|
-
|
|
12880
|
-
|
|
12492
|
+
for (const v of message.stopsAdjacency) {
|
|
12493
|
+
StopAdjacency.encode(v, writer.uint32(18).fork()).join();
|
|
12881
12494
|
}
|
|
12882
12495
|
for (const v of message.routesAdjacency) {
|
|
12883
12496
|
Route$1.encode(v, writer.uint32(26).fork()).join();
|
|
12884
12497
|
}
|
|
12885
|
-
|
|
12886
|
-
|
|
12498
|
+
for (const v of message.serviceRoutes) {
|
|
12499
|
+
ServiceRoute.encode(v, writer.uint32(34).fork()).join();
|
|
12887
12500
|
}
|
|
12888
12501
|
return writer;
|
|
12889
12502
|
},
|
|
@@ -12905,7 +12518,7 @@ const Timetable$1 = {
|
|
|
12905
12518
|
if (tag !== 18) {
|
|
12906
12519
|
break;
|
|
12907
12520
|
}
|
|
12908
|
-
message.stopsAdjacency
|
|
12521
|
+
message.stopsAdjacency.push(StopAdjacency.decode(reader, reader.uint32()));
|
|
12909
12522
|
continue;
|
|
12910
12523
|
}
|
|
12911
12524
|
case 3: {
|
|
@@ -12919,7 +12532,7 @@ const Timetable$1 = {
|
|
|
12919
12532
|
if (tag !== 34) {
|
|
12920
12533
|
break;
|
|
12921
12534
|
}
|
|
12922
|
-
message.
|
|
12535
|
+
message.serviceRoutes.push(ServiceRoute.decode(reader, reader.uint32()));
|
|
12923
12536
|
continue;
|
|
12924
12537
|
}
|
|
12925
12538
|
}
|
|
@@ -12933,27 +12546,31 @@ const Timetable$1 = {
|
|
|
12933
12546
|
fromJSON(object) {
|
|
12934
12547
|
return {
|
|
12935
12548
|
version: isSet(object.version) ? globalThis.String(object.version) : "",
|
|
12936
|
-
stopsAdjacency:
|
|
12549
|
+
stopsAdjacency: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.stopsAdjacency)
|
|
12550
|
+
? object.stopsAdjacency.map((e) => StopAdjacency.fromJSON(e))
|
|
12551
|
+
: [],
|
|
12937
12552
|
routesAdjacency: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.routesAdjacency)
|
|
12938
12553
|
? object.routesAdjacency.map((e) => Route$1.fromJSON(e))
|
|
12939
12554
|
: [],
|
|
12940
|
-
|
|
12555
|
+
serviceRoutes: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.serviceRoutes)
|
|
12556
|
+
? object.serviceRoutes.map((e) => ServiceRoute.fromJSON(e))
|
|
12557
|
+
: [],
|
|
12941
12558
|
};
|
|
12942
12559
|
},
|
|
12943
12560
|
toJSON(message) {
|
|
12944
|
-
var _a;
|
|
12561
|
+
var _a, _b, _c;
|
|
12945
12562
|
const obj = {};
|
|
12946
12563
|
if (message.version !== "") {
|
|
12947
12564
|
obj.version = message.version;
|
|
12948
12565
|
}
|
|
12949
|
-
if (message.stopsAdjacency
|
|
12950
|
-
obj.stopsAdjacency =
|
|
12566
|
+
if ((_a = message.stopsAdjacency) === null || _a === void 0 ? void 0 : _a.length) {
|
|
12567
|
+
obj.stopsAdjacency = message.stopsAdjacency.map((e) => StopAdjacency.toJSON(e));
|
|
12951
12568
|
}
|
|
12952
|
-
if ((
|
|
12569
|
+
if ((_b = message.routesAdjacency) === null || _b === void 0 ? void 0 : _b.length) {
|
|
12953
12570
|
obj.routesAdjacency = message.routesAdjacency.map((e) => Route$1.toJSON(e));
|
|
12954
12571
|
}
|
|
12955
|
-
if (message.
|
|
12956
|
-
obj.
|
|
12572
|
+
if ((_c = message.serviceRoutes) === null || _c === void 0 ? void 0 : _c.length) {
|
|
12573
|
+
obj.serviceRoutes = message.serviceRoutes.map((e) => ServiceRoute.toJSON(e));
|
|
12957
12574
|
}
|
|
12958
12575
|
return obj;
|
|
12959
12576
|
},
|
|
@@ -12961,16 +12578,12 @@ const Timetable$1 = {
|
|
|
12961
12578
|
return Timetable$1.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
12962
12579
|
},
|
|
12963
12580
|
fromPartial(object) {
|
|
12964
|
-
var _a, _b;
|
|
12581
|
+
var _a, _b, _c, _d;
|
|
12965
12582
|
const message = createBaseTimetable();
|
|
12966
12583
|
message.version = (_a = object.version) !== null && _a !== void 0 ? _a : "";
|
|
12967
|
-
message.stopsAdjacency = (object.stopsAdjacency
|
|
12968
|
-
|
|
12969
|
-
|
|
12970
|
-
message.routesAdjacency = ((_b = object.routesAdjacency) === null || _b === void 0 ? void 0 : _b.map((e) => Route$1.fromPartial(e))) || [];
|
|
12971
|
-
message.routes = (object.routes !== undefined && object.routes !== null)
|
|
12972
|
-
? ServiceRoutesMap.fromPartial(object.routes)
|
|
12973
|
-
: undefined;
|
|
12584
|
+
message.stopsAdjacency = ((_b = object.stopsAdjacency) === null || _b === void 0 ? void 0 : _b.map((e) => StopAdjacency.fromPartial(e))) || [];
|
|
12585
|
+
message.routesAdjacency = ((_c = object.routesAdjacency) === null || _c === void 0 ? void 0 : _c.map((e) => Route$1.fromPartial(e))) || [];
|
|
12586
|
+
message.serviceRoutes = ((_d = object.serviceRoutes) === null || _d === void 0 ? void 0 : _d.map((e) => ServiceRoute.fromPartial(e))) || [];
|
|
12974
12587
|
return message;
|
|
12975
12588
|
},
|
|
12976
12589
|
};
|
|
@@ -12999,9 +12612,6 @@ function base64FromBytes(arr) {
|
|
|
12999
12612
|
return globalThis.btoa(bin.join(""));
|
|
13000
12613
|
}
|
|
13001
12614
|
}
|
|
13002
|
-
function isObject(value) {
|
|
13003
|
-
return typeof value === "object" && value !== null;
|
|
13004
|
-
}
|
|
13005
12615
|
function isSet(value) {
|
|
13006
12616
|
return value !== null && value !== undefined;
|
|
13007
12617
|
}
|
|
@@ -13379,27 +12989,6 @@ class Route {
|
|
|
13379
12989
|
: byte & 0x03; // Lower 2 bits for first pair
|
|
13380
12990
|
return toPickupDropOffType(dropOffValue);
|
|
13381
12991
|
}
|
|
13382
|
-
/**
|
|
13383
|
-
* Iterates over the stops in the route, starting from an optional specified stop.
|
|
13384
|
-
* If no start stop is provided, the iteration begins from the first stop in the route.
|
|
13385
|
-
*
|
|
13386
|
-
* @param [startStopId] - (Optional) The StopId of the stop to start the iteration from.
|
|
13387
|
-
* @returns An IterableIterator of StopIds, starting from the specified stop or the first stop.
|
|
13388
|
-
* @throws An error if the specified start stop is not found in the route.
|
|
13389
|
-
*/
|
|
13390
|
-
stopsIterator(startStopId) {
|
|
13391
|
-
const startIndex = startStopId !== undefined ? this.stopIndices.get(startStopId) : 0;
|
|
13392
|
-
if (startIndex === undefined) {
|
|
13393
|
-
throw new Error(`Start stop ${startStopId} not found in route ${this.serviceRouteId}`);
|
|
13394
|
-
}
|
|
13395
|
-
function* generator(stops, startIndex) {
|
|
13396
|
-
for (let i = startIndex; i < stops.length; i++) {
|
|
13397
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
13398
|
-
yield stops[i];
|
|
13399
|
-
}
|
|
13400
|
-
}
|
|
13401
|
-
return generator(this.stops, startIndex);
|
|
13402
|
-
}
|
|
13403
12992
|
/**
|
|
13404
12993
|
* Finds the earliest trip that can be taken from a specific stop on a given route,
|
|
13405
12994
|
* optionally constrained by a latest trip index and a time before which the trip
|
|
@@ -13517,18 +13106,14 @@ const bytesToUint16Array = (bytes) => {
|
|
|
13517
13106
|
return result;
|
|
13518
13107
|
};
|
|
13519
13108
|
const serializeStopsAdjacency = (stopsAdjacency) => {
|
|
13520
|
-
|
|
13521
|
-
|
|
13522
|
-
};
|
|
13523
|
-
stopsAdjacency.forEach((value, key) => {
|
|
13524
|
-
protoStopsAdjacency.stops[key] = {
|
|
13109
|
+
return stopsAdjacency.map((value) => {
|
|
13110
|
+
return {
|
|
13525
13111
|
transfers: value.transfers.map((transfer) => (Object.assign({ destination: transfer.destination, type: serializeTransferType(transfer.type) }, (transfer.minTransferTime !== undefined && {
|
|
13526
13112
|
minTransferTime: transfer.minTransferTime.toSeconds(),
|
|
13527
13113
|
})))),
|
|
13528
13114
|
routes: value.routes,
|
|
13529
13115
|
};
|
|
13530
13116
|
});
|
|
13531
|
-
return protoStopsAdjacency;
|
|
13532
13117
|
};
|
|
13533
13118
|
const serializeRoutesAdjacency = (routesAdjacency) => {
|
|
13534
13119
|
const protoRoutesAdjacency = [];
|
|
@@ -13543,50 +13128,58 @@ const serializeRoutesAdjacency = (routesAdjacency) => {
|
|
|
13543
13128
|
});
|
|
13544
13129
|
return protoRoutesAdjacency;
|
|
13545
13130
|
};
|
|
13546
|
-
const serializeServiceRoutesMap = (
|
|
13547
|
-
|
|
13548
|
-
|
|
13549
|
-
};
|
|
13550
|
-
serviceRoutesMap.forEach((value, key) => {
|
|
13551
|
-
protoServiceRoutesMap.routes[key] = {
|
|
13131
|
+
const serializeServiceRoutesMap = (serviceRoutes) => {
|
|
13132
|
+
return serviceRoutes.map((value) => {
|
|
13133
|
+
return {
|
|
13552
13134
|
type: serializeRouteType(value.type),
|
|
13553
13135
|
name: value.name,
|
|
13554
13136
|
routes: value.routes,
|
|
13555
13137
|
};
|
|
13556
13138
|
});
|
|
13557
|
-
return protoServiceRoutesMap;
|
|
13558
13139
|
};
|
|
13559
13140
|
const deserializeStopsAdjacency = (protoStopsAdjacency) => {
|
|
13560
|
-
const
|
|
13561
|
-
|
|
13562
|
-
|
|
13563
|
-
|
|
13564
|
-
|
|
13141
|
+
const result = [];
|
|
13142
|
+
for (let i = 0; i < protoStopsAdjacency.length; i++) {
|
|
13143
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
13144
|
+
const value = protoStopsAdjacency[i];
|
|
13145
|
+
const transfers = [];
|
|
13146
|
+
for (let j = 0; j < value.transfers.length; j++) {
|
|
13147
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
13148
|
+
const transfer = value.transfers[j];
|
|
13149
|
+
const newTransfer = Object.assign({ destination: transfer.destination, type: parseTransferType(transfer.type) }, (transfer.minTransferTime !== undefined && {
|
|
13565
13150
|
minTransferTime: Duration.fromSeconds(transfer.minTransferTime),
|
|
13566
|
-
}))
|
|
13151
|
+
}));
|
|
13152
|
+
transfers.push(newTransfer);
|
|
13153
|
+
}
|
|
13154
|
+
result.push({
|
|
13155
|
+
transfers: transfers,
|
|
13567
13156
|
routes: value.routes,
|
|
13568
13157
|
});
|
|
13569
|
-
}
|
|
13570
|
-
return
|
|
13158
|
+
}
|
|
13159
|
+
return result;
|
|
13571
13160
|
};
|
|
13572
13161
|
const deserializeRoutesAdjacency = (protoRoutesAdjacency) => {
|
|
13573
13162
|
const routesAdjacency = [];
|
|
13574
|
-
protoRoutesAdjacency.
|
|
13163
|
+
for (let i = 0; i < protoRoutesAdjacency.length; i++) {
|
|
13164
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
13165
|
+
const value = protoRoutesAdjacency[i];
|
|
13575
13166
|
const stops = bytesToUint32Array(value.stops);
|
|
13576
13167
|
routesAdjacency.push(new Route(bytesToUint16Array(value.stopTimes), value.pickUpDropOffTypes, stops, value.serviceRouteId));
|
|
13577
|
-
}
|
|
13168
|
+
}
|
|
13578
13169
|
return routesAdjacency;
|
|
13579
13170
|
};
|
|
13580
|
-
const deserializeServiceRoutesMap = (
|
|
13581
|
-
const
|
|
13582
|
-
|
|
13583
|
-
|
|
13171
|
+
const deserializeServiceRoutesMap = (protoServiceRoutes) => {
|
|
13172
|
+
const result = [];
|
|
13173
|
+
for (let i = 0; i < protoServiceRoutes.length; i++) {
|
|
13174
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
13175
|
+
const value = protoServiceRoutes[i];
|
|
13176
|
+
result.push({
|
|
13584
13177
|
type: parseRouteType(value.type),
|
|
13585
13178
|
name: value.name,
|
|
13586
13179
|
routes: value.routes,
|
|
13587
13180
|
});
|
|
13588
|
-
}
|
|
13589
|
-
return
|
|
13181
|
+
}
|
|
13182
|
+
return result;
|
|
13590
13183
|
};
|
|
13591
13184
|
const parseTransferType = (type) => {
|
|
13592
13185
|
switch (type) {
|
|
@@ -13678,7 +13271,7 @@ const ALL_TRANSPORT_MODES = new Set([
|
|
|
13678
13271
|
'TROLLEYBUS',
|
|
13679
13272
|
'MONORAIL',
|
|
13680
13273
|
]);
|
|
13681
|
-
const CURRENT_VERSION = '0.0.
|
|
13274
|
+
const CURRENT_VERSION = '0.0.7';
|
|
13682
13275
|
/**
|
|
13683
13276
|
* The internal transit timetable format.
|
|
13684
13277
|
*/
|
|
@@ -13686,7 +13279,15 @@ class Timetable {
|
|
|
13686
13279
|
constructor(stopsAdjacency, routesAdjacency, routes) {
|
|
13687
13280
|
this.stopsAdjacency = stopsAdjacency;
|
|
13688
13281
|
this.routesAdjacency = routesAdjacency;
|
|
13689
|
-
this.
|
|
13282
|
+
this.serviceRoutes = routes;
|
|
13283
|
+
this.activeStops = new Set();
|
|
13284
|
+
for (let i = 0; i < stopsAdjacency.length; i++) {
|
|
13285
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
13286
|
+
const stop = stopsAdjacency[i];
|
|
13287
|
+
if (stop.routes.length > 0 || stop.transfers.length > 0) {
|
|
13288
|
+
this.activeStops.add(i);
|
|
13289
|
+
}
|
|
13290
|
+
}
|
|
13690
13291
|
}
|
|
13691
13292
|
/**
|
|
13692
13293
|
* Serializes the Timetable into a binary array.
|
|
@@ -13698,7 +13299,7 @@ class Timetable {
|
|
|
13698
13299
|
version: CURRENT_VERSION,
|
|
13699
13300
|
stopsAdjacency: serializeStopsAdjacency(this.stopsAdjacency),
|
|
13700
13301
|
routesAdjacency: serializeRoutesAdjacency(this.routesAdjacency),
|
|
13701
|
-
|
|
13302
|
+
serviceRoutes: serializeServiceRoutesMap(this.serviceRoutes),
|
|
13702
13303
|
};
|
|
13703
13304
|
const writer = new BinaryWriter();
|
|
13704
13305
|
Timetable$1.encode(protoTimetable, writer);
|
|
@@ -13716,11 +13317,18 @@ class Timetable {
|
|
|
13716
13317
|
if (protoTimetable.version !== CURRENT_VERSION) {
|
|
13717
13318
|
throw new Error(`Unsupported timetable version ${protoTimetable.version}`);
|
|
13718
13319
|
}
|
|
13719
|
-
return new Timetable(
|
|
13720
|
-
|
|
13721
|
-
|
|
13722
|
-
|
|
13723
|
-
|
|
13320
|
+
return new Timetable(deserializeStopsAdjacency(protoTimetable.stopsAdjacency), deserializeRoutesAdjacency(protoTimetable.routesAdjacency), deserializeServiceRoutesMap(protoTimetable.serviceRoutes));
|
|
13321
|
+
}
|
|
13322
|
+
/**
|
|
13323
|
+
* Checks if the given stop is active on the timetable.
|
|
13324
|
+
* An active stop is a stop reached by a route that is active on the timetable
|
|
13325
|
+
* or by a transfer reachable from an active route.
|
|
13326
|
+
*
|
|
13327
|
+
* @param stopId - The ID of the stop to check.
|
|
13328
|
+
* @returns True if the stop is active, false otherwise.
|
|
13329
|
+
*/
|
|
13330
|
+
isActive(stopId) {
|
|
13331
|
+
return this.activeStops.has(stopId);
|
|
13724
13332
|
}
|
|
13725
13333
|
/**
|
|
13726
13334
|
* Retrieves the route associated with the given route ID.
|
|
@@ -13740,7 +13348,7 @@ class Timetable {
|
|
|
13740
13348
|
*/
|
|
13741
13349
|
getTransfers(stopId) {
|
|
13742
13350
|
var _a, _b;
|
|
13743
|
-
return (_b = (_a = this.stopsAdjacency
|
|
13351
|
+
return (_b = (_a = this.stopsAdjacency[stopId]) === null || _a === void 0 ? void 0 : _a.transfers) !== null && _b !== void 0 ? _b : [];
|
|
13744
13352
|
}
|
|
13745
13353
|
/**
|
|
13746
13354
|
* Retrieves the service route associated with the given route.
|
|
@@ -13751,7 +13359,7 @@ class Timetable {
|
|
|
13751
13359
|
* @returns The service route corresponding to the provided route.
|
|
13752
13360
|
*/
|
|
13753
13361
|
getServiceRouteInfo(route) {
|
|
13754
|
-
const serviceRoute = this.
|
|
13362
|
+
const serviceRoute = this.serviceRoutes[route.serviceRoute()];
|
|
13755
13363
|
if (!serviceRoute) {
|
|
13756
13364
|
throw new Error(`Service route not found for route ID: ${route.serviceRoute()}`);
|
|
13757
13365
|
}
|
|
@@ -13766,12 +13374,13 @@ class Timetable {
|
|
|
13766
13374
|
* @returns An array of routes passing through the specified stop.
|
|
13767
13375
|
*/
|
|
13768
13376
|
routesPassingThrough(stopId) {
|
|
13769
|
-
const stopData = this.stopsAdjacency
|
|
13377
|
+
const stopData = this.stopsAdjacency[stopId];
|
|
13770
13378
|
if (!stopData) {
|
|
13771
13379
|
return [];
|
|
13772
13380
|
}
|
|
13773
13381
|
const routes = [];
|
|
13774
|
-
for (
|
|
13382
|
+
for (let i = 0; i < stopData.routes.length; i++) {
|
|
13383
|
+
const routeId = stopData.routes[i];
|
|
13775
13384
|
const route = this.routesAdjacency[routeId];
|
|
13776
13385
|
if (route) {
|
|
13777
13386
|
routes.push(route);
|
|
@@ -13790,12 +13399,15 @@ class Timetable {
|
|
|
13790
13399
|
*/
|
|
13791
13400
|
findReachableRoutes(fromStops, transportModes = ALL_TRANSPORT_MODES) {
|
|
13792
13401
|
const reachableRoutes = new Map();
|
|
13793
|
-
|
|
13402
|
+
const fromStopsArray = Array.from(fromStops);
|
|
13403
|
+
for (let i = 0; i < fromStopsArray.length; i++) {
|
|
13404
|
+
const originStop = fromStopsArray[i];
|
|
13794
13405
|
const validRoutes = this.routesPassingThrough(originStop).filter((route) => {
|
|
13795
13406
|
const serviceRoute = this.getServiceRouteInfo(route);
|
|
13796
13407
|
return transportModes.has(serviceRoute.type);
|
|
13797
13408
|
});
|
|
13798
|
-
for (
|
|
13409
|
+
for (let j = 0; j < validRoutes.length; j++) {
|
|
13410
|
+
const route = validRoutes[j];
|
|
13799
13411
|
const hopOnStop = reachableRoutes.get(route);
|
|
13800
13412
|
if (hopOnStop) {
|
|
13801
13413
|
if (route.isBefore(originStop, hopOnStop)) {
|
|
@@ -15797,7 +15409,6 @@ const parseRoutes = (routesStream_1, ...args_1) => __awaiter(void 0, [routesStre
|
|
|
15797
15409
|
routes.set(line.route_id, {
|
|
15798
15410
|
name: line.route_short_name,
|
|
15799
15411
|
type: routeType,
|
|
15800
|
-
routes: [],
|
|
15801
15412
|
});
|
|
15802
15413
|
}
|
|
15803
15414
|
}
|
|
@@ -15810,6 +15421,29 @@ const parseRoutes = (routesStream_1, ...args_1) => __awaiter(void 0, [routesStre
|
|
|
15810
15421
|
}
|
|
15811
15422
|
return routes;
|
|
15812
15423
|
});
|
|
15424
|
+
/**
|
|
15425
|
+
* Creates an array of ServiceRoute objects by combining GTFS route data with service route mappings.
|
|
15426
|
+
*
|
|
15427
|
+
* @param gtfsRoutesMap A map containing GTFS route information indexed by route ID
|
|
15428
|
+
* @param serviceRoutesMap A map linking GTFS route IDs to service route IDs
|
|
15429
|
+
* @returns An array of ServiceRoute objects with route information
|
|
15430
|
+
*/
|
|
15431
|
+
const indexRoutes = (gtfsRoutesMap, serviceRoutesMap) => {
|
|
15432
|
+
const serviceRoutes = new Array(serviceRoutesMap.size);
|
|
15433
|
+
for (const [gtfsRouteId, serviceRouteId] of serviceRoutesMap) {
|
|
15434
|
+
const route = gtfsRoutesMap.get(gtfsRouteId);
|
|
15435
|
+
if (route === undefined) {
|
|
15436
|
+
log.warn(`Route ${gtfsRouteId} not found.`);
|
|
15437
|
+
continue;
|
|
15438
|
+
}
|
|
15439
|
+
serviceRoutes[serviceRouteId] = {
|
|
15440
|
+
name: route.name,
|
|
15441
|
+
type: route.type,
|
|
15442
|
+
routes: [],
|
|
15443
|
+
};
|
|
15444
|
+
}
|
|
15445
|
+
return serviceRoutes;
|
|
15446
|
+
};
|
|
15813
15447
|
|
|
15814
15448
|
const toGtfsDate = (date) => {
|
|
15815
15449
|
return parseInt(date.toFormat('yyyyLLdd'));
|
|
@@ -15977,37 +15611,6 @@ const parseStops = (stopsStream) => __awaiter(void 0, void 0, void 0, function*
|
|
|
15977
15611
|
}
|
|
15978
15612
|
return parsedStops;
|
|
15979
15613
|
});
|
|
15980
|
-
/**
|
|
15981
|
-
* Builds the final stop map indexed by internal IDs.
|
|
15982
|
-
* Excludes all stops that do not have at least one valid stopId
|
|
15983
|
-
* as a child, a parent, or being valid itself.
|
|
15984
|
-
*
|
|
15985
|
-
* @param parsedStops - The map of parsed stops.
|
|
15986
|
-
* @param validStops - A set of valid stop IDs.
|
|
15987
|
-
* @returns A map of stops indexed by internal IDs.
|
|
15988
|
-
*/
|
|
15989
|
-
const indexStops = (parsedStops, validStops) => {
|
|
15990
|
-
const stops = new Map();
|
|
15991
|
-
for (const [, stop] of parsedStops) {
|
|
15992
|
-
if (!validStops ||
|
|
15993
|
-
validStops.has(stop.id) ||
|
|
15994
|
-
(stop.parent && validStops.has(stop.parent)) ||
|
|
15995
|
-
stop.children.some((childId) => validStops.has(childId))) {
|
|
15996
|
-
stops.set(stop.id, {
|
|
15997
|
-
id: stop.id,
|
|
15998
|
-
sourceStopId: stop.sourceStopId,
|
|
15999
|
-
name: stop.name,
|
|
16000
|
-
lat: stop.lat,
|
|
16001
|
-
lon: stop.lon,
|
|
16002
|
-
locationType: stop.locationType,
|
|
16003
|
-
platform: stop.platform,
|
|
16004
|
-
children: stop.children.filter((childId) => !validStops || validStops.has(childId)),
|
|
16005
|
-
parent: stop.parent,
|
|
16006
|
-
});
|
|
16007
|
-
}
|
|
16008
|
-
}
|
|
16009
|
-
return stops;
|
|
16010
|
-
};
|
|
16011
15614
|
const parseGtfsLocationType = (gtfsLocationType) => {
|
|
16012
15615
|
switch (gtfsLocationType) {
|
|
16013
15616
|
case 0:
|
|
@@ -16184,7 +15787,7 @@ const finalizeRouteFromBuilder = (builder) => {
|
|
|
16184
15787
|
* @param serviceRoutes A mapping of route IDs to route details.
|
|
16185
15788
|
* @returns A mapping of trip IDs to corresponding route IDs.
|
|
16186
15789
|
*/
|
|
16187
|
-
const parseTrips = (tripsStream, serviceIds,
|
|
15790
|
+
const parseTrips = (tripsStream, serviceIds, validGtfsRoutes) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16188
15791
|
var _a, e_1, _b, _c;
|
|
16189
15792
|
const trips = new Map();
|
|
16190
15793
|
try {
|
|
@@ -16197,7 +15800,7 @@ const parseTrips = (tripsStream, serviceIds, serviceRoutes) => __awaiter(void 0,
|
|
|
16197
15800
|
// The trip doesn't correspond to an active service
|
|
16198
15801
|
continue;
|
|
16199
15802
|
}
|
|
16200
|
-
if (!
|
|
15803
|
+
if (!validGtfsRoutes.has(line.route_id)) {
|
|
16201
15804
|
// The trip doesn't correspond to a supported route
|
|
16202
15805
|
continue;
|
|
16203
15806
|
}
|
|
@@ -16213,29 +15816,38 @@ const parseTrips = (tripsStream, serviceIds, serviceRoutes) => __awaiter(void 0,
|
|
|
16213
15816
|
}
|
|
16214
15817
|
return trips;
|
|
16215
15818
|
});
|
|
16216
|
-
const buildStopsAdjacencyStructure = (
|
|
16217
|
-
|
|
16218
|
-
|
|
16219
|
-
|
|
16220
|
-
|
|
16221
|
-
|
|
16222
|
-
|
|
15819
|
+
const buildStopsAdjacencyStructure = (serviceRoutes, routes, transfersMap, nbStops, activeStops) => {
|
|
15820
|
+
// TODO somehow works when it's a map
|
|
15821
|
+
const stopsAdjacency = new Array(nbStops);
|
|
15822
|
+
for (let i = 0; i < nbStops; i++) {
|
|
15823
|
+
stopsAdjacency[i] = { routes: [], transfers: [] };
|
|
15824
|
+
}
|
|
15825
|
+
for (let index = 0; index < routes.length; index++) {
|
|
15826
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
15827
|
+
const route = routes[index];
|
|
15828
|
+
for (let j = 0; j < route.getNbStops(); j++) {
|
|
15829
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
15830
|
+
const stop = route.stops[j];
|
|
15831
|
+
if (activeStops.has(stop)) {
|
|
15832
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
15833
|
+
stopsAdjacency[stop].routes.push(index);
|
|
16223
15834
|
}
|
|
16224
|
-
(_a = stopsAdjacency.get(stop)) === null || _a === void 0 ? void 0 : _a.routes.push(index);
|
|
16225
15835
|
}
|
|
16226
|
-
const serviceRoute = serviceRoutes
|
|
16227
|
-
if (
|
|
15836
|
+
const serviceRoute = serviceRoutes[route.serviceRoute()];
|
|
15837
|
+
if (serviceRoute === undefined) {
|
|
16228
15838
|
throw new Error(`Service route ${route.serviceRoute()} not found for route ${index}.`);
|
|
16229
15839
|
}
|
|
16230
15840
|
serviceRoute.routes.push(index);
|
|
16231
|
-
}
|
|
15841
|
+
}
|
|
16232
15842
|
for (const [stop, transfers] of transfersMap) {
|
|
16233
|
-
|
|
16234
|
-
|
|
16235
|
-
|
|
16236
|
-
|
|
16237
|
-
|
|
16238
|
-
|
|
15843
|
+
for (let i = 0; i < transfers.length; i++) {
|
|
15844
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
15845
|
+
const transfer = transfers[i];
|
|
15846
|
+
if (activeStops.has(stop) || activeStops.has(transfer.destination)) {
|
|
15847
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
15848
|
+
stopsAdjacency[stop].transfers.push(transfer);
|
|
15849
|
+
activeStops.add(transfer.destination);
|
|
15850
|
+
activeStops.add(stop);
|
|
16239
15851
|
}
|
|
16240
15852
|
}
|
|
16241
15853
|
}
|
|
@@ -16246,18 +15858,18 @@ const buildStopsAdjacencyStructure = (validStops, serviceRoutes, routes, transfe
|
|
|
16246
15858
|
*
|
|
16247
15859
|
* @param stopTimesStream The readable stream containing the stop times data.
|
|
16248
15860
|
* @param stopsMap A map of parsed stops from the GTFS feed.
|
|
16249
|
-
* @param
|
|
16250
|
-
* @param
|
|
15861
|
+
* @param activeTripIds A map of valid trip IDs to corresponding route IDs.
|
|
15862
|
+
* @param activeStopIds A set of valid stop IDs.
|
|
16251
15863
|
* @returns A mapping of route IDs to route details. The routes returned correspond to the set of trips from GTFS that share the same stop list.
|
|
16252
15864
|
*/
|
|
16253
|
-
const parseStopTimes = (stopTimesStream, stopsMap,
|
|
15865
|
+
const parseStopTimes = (stopTimesStream, stopsMap, activeTripIds, activeStopIds) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16254
15866
|
var _a, e_2, _b, _c;
|
|
16255
15867
|
var _d, _e;
|
|
16256
15868
|
/**
|
|
16257
15869
|
* Adds a trip to the appropriate route builder
|
|
16258
15870
|
*/
|
|
16259
15871
|
const addTrip = (currentTripId) => {
|
|
16260
|
-
const gtfsRouteId =
|
|
15872
|
+
const gtfsRouteId = activeTripIds.get(currentTripId);
|
|
16261
15873
|
if (!gtfsRouteId || stops.length === 0) {
|
|
16262
15874
|
stops = [];
|
|
16263
15875
|
arrivalTimes = [];
|
|
@@ -16266,7 +15878,6 @@ const parseStopTimes = (stopTimesStream, stopsMap, validTripIds, validStopIds) =
|
|
|
16266
15878
|
dropOffTypes = [];
|
|
16267
15879
|
return;
|
|
16268
15880
|
}
|
|
16269
|
-
const routeId = `${gtfsRouteId}_${hashIds(stops)}`;
|
|
16270
15881
|
const firstDeparture = departureTimes[0];
|
|
16271
15882
|
if (firstDeparture === undefined) {
|
|
16272
15883
|
console.warn(`Empty trip ${currentTripId}`);
|
|
@@ -16277,24 +15888,31 @@ const parseStopTimes = (stopTimesStream, stopsMap, validTripIds, validStopIds) =
|
|
|
16277
15888
|
dropOffTypes = [];
|
|
16278
15889
|
return;
|
|
16279
15890
|
}
|
|
15891
|
+
const routeId = `${gtfsRouteId}_${hashIds(stops)}`;
|
|
16280
15892
|
let routeBuilder = routeBuilders.get(routeId);
|
|
16281
15893
|
if (!routeBuilder) {
|
|
15894
|
+
let serviceRouteId = serviceRoutesMap.get(gtfsRouteId);
|
|
15895
|
+
if (serviceRouteId === undefined) {
|
|
15896
|
+
serviceRouteId = currentServiceRouteId;
|
|
15897
|
+
serviceRoutesMap.set(gtfsRouteId, serviceRouteId);
|
|
15898
|
+
currentServiceRouteId = currentServiceRouteId + 1;
|
|
15899
|
+
}
|
|
16282
15900
|
routeBuilder = {
|
|
16283
|
-
serviceRouteId
|
|
16284
|
-
stops
|
|
15901
|
+
serviceRouteId,
|
|
15902
|
+
stops,
|
|
16285
15903
|
trips: [],
|
|
16286
15904
|
};
|
|
16287
15905
|
routeBuilders.set(routeId, routeBuilder);
|
|
16288
15906
|
for (const stop of stops) {
|
|
16289
|
-
|
|
15907
|
+
activeStopIds.add(stop);
|
|
16290
15908
|
}
|
|
16291
15909
|
}
|
|
16292
15910
|
routeBuilder.trips.push({
|
|
16293
15911
|
firstDeparture,
|
|
16294
|
-
arrivalTimes:
|
|
16295
|
-
departureTimes:
|
|
16296
|
-
pickUpTypes:
|
|
16297
|
-
dropOffTypes:
|
|
15912
|
+
arrivalTimes: arrivalTimes,
|
|
15913
|
+
departureTimes: departureTimes,
|
|
15914
|
+
pickUpTypes: pickUpTypes,
|
|
15915
|
+
dropOffTypes: dropOffTypes,
|
|
16298
15916
|
});
|
|
16299
15917
|
stops = [];
|
|
16300
15918
|
arrivalTimes = [];
|
|
@@ -16303,6 +15921,9 @@ const parseStopTimes = (stopTimesStream, stopsMap, validTripIds, validStopIds) =
|
|
|
16303
15921
|
dropOffTypes = [];
|
|
16304
15922
|
};
|
|
16305
15923
|
const routeBuilders = new Map();
|
|
15924
|
+
const serviceRoutesMap = new Map();
|
|
15925
|
+
// incrementally generate service route IDs
|
|
15926
|
+
let currentServiceRouteId = 0;
|
|
16306
15927
|
let previousSeq = 0;
|
|
16307
15928
|
let stops = [];
|
|
16308
15929
|
let arrivalTimes = [];
|
|
@@ -16365,7 +15986,7 @@ const parseStopTimes = (stopTimesStream, stopsMap, validTripIds, validStopIds) =
|
|
|
16365
15986
|
const routeData = finalizeRouteFromBuilder(routeBuilder);
|
|
16366
15987
|
routesAdjacency.push(new Route(routeData.stopTimes, routeData.pickUpDropOffTypes, routeData.stops, routeData.serviceRouteId));
|
|
16367
15988
|
}
|
|
16368
|
-
return routesAdjacency;
|
|
15989
|
+
return { routes: routesAdjacency, serviceRoutesMap };
|
|
16369
15990
|
});
|
|
16370
15991
|
const parsePickupDropOffType = (gtfsType) => {
|
|
16371
15992
|
switch (gtfsType) {
|
|
@@ -16399,18 +16020,16 @@ class GtfsParser {
|
|
|
16399
16020
|
* Parses a GTFS feed to extract all the data relevant to a given day in a transit-planner friendly format.
|
|
16400
16021
|
*
|
|
16401
16022
|
* @param date The active date.
|
|
16402
|
-
* @
|
|
16403
|
-
* @param gtfsProfile The GTFS profile configuration.
|
|
16404
|
-
* @returns An object containing the timetable and stops map.
|
|
16023
|
+
* @returns The parsed timetable.
|
|
16405
16024
|
*/
|
|
16406
|
-
|
|
16025
|
+
parseTimetable(date) {
|
|
16407
16026
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16408
16027
|
log.setLevel('INFO');
|
|
16409
16028
|
const zip = new StreamZip.async({ file: this.path });
|
|
16410
16029
|
const entries = yield zip.entries();
|
|
16411
16030
|
const datetime = DateTime.fromJSDate(date);
|
|
16412
|
-
const
|
|
16413
|
-
const
|
|
16031
|
+
const activeServiceIds = new Set();
|
|
16032
|
+
const activeStopIds = new Set();
|
|
16414
16033
|
log.info(`Parsing ${STOPS_FILE}`);
|
|
16415
16034
|
const stopsStart = performance.now();
|
|
16416
16035
|
const stopsStream = yield zip.stream(STOPS_FILE);
|
|
@@ -16421,17 +16040,17 @@ class GtfsParser {
|
|
|
16421
16040
|
log.info(`Parsing ${CALENDAR_FILE}`);
|
|
16422
16041
|
const calendarStart = performance.now();
|
|
16423
16042
|
const calendarStream = yield zip.stream(CALENDAR_FILE);
|
|
16424
|
-
yield parseCalendar(calendarStream,
|
|
16043
|
+
yield parseCalendar(calendarStream, activeServiceIds, datetime);
|
|
16425
16044
|
const calendarEnd = performance.now();
|
|
16426
|
-
log.info(`${
|
|
16045
|
+
log.info(`${activeServiceIds.size} valid services. (${(calendarEnd - calendarStart).toFixed(2)}ms)`);
|
|
16427
16046
|
}
|
|
16428
16047
|
if (entries[CALENDAR_DATES_FILE]) {
|
|
16429
16048
|
log.info(`Parsing ${CALENDAR_DATES_FILE}`);
|
|
16430
16049
|
const calendarDatesStart = performance.now();
|
|
16431
16050
|
const calendarDatesStream = yield zip.stream(CALENDAR_DATES_FILE);
|
|
16432
|
-
yield parseCalendarDates(calendarDatesStream,
|
|
16051
|
+
yield parseCalendarDates(calendarDatesStream, activeServiceIds, datetime);
|
|
16433
16052
|
const calendarDatesEnd = performance.now();
|
|
16434
|
-
log.info(`${
|
|
16053
|
+
log.info(`${activeServiceIds.size} valid services. (${(calendarDatesEnd - calendarDatesStart).toFixed(2)}ms)`);
|
|
16435
16054
|
}
|
|
16436
16055
|
log.info(`Parsing ${ROUTES_FILE}`);
|
|
16437
16056
|
const routesStart = performance.now();
|
|
@@ -16442,7 +16061,7 @@ class GtfsParser {
|
|
|
16442
16061
|
log.info(`Parsing ${TRIPS_FILE}`);
|
|
16443
16062
|
const tripsStart = performance.now();
|
|
16444
16063
|
const tripsStream = yield zip.stream(TRIPS_FILE);
|
|
16445
|
-
const trips = yield parseTrips(tripsStream,
|
|
16064
|
+
const trips = yield parseTrips(tripsStream, activeServiceIds, validGtfsRoutes);
|
|
16446
16065
|
const tripsEnd = performance.now();
|
|
16447
16066
|
log.info(`${trips.size} valid trips. (${(tripsEnd - tripsStart).toFixed(2)}ms)`);
|
|
16448
16067
|
let transfers = new Map();
|
|
@@ -16457,32 +16076,26 @@ class GtfsParser {
|
|
|
16457
16076
|
log.info(`Parsing ${STOP_TIMES_FILE}`);
|
|
16458
16077
|
const stopTimesStart = performance.now();
|
|
16459
16078
|
const stopTimesStream = yield zip.stream(STOP_TIMES_FILE);
|
|
16460
|
-
const
|
|
16461
|
-
const
|
|
16079
|
+
const { routes, serviceRoutesMap } = yield parseStopTimes(stopTimesStream, parsedStops, trips, activeStopIds);
|
|
16080
|
+
const serviceRoutes = indexRoutes(validGtfsRoutes, serviceRoutesMap);
|
|
16462
16081
|
const stopTimesEnd = performance.now();
|
|
16463
|
-
log.info(`${
|
|
16464
|
-
log.info(
|
|
16465
|
-
const
|
|
16466
|
-
const
|
|
16467
|
-
const
|
|
16468
|
-
log.info(`${
|
|
16082
|
+
log.info(`${routes.length} valid unique routes. (${(stopTimesEnd - stopTimesStart).toFixed(2)}ms)`);
|
|
16083
|
+
log.info('Building stops adjacency structure');
|
|
16084
|
+
const stopsAdjacencyStart = performance.now();
|
|
16085
|
+
const stopsAdjacency = buildStopsAdjacencyStructure(serviceRoutes, routes, transfers, parsedStops.size, activeStopIds);
|
|
16086
|
+
const stopsAdjacencyEnd = performance.now();
|
|
16087
|
+
log.info(`${stopsAdjacency.length} valid stops in the structure. (${(stopsAdjacencyEnd - stopsAdjacencyStart).toFixed(2)}ms)`);
|
|
16469
16088
|
yield zip.close();
|
|
16470
|
-
const timetable = new Timetable(stopsAdjacency,
|
|
16471
|
-
log.info(`Building stops index.`);
|
|
16472
|
-
const stopsIndexStart = performance.now();
|
|
16473
|
-
const stopsIndex = new StopsIndex(stops);
|
|
16474
|
-
const stopsIndexEnd = performance.now();
|
|
16475
|
-
log.info(`Stops index built. (${(stopsIndexEnd - stopsIndexStart).toFixed(2)}ms)`);
|
|
16089
|
+
const timetable = new Timetable(stopsAdjacency, routes, serviceRoutes);
|
|
16476
16090
|
log.info('Parsing complete.');
|
|
16477
|
-
return
|
|
16091
|
+
return timetable;
|
|
16478
16092
|
});
|
|
16479
16093
|
}
|
|
16480
16094
|
/**
|
|
16481
16095
|
* Parses a GTFS feed to extract all stops.
|
|
16482
16096
|
*
|
|
16483
|
-
* @param
|
|
16484
|
-
* @
|
|
16485
|
-
* @returns An object containing the timetable and stops map.
|
|
16097
|
+
* @param activeStops The set of active stop IDs to include in the index.
|
|
16098
|
+
* @returns An index of stops.
|
|
16486
16099
|
*/
|
|
16487
16100
|
parseStops() {
|
|
16488
16101
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -16490,11 +16103,11 @@ class GtfsParser {
|
|
|
16490
16103
|
log.info(`Parsing ${STOPS_FILE}`);
|
|
16491
16104
|
const stopsStart = performance.now();
|
|
16492
16105
|
const stopsStream = yield zip.stream(STOPS_FILE);
|
|
16493
|
-
const stops =
|
|
16106
|
+
const stops = yield parseStops(stopsStream);
|
|
16494
16107
|
const stopsEnd = performance.now();
|
|
16495
16108
|
log.info(`${stops.size} parsed stops. (${(stopsEnd - stopsStart).toFixed(2)}ms)`);
|
|
16496
16109
|
yield zip.close();
|
|
16497
|
-
return new StopsIndex(stops);
|
|
16110
|
+
return new StopsIndex(Array.from(stops.values()));
|
|
16498
16111
|
});
|
|
16499
16112
|
}
|
|
16500
16113
|
}
|