minotor 5.0.0 → 6.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 +3 -4
- package/dist/cli.mjs +212 -632
- package/dist/cli.mjs.map +1 -1
- package/dist/gtfs/parser.d.ts +4 -13
- package/dist/gtfs/routes.d.ts +16 -2
- package/dist/gtfs/stops.d.ts +3 -14
- package/dist/gtfs/transfers.d.ts +2 -2
- package/dist/gtfs/trips.d.ts +12 -8
- package/dist/parser.cjs.js +206 -629
- package/dist/parser.cjs.js.map +1 -1
- package/dist/parser.esm.js +206 -629
- 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/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 +7 -137
- package/src/gtfs/__tests__/transfers.test.ts +7 -7
- package/src/gtfs/__tests__/trips.test.ts +74 -45
- package/src/gtfs/parser.ts +34 -57
- package/src/gtfs/profiles/__tests__/ch.test.ts +0 -28
- package/src/gtfs/profiles/ch.ts +1 -18
- package/src/gtfs/profiles/standard.ts +0 -9
- package/src/gtfs/routes.ts +43 -5
- package/src/gtfs/stops.ts +4 -56
- package/src/gtfs/transfers.ts +2 -2
- package/src/gtfs/trips.ts +57 -40
- package/src/routing/__tests__/result.test.ts +48 -48
- package/src/routing/__tests__/router.test.ts +279 -363
- package/src/routing/router.ts +3 -1
- 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 +20 -26
- package/src/timetable/__tests__/io.test.ts +44 -54
- package/src/timetable/__tests__/route.test.ts +11 -11
- package/src/timetable/__tests__/timetable.test.ts +29 -37
- package/src/timetable/io.ts +38 -66
- package/src/timetable/proto/timetable.proto +6 -13
- package/src/timetable/proto/timetable.ts +43 -385
- package/src/timetable/timetable.ts +43 -28
package/src/routing/router.ts
CHANGED
|
@@ -186,6 +186,8 @@ export class Router {
|
|
|
186
186
|
for (const [route, hopOnStop] of reachableRoutes.entries()) {
|
|
187
187
|
let currentTrip: CurrentTrip | undefined = undefined;
|
|
188
188
|
for (const currentStop of route.stopsIterator(hopOnStop)) {
|
|
189
|
+
// If we're currently on a trip,
|
|
190
|
+
// check if arrival at the stop improves the earliest arrival time
|
|
189
191
|
if (currentTrip !== undefined) {
|
|
190
192
|
const currentArrivalTime = route.arrivalAt(
|
|
191
193
|
currentStop,
|
|
@@ -230,7 +232,7 @@ export class Router {
|
|
|
230
232
|
markedStops.add(currentStop);
|
|
231
233
|
}
|
|
232
234
|
}
|
|
233
|
-
// check if we can
|
|
235
|
+
// check if we can board an earlier trip at the current stop
|
|
234
236
|
// if there was no current trip, find the first one reachable
|
|
235
237
|
const earliestArrivalOnPreviousRound =
|
|
236
238
|
arrivalsAtPreviousRound.get(currentStop)?.arrival;
|
|
@@ -2,39 +2,33 @@ import assert from 'node:assert';
|
|
|
2
2
|
import { describe, it } from 'node:test';
|
|
3
3
|
|
|
4
4
|
import { deserializeStopsMap, serializeStopsMap } from '../io.js';
|
|
5
|
-
import {
|
|
5
|
+
import { Stop } from '../stops.js';
|
|
6
6
|
|
|
7
7
|
describe('Stops IO', () => {
|
|
8
|
-
const stopsMap:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
parent: 1,
|
|
33
|
-
locationType: 'STATION',
|
|
34
|
-
platform: 'Platform 2',
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
]);
|
|
8
|
+
const stopsMap: Stop[] = [
|
|
9
|
+
{
|
|
10
|
+
id: 0,
|
|
11
|
+
sourceStopId: 'stop1',
|
|
12
|
+
name: 'Stop 1',
|
|
13
|
+
lat: 40.712776,
|
|
14
|
+
lon: -74.005974,
|
|
15
|
+
children: [1],
|
|
16
|
+
parent: undefined,
|
|
17
|
+
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
18
|
+
platform: 'Platform 1',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: 1,
|
|
22
|
+
sourceStopId: 'stop2',
|
|
23
|
+
name: 'Stop 2',
|
|
24
|
+
lat: 34.052235,
|
|
25
|
+
lon: -118.243683,
|
|
26
|
+
children: [],
|
|
27
|
+
parent: 0,
|
|
28
|
+
locationType: 'STATION',
|
|
29
|
+
platform: 'Platform 2',
|
|
30
|
+
},
|
|
31
|
+
];
|
|
38
32
|
it('should serialize and deserialize stops correctly', () => {
|
|
39
33
|
const serializedData = serializeStopsMap(stopsMap);
|
|
40
34
|
const deserializedStopsMap = deserializeStopsMap(serializedData);
|
|
@@ -1,97 +1,76 @@
|
|
|
1
1
|
import assert from 'node:assert';
|
|
2
2
|
import { beforeEach, describe, it } from 'node:test';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { Stop } from '../stops.js';
|
|
5
5
|
import { StopsIndex } from '../stopsIndex.js';
|
|
6
|
-
const mockStops:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
4,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
lat: 46.8031492395272,
|
|
75
|
-
lon: 7.15104780338173,
|
|
76
|
-
children: [],
|
|
77
|
-
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
78
|
-
parent: 4,
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
[
|
|
82
|
-
7,
|
|
83
|
-
{
|
|
84
|
-
id: 7,
|
|
85
|
-
sourceStopId: '8504100:0:2',
|
|
86
|
-
name: 'Fribourg/Freiburg',
|
|
87
|
-
lat: 46.8031492395272,
|
|
88
|
-
lon: 7.15104780338173,
|
|
89
|
-
children: [],
|
|
90
|
-
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
91
|
-
parent: 4,
|
|
92
|
-
},
|
|
93
|
-
],
|
|
94
|
-
]);
|
|
6
|
+
const mockStops: Stop[] = [
|
|
7
|
+
{
|
|
8
|
+
id: 0,
|
|
9
|
+
sourceStopId: '8587255',
|
|
10
|
+
name: 'Fribourg, Tilleul/Cathédrale',
|
|
11
|
+
lat: 46.8061375857565,
|
|
12
|
+
lon: 7.16145029437328,
|
|
13
|
+
children: [],
|
|
14
|
+
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
id: 1,
|
|
18
|
+
sourceStopId: '8592383',
|
|
19
|
+
name: 'Fribourg, Neuveville/Court-Ch.',
|
|
20
|
+
lat: 46.8042990960992,
|
|
21
|
+
lon: 7.16060587800609,
|
|
22
|
+
children: [],
|
|
23
|
+
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: 2,
|
|
27
|
+
sourceStopId: '8592386',
|
|
28
|
+
name: 'Fribourg, Petit-St-Jean',
|
|
29
|
+
lat: 46.8035550740648,
|
|
30
|
+
lon: 7.16806189486532,
|
|
31
|
+
children: [],
|
|
32
|
+
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: 3,
|
|
36
|
+
sourceStopId: 'Parent8504100',
|
|
37
|
+
name: 'Fribourg/Freiburg',
|
|
38
|
+
lat: 46.8031492395272,
|
|
39
|
+
lon: 7.15104780338173,
|
|
40
|
+
children: [4, 5, 6],
|
|
41
|
+
locationType: 'STATION',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: 4,
|
|
45
|
+
sourceStopId: '8504100:0:1',
|
|
46
|
+
name: 'Fribourg/Freiburg',
|
|
47
|
+
lat: 46.8031492395272,
|
|
48
|
+
lon: 7.15104780338173,
|
|
49
|
+
children: [],
|
|
50
|
+
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
51
|
+
parent: 3,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: 5,
|
|
55
|
+
sourceStopId: '8504100:0:1AB',
|
|
56
|
+
name: 'Fribourg/Freiburg',
|
|
57
|
+
lat: 46.8031492395272,
|
|
58
|
+
lon: 7.15104780338173,
|
|
59
|
+
children: [],
|
|
60
|
+
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
61
|
+
parent: 3,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: 6,
|
|
65
|
+
sourceStopId: '8504100:0:2',
|
|
66
|
+
name: 'Fribourg/Freiburg',
|
|
67
|
+
lat: 46.8031492395272,
|
|
68
|
+
lon: 7.15104780338173,
|
|
69
|
+
children: [],
|
|
70
|
+
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
71
|
+
parent: 3,
|
|
72
|
+
},
|
|
73
|
+
];
|
|
95
74
|
|
|
96
75
|
describe('Stop Finder', () => {
|
|
97
76
|
let stopFinder: StopsIndex;
|
|
@@ -105,25 +84,25 @@ describe('Stop Finder', () => {
|
|
|
105
84
|
const results = stopFinder.findStopsByName(
|
|
106
85
|
'Fribourg, Tilleul/Cathédrale',
|
|
107
86
|
);
|
|
108
|
-
assert.strictEqual(results[0]?.id,
|
|
87
|
+
assert.strictEqual(results[0]?.id, 0);
|
|
109
88
|
});
|
|
110
89
|
|
|
111
90
|
it('should not include children stops', () => {
|
|
112
91
|
const results = stopFinder.findStopsByName('Fribourg/Freiburg', 2);
|
|
113
|
-
assert.strictEqual(results[0]?.id,
|
|
114
|
-
assert.strictEqual(results[1]?.id,
|
|
92
|
+
assert.strictEqual(results[0]?.id, 3);
|
|
93
|
+
assert.strictEqual(results[1]?.id, 0);
|
|
115
94
|
});
|
|
116
95
|
|
|
117
96
|
it('should find stops by partial name', () => {
|
|
118
97
|
const results = stopFinder.findStopsByName('Cathédrale');
|
|
119
98
|
assert.strictEqual(results.length, 1);
|
|
120
|
-
assert.strictEqual(results[0]?.id,
|
|
99
|
+
assert.strictEqual(results[0]?.id, 0);
|
|
121
100
|
});
|
|
122
101
|
|
|
123
102
|
it('should find stops by name with accents', () => {
|
|
124
103
|
const results = stopFinder.findStopsByName('Cathedrale');
|
|
125
104
|
assert.strictEqual(results.length, 1);
|
|
126
|
-
assert.strictEqual(results[0]?.id,
|
|
105
|
+
assert.strictEqual(results[0]?.id, 0);
|
|
127
106
|
});
|
|
128
107
|
|
|
129
108
|
it('should return an empty array if no stops match the query', () => {
|
|
@@ -136,22 +115,22 @@ describe('Stop Finder', () => {
|
|
|
136
115
|
it('should find stops by geographic location', () => {
|
|
137
116
|
const results = stopFinder.findStopsByLocation(46.8061, 7.1614, 1);
|
|
138
117
|
assert.strictEqual(results.length, 1);
|
|
139
|
-
assert.strictEqual(results[0]?.id,
|
|
118
|
+
assert.strictEqual(results[0]?.id, 0);
|
|
140
119
|
});
|
|
141
120
|
|
|
142
121
|
it('should find multiple stops within the radius', () => {
|
|
143
122
|
const results = stopFinder.findStopsByLocation(46.8, 7.16, 10, 0.75);
|
|
144
123
|
assert.strictEqual(results.length, 3);
|
|
145
|
-
assert.strictEqual(results[0]?.id,
|
|
146
|
-
assert.strictEqual(results[1]?.id,
|
|
147
|
-
assert.strictEqual(results[2]?.id,
|
|
124
|
+
assert.strictEqual(results[0]?.id, 1);
|
|
125
|
+
assert.strictEqual(results[1]?.id, 0);
|
|
126
|
+
assert.strictEqual(results[2]?.id, 2);
|
|
148
127
|
});
|
|
149
128
|
|
|
150
129
|
it('should find the N closest stops', () => {
|
|
151
130
|
const results = stopFinder.findStopsByLocation(46.8, 7.16, 2, 10);
|
|
152
131
|
assert.strictEqual(results.length, 2);
|
|
153
|
-
assert.strictEqual(results[0]?.id,
|
|
154
|
-
assert.strictEqual(results[1]?.id,
|
|
132
|
+
assert.strictEqual(results[0]?.id, 1);
|
|
133
|
+
assert.strictEqual(results[1]?.id, 0);
|
|
155
134
|
});
|
|
156
135
|
|
|
157
136
|
it('should return an empty array if no stops are within the radius', () => {
|
|
@@ -174,7 +153,7 @@ describe('Stop Finder', () => {
|
|
|
174
153
|
const equivalentStops = stopFinder.equivalentStops('8504100:0:1');
|
|
175
154
|
assert.deepStrictEqual(
|
|
176
155
|
equivalentStops.map((stop) => stop.id),
|
|
177
|
-
[5, 6
|
|
156
|
+
[4, 5, 6],
|
|
178
157
|
);
|
|
179
158
|
});
|
|
180
159
|
|
|
@@ -182,7 +161,7 @@ describe('Stop Finder', () => {
|
|
|
182
161
|
const equivalentStops = stopFinder.equivalentStops('8587255');
|
|
183
162
|
assert.deepStrictEqual(
|
|
184
163
|
equivalentStops.map((stop) => stop.id),
|
|
185
|
-
[
|
|
164
|
+
[0],
|
|
186
165
|
);
|
|
187
166
|
});
|
|
188
167
|
|
package/src/stops/io.ts
CHANGED
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
Stop as ProtoStop,
|
|
4
4
|
StopsMap as ProtoStopsMap,
|
|
5
5
|
} from './proto/stops.js';
|
|
6
|
-
import { LocationType, Stop
|
|
6
|
+
import { LocationType, Stop } from './stops.js';
|
|
7
7
|
|
|
8
|
-
const CURRENT_VERSION = '0.0.
|
|
8
|
+
const CURRENT_VERSION = '0.0.3';
|
|
9
9
|
const serializeStop = (stop: Stop): ProtoStop => {
|
|
10
10
|
return {
|
|
11
11
|
name: stop.name,
|
|
@@ -19,16 +19,12 @@ const serializeStop = (stop: Stop): ProtoStop => {
|
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
export const serializeStopsMap = (
|
|
22
|
+
export const serializeStopsMap = (stops: Stop[]): ProtoStopsMap => {
|
|
23
23
|
const protoStopsMap: ProtoStopsMap = {
|
|
24
24
|
version: CURRENT_VERSION,
|
|
25
|
-
stops:
|
|
25
|
+
stops: stops.map((value) => serializeStop(value)),
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
stopsMap.forEach((value: Stop, key: number) => {
|
|
29
|
-
protoStopsMap.stops[key] = serializeStop(value);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
28
|
return protoStopsMap;
|
|
33
29
|
};
|
|
34
30
|
|
|
@@ -46,18 +42,13 @@ const deserializeStop = (stopId: number, protoStop: ProtoStop): Stop => {
|
|
|
46
42
|
};
|
|
47
43
|
};
|
|
48
44
|
|
|
49
|
-
export const deserializeStopsMap = (protoStopsMap: ProtoStopsMap):
|
|
45
|
+
export const deserializeStopsMap = (protoStopsMap: ProtoStopsMap): Stop[] => {
|
|
50
46
|
if (protoStopsMap.version !== CURRENT_VERSION) {
|
|
51
47
|
throw new Error(`Unsupported stopMap version ${protoStopsMap.version}`);
|
|
52
48
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const intKey = parseInt(key, 10);
|
|
57
|
-
stopsMap.set(intKey, deserializeStop(intKey, value));
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
return stopsMap;
|
|
49
|
+
return protoStopsMap.stops.map((value, intKey) =>
|
|
50
|
+
deserializeStop(intKey, value),
|
|
51
|
+
);
|
|
61
52
|
};
|
|
62
53
|
|
|
63
54
|
const parseProtoLocationType = (
|
|
@@ -13,8 +13,8 @@ enum LocationType {
|
|
|
13
13
|
message Stop {
|
|
14
14
|
string name = 1;
|
|
15
15
|
string sourceStopId = 2;
|
|
16
|
-
optional
|
|
17
|
-
optional
|
|
16
|
+
optional float lat = 3;
|
|
17
|
+
optional float lon = 4;
|
|
18
18
|
repeated uint32 children = 5;
|
|
19
19
|
optional uint32 parent = 6;
|
|
20
20
|
LocationType locationType = 7;
|
|
@@ -23,5 +23,5 @@ message Stop {
|
|
|
23
23
|
|
|
24
24
|
message StopsMap {
|
|
25
25
|
string version = 1;
|
|
26
|
-
|
|
26
|
+
repeated Stop stops = 2;
|
|
27
27
|
}
|
package/src/stops/proto/stops.ts
CHANGED
|
@@ -73,12 +73,7 @@ export interface Stop {
|
|
|
73
73
|
|
|
74
74
|
export interface StopsMap {
|
|
75
75
|
version: string;
|
|
76
|
-
stops:
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export interface StopsMap_StopsEntry {
|
|
80
|
-
key: number;
|
|
81
|
-
value: Stop | undefined;
|
|
76
|
+
stops: Stop[];
|
|
82
77
|
}
|
|
83
78
|
|
|
84
79
|
function createBaseStop(): Stop {
|
|
@@ -103,10 +98,10 @@ export const Stop: MessageFns<Stop> = {
|
|
|
103
98
|
writer.uint32(18).string(message.sourceStopId);
|
|
104
99
|
}
|
|
105
100
|
if (message.lat !== undefined) {
|
|
106
|
-
writer.uint32(
|
|
101
|
+
writer.uint32(29).float(message.lat);
|
|
107
102
|
}
|
|
108
103
|
if (message.lon !== undefined) {
|
|
109
|
-
writer.uint32(
|
|
104
|
+
writer.uint32(37).float(message.lon);
|
|
110
105
|
}
|
|
111
106
|
writer.uint32(42).fork();
|
|
112
107
|
for (const v of message.children) {
|
|
@@ -149,19 +144,19 @@ export const Stop: MessageFns<Stop> = {
|
|
|
149
144
|
continue;
|
|
150
145
|
}
|
|
151
146
|
case 3: {
|
|
152
|
-
if (tag !==
|
|
147
|
+
if (tag !== 29) {
|
|
153
148
|
break;
|
|
154
149
|
}
|
|
155
150
|
|
|
156
|
-
message.lat = reader.
|
|
151
|
+
message.lat = reader.float();
|
|
157
152
|
continue;
|
|
158
153
|
}
|
|
159
154
|
case 4: {
|
|
160
|
-
if (tag !==
|
|
155
|
+
if (tag !== 37) {
|
|
161
156
|
break;
|
|
162
157
|
}
|
|
163
158
|
|
|
164
|
-
message.lon = reader.
|
|
159
|
+
message.lon = reader.float();
|
|
165
160
|
continue;
|
|
166
161
|
}
|
|
167
162
|
case 5: {
|
|
@@ -275,7 +270,7 @@ export const Stop: MessageFns<Stop> = {
|
|
|
275
270
|
};
|
|
276
271
|
|
|
277
272
|
function createBaseStopsMap(): StopsMap {
|
|
278
|
-
return { version: "", stops:
|
|
273
|
+
return { version: "", stops: [] };
|
|
279
274
|
}
|
|
280
275
|
|
|
281
276
|
export const StopsMap: MessageFns<StopsMap> = {
|
|
@@ -283,9 +278,9 @@ export const StopsMap: MessageFns<StopsMap> = {
|
|
|
283
278
|
if (message.version !== "") {
|
|
284
279
|
writer.uint32(10).string(message.version);
|
|
285
280
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
}
|
|
281
|
+
for (const v of message.stops) {
|
|
282
|
+
Stop.encode(v!, writer.uint32(18).fork()).join();
|
|
283
|
+
}
|
|
289
284
|
return writer;
|
|
290
285
|
},
|
|
291
286
|
|
|
@@ -309,10 +304,7 @@ export const StopsMap: MessageFns<StopsMap> = {
|
|
|
309
304
|
break;
|
|
310
305
|
}
|
|
311
306
|
|
|
312
|
-
|
|
313
|
-
if (entry2.value !== undefined) {
|
|
314
|
-
message.stops[entry2.key] = entry2.value;
|
|
315
|
-
}
|
|
307
|
+
message.stops.push(Stop.decode(reader, reader.uint32()));
|
|
316
308
|
continue;
|
|
317
309
|
}
|
|
318
310
|
}
|
|
@@ -327,12 +319,7 @@ export const StopsMap: MessageFns<StopsMap> = {
|
|
|
327
319
|
fromJSON(object: any): StopsMap {
|
|
328
320
|
return {
|
|
329
321
|
version: isSet(object.version) ? globalThis.String(object.version) : "",
|
|
330
|
-
stops:
|
|
331
|
-
? Object.entries(object.stops).reduce<{ [key: number]: Stop }>((acc, [key, value]) => {
|
|
332
|
-
acc[globalThis.Number(key)] = Stop.fromJSON(value);
|
|
333
|
-
return acc;
|
|
334
|
-
}, {})
|
|
335
|
-
: {},
|
|
322
|
+
stops: globalThis.Array.isArray(object?.stops) ? object.stops.map((e: any) => Stop.fromJSON(e)) : [],
|
|
336
323
|
};
|
|
337
324
|
},
|
|
338
325
|
|
|
@@ -341,14 +328,8 @@ export const StopsMap: MessageFns<StopsMap> = {
|
|
|
341
328
|
if (message.version !== "") {
|
|
342
329
|
obj.version = message.version;
|
|
343
330
|
}
|
|
344
|
-
if (message.stops) {
|
|
345
|
-
|
|
346
|
-
if (entries.length > 0) {
|
|
347
|
-
obj.stops = {};
|
|
348
|
-
entries.forEach(([k, v]) => {
|
|
349
|
-
obj.stops[k] = Stop.toJSON(v);
|
|
350
|
-
});
|
|
351
|
-
}
|
|
331
|
+
if (message.stops?.length) {
|
|
332
|
+
obj.stops = message.stops.map((e) => Stop.toJSON(e));
|
|
352
333
|
}
|
|
353
334
|
return obj;
|
|
354
335
|
},
|
|
@@ -359,88 +340,7 @@ export const StopsMap: MessageFns<StopsMap> = {
|
|
|
359
340
|
fromPartial<I extends Exact<DeepPartial<StopsMap>, I>>(object: I): StopsMap {
|
|
360
341
|
const message = createBaseStopsMap();
|
|
361
342
|
message.version = object.version ?? "";
|
|
362
|
-
message.stops =
|
|
363
|
-
if (value !== undefined) {
|
|
364
|
-
acc[globalThis.Number(key)] = Stop.fromPartial(value);
|
|
365
|
-
}
|
|
366
|
-
return acc;
|
|
367
|
-
}, {});
|
|
368
|
-
return message;
|
|
369
|
-
},
|
|
370
|
-
};
|
|
371
|
-
|
|
372
|
-
function createBaseStopsMap_StopsEntry(): StopsMap_StopsEntry {
|
|
373
|
-
return { key: 0, value: undefined };
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
export const StopsMap_StopsEntry: MessageFns<StopsMap_StopsEntry> = {
|
|
377
|
-
encode(message: StopsMap_StopsEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
378
|
-
if (message.key !== 0) {
|
|
379
|
-
writer.uint32(8).uint32(message.key);
|
|
380
|
-
}
|
|
381
|
-
if (message.value !== undefined) {
|
|
382
|
-
Stop.encode(message.value, writer.uint32(18).fork()).join();
|
|
383
|
-
}
|
|
384
|
-
return writer;
|
|
385
|
-
},
|
|
386
|
-
|
|
387
|
-
decode(input: BinaryReader | Uint8Array, length?: number): StopsMap_StopsEntry {
|
|
388
|
-
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
389
|
-
const end = length === undefined ? reader.len : reader.pos + length;
|
|
390
|
-
const message = createBaseStopsMap_StopsEntry();
|
|
391
|
-
while (reader.pos < end) {
|
|
392
|
-
const tag = reader.uint32();
|
|
393
|
-
switch (tag >>> 3) {
|
|
394
|
-
case 1: {
|
|
395
|
-
if (tag !== 8) {
|
|
396
|
-
break;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
message.key = reader.uint32();
|
|
400
|
-
continue;
|
|
401
|
-
}
|
|
402
|
-
case 2: {
|
|
403
|
-
if (tag !== 18) {
|
|
404
|
-
break;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
message.value = Stop.decode(reader, reader.uint32());
|
|
408
|
-
continue;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
if ((tag & 7) === 4 || tag === 0) {
|
|
412
|
-
break;
|
|
413
|
-
}
|
|
414
|
-
reader.skip(tag & 7);
|
|
415
|
-
}
|
|
416
|
-
return message;
|
|
417
|
-
},
|
|
418
|
-
|
|
419
|
-
fromJSON(object: any): StopsMap_StopsEntry {
|
|
420
|
-
return {
|
|
421
|
-
key: isSet(object.key) ? globalThis.Number(object.key) : 0,
|
|
422
|
-
value: isSet(object.value) ? Stop.fromJSON(object.value) : undefined,
|
|
423
|
-
};
|
|
424
|
-
},
|
|
425
|
-
|
|
426
|
-
toJSON(message: StopsMap_StopsEntry): unknown {
|
|
427
|
-
const obj: any = {};
|
|
428
|
-
if (message.key !== 0) {
|
|
429
|
-
obj.key = Math.round(message.key);
|
|
430
|
-
}
|
|
431
|
-
if (message.value !== undefined) {
|
|
432
|
-
obj.value = Stop.toJSON(message.value);
|
|
433
|
-
}
|
|
434
|
-
return obj;
|
|
435
|
-
},
|
|
436
|
-
|
|
437
|
-
create<I extends Exact<DeepPartial<StopsMap_StopsEntry>, I>>(base?: I): StopsMap_StopsEntry {
|
|
438
|
-
return StopsMap_StopsEntry.fromPartial(base ?? ({} as any));
|
|
439
|
-
},
|
|
440
|
-
fromPartial<I extends Exact<DeepPartial<StopsMap_StopsEntry>, I>>(object: I): StopsMap_StopsEntry {
|
|
441
|
-
const message = createBaseStopsMap_StopsEntry();
|
|
442
|
-
message.key = object.key ?? 0;
|
|
443
|
-
message.value = (object.value !== undefined && object.value !== null) ? Stop.fromPartial(object.value) : undefined;
|
|
343
|
+
message.stops = object.stops?.map((e) => Stop.fromPartial(e)) || [];
|
|
444
344
|
return message;
|
|
445
345
|
},
|
|
446
346
|
};
|
|
@@ -457,10 +357,6 @@ type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
|
457
357
|
export type Exact<P, I extends P> = P extends Builtin ? P
|
|
458
358
|
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
|
|
459
359
|
|
|
460
|
-
function isObject(value: any): boolean {
|
|
461
|
-
return typeof value === "object" && value !== null;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
360
|
function isSet(value: any): boolean {
|
|
465
361
|
return value !== null && value !== undefined;
|
|
466
362
|
}
|
package/src/stops/stops.ts
CHANGED