minotor 5.0.1 → 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 +8 -3
- package/dist/cli.mjs +207 -596
- 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 +201 -593
- package/dist/parser.cjs.js.map +1 -1
- package/dist/parser.esm.js +201 -593
- 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 +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 +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/dist/stops/io.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { StopsMap as ProtoStopsMap } from './proto/stops.js';
|
|
2
|
-
import {
|
|
3
|
-
export declare const serializeStopsMap: (
|
|
4
|
-
export declare const deserializeStopsMap: (protoStopsMap: ProtoStopsMap) =>
|
|
2
|
+
import { Stop } from './stops.js';
|
|
3
|
+
export declare const serializeStopsMap: (stops: Stop[]) => ProtoStopsMap;
|
|
4
|
+
export declare const deserializeStopsMap: (protoStopsMap: ProtoStopsMap) => Stop[];
|
|
@@ -22,17 +22,10 @@ export interface Stop {
|
|
|
22
22
|
}
|
|
23
23
|
export interface StopsMap {
|
|
24
24
|
version: string;
|
|
25
|
-
stops:
|
|
26
|
-
[key: number]: Stop;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export interface StopsMap_StopsEntry {
|
|
30
|
-
key: number;
|
|
31
|
-
value: Stop | undefined;
|
|
25
|
+
stops: Stop[];
|
|
32
26
|
}
|
|
33
27
|
export declare const Stop: MessageFns<Stop>;
|
|
34
28
|
export declare const StopsMap: MessageFns<StopsMap>;
|
|
35
|
-
export declare const StopsMap_StopsEntry: MessageFns<StopsMap_StopsEntry>;
|
|
36
29
|
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
37
30
|
export type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
38
31
|
[K in keyof T]?: DeepPartial<T[K]>;
|
package/dist/stops/stops.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { SourceStopId, Stop, StopId
|
|
1
|
+
import { SourceStopId, Stop, StopId } from './stops.js';
|
|
2
2
|
/**
|
|
3
3
|
* The StopMap class provides functionality to search for public transport stops
|
|
4
4
|
* by name or geographic location. It leverages text search and geospatial indexing
|
|
5
5
|
* to efficiently find stops based on user queries.
|
|
6
6
|
*/
|
|
7
7
|
export declare class StopsIndex {
|
|
8
|
-
private readonly
|
|
8
|
+
private readonly stops;
|
|
9
9
|
private readonly sourceStopsMap;
|
|
10
10
|
private readonly textIndex;
|
|
11
11
|
private readonly geoIndex;
|
|
12
12
|
private readonly stopPoints;
|
|
13
|
-
constructor(
|
|
13
|
+
constructor(stops: Stop[]);
|
|
14
14
|
/**
|
|
15
15
|
* Deserializes a binary representation of the stops.
|
|
16
16
|
*
|
package/dist/timetable/io.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Route as ProtoRoute,
|
|
1
|
+
import { Route as ProtoRoute, ServiceRoute as ProtoServiceRoute, StopAdjacency as ProtoStopAdjacency } from './proto/timetable.js';
|
|
2
2
|
import { Route } from './route.js';
|
|
3
|
-
import {
|
|
3
|
+
import { ServiceRoute, ServiceRouteId, StopAdjacency } from './timetable.js';
|
|
4
4
|
export type SerializedRoute = {
|
|
5
5
|
stopTimes: Uint16Array;
|
|
6
6
|
pickUpDropOffTypes: Uint8Array;
|
|
7
7
|
stops: Uint32Array;
|
|
8
8
|
serviceRouteId: ServiceRouteId;
|
|
9
9
|
};
|
|
10
|
-
export declare const serializeStopsAdjacency: (stopsAdjacency:
|
|
10
|
+
export declare const serializeStopsAdjacency: (stopsAdjacency: StopAdjacency[]) => ProtoStopAdjacency[];
|
|
11
11
|
export declare const serializeRoutesAdjacency: (routesAdjacency: Route[]) => ProtoRoute[];
|
|
12
|
-
export declare const serializeServiceRoutesMap: (
|
|
13
|
-
export declare const deserializeStopsAdjacency: (protoStopsAdjacency:
|
|
12
|
+
export declare const serializeServiceRoutesMap: (serviceRoutes: ServiceRoute[]) => ProtoServiceRoute[];
|
|
13
|
+
export declare const deserializeStopsAdjacency: (protoStopsAdjacency: ProtoStopAdjacency[]) => StopAdjacency[];
|
|
14
14
|
export declare const deserializeRoutesAdjacency: (protoRoutesAdjacency: ProtoRoute[]) => Route[];
|
|
15
|
-
export declare const deserializeServiceRoutesMap: (
|
|
15
|
+
export declare const deserializeServiceRoutesMap: (protoServiceRoutes: ProtoServiceRoute[]) => ServiceRoute[];
|
|
@@ -46,54 +46,32 @@ export interface Route {
|
|
|
46
46
|
* Format: [stop1, stop2, stop3, etc.]
|
|
47
47
|
*/
|
|
48
48
|
stops: Uint8Array;
|
|
49
|
-
serviceRouteId:
|
|
49
|
+
serviceRouteId: number;
|
|
50
50
|
}
|
|
51
51
|
export interface Transfer {
|
|
52
52
|
destination: number;
|
|
53
53
|
type: TransferType;
|
|
54
54
|
minTransferTime?: number | undefined;
|
|
55
55
|
}
|
|
56
|
-
export interface
|
|
57
|
-
stops: {
|
|
58
|
-
[key: number]: StopsAdjacency_StopAdjacency;
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
export interface StopsAdjacency_StopAdjacency {
|
|
56
|
+
export interface StopAdjacency {
|
|
62
57
|
transfers: Transfer[];
|
|
63
58
|
routes: number[];
|
|
64
59
|
}
|
|
65
|
-
export interface StopsAdjacency_StopsEntry {
|
|
66
|
-
key: number;
|
|
67
|
-
value: StopsAdjacency_StopAdjacency | undefined;
|
|
68
|
-
}
|
|
69
60
|
export interface ServiceRoute {
|
|
70
61
|
type: RouteType;
|
|
71
62
|
name: string;
|
|
72
63
|
routes: number[];
|
|
73
64
|
}
|
|
74
|
-
export interface ServiceRoutesMap {
|
|
75
|
-
routes: {
|
|
76
|
-
[key: string]: ServiceRoute;
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
export interface ServiceRoutesMap_RoutesEntry {
|
|
80
|
-
key: string;
|
|
81
|
-
value: ServiceRoute | undefined;
|
|
82
|
-
}
|
|
83
65
|
export interface Timetable {
|
|
84
66
|
version: string;
|
|
85
|
-
stopsAdjacency:
|
|
67
|
+
stopsAdjacency: StopAdjacency[];
|
|
86
68
|
routesAdjacency: Route[];
|
|
87
|
-
|
|
69
|
+
serviceRoutes: ServiceRoute[];
|
|
88
70
|
}
|
|
89
71
|
export declare const Route: MessageFns<Route>;
|
|
90
72
|
export declare const Transfer: MessageFns<Transfer>;
|
|
91
|
-
export declare const
|
|
92
|
-
export declare const StopsAdjacency_StopAdjacency: MessageFns<StopsAdjacency_StopAdjacency>;
|
|
93
|
-
export declare const StopsAdjacency_StopsEntry: MessageFns<StopsAdjacency_StopsEntry>;
|
|
73
|
+
export declare const StopAdjacency: MessageFns<StopAdjacency>;
|
|
94
74
|
export declare const ServiceRoute: MessageFns<ServiceRoute>;
|
|
95
|
-
export declare const ServiceRoutesMap: MessageFns<ServiceRoutesMap>;
|
|
96
|
-
export declare const ServiceRoutesMap_RoutesEntry: MessageFns<ServiceRoutesMap_RoutesEntry>;
|
|
97
75
|
export declare const Timetable: MessageFns<Timetable>;
|
|
98
76
|
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
99
77
|
export type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
@@ -7,29 +7,29 @@ export type Transfer = {
|
|
|
7
7
|
type: TransferType;
|
|
8
8
|
minTransferTime?: Duration;
|
|
9
9
|
};
|
|
10
|
-
export type
|
|
10
|
+
export type StopAdjacency = {
|
|
11
11
|
transfers: Transfer[];
|
|
12
12
|
routes: RouteId[];
|
|
13
|
-
}
|
|
14
|
-
export type ServiceRouteId =
|
|
13
|
+
};
|
|
14
|
+
export type ServiceRouteId = number;
|
|
15
15
|
export type RouteType = 'TRAM' | 'SUBWAY' | 'RAIL' | 'BUS' | 'FERRY' | 'CABLE_TRAM' | 'AERIAL_LIFT' | 'FUNICULAR' | 'TROLLEYBUS' | 'MONORAIL';
|
|
16
|
-
type ServiceRoute = {
|
|
16
|
+
export type ServiceRoute = {
|
|
17
17
|
type: RouteType;
|
|
18
18
|
name: string;
|
|
19
19
|
routes: RouteId[];
|
|
20
20
|
};
|
|
21
21
|
export type ServiceRouteInfo = Omit<ServiceRoute, 'routes'>;
|
|
22
|
-
export type ServiceRoutesMap = Map<ServiceRouteId, ServiceRoute>;
|
|
23
22
|
export declare const ALL_TRANSPORT_MODES: Set<RouteType>;
|
|
24
|
-
export declare const CURRENT_VERSION = "0.0.
|
|
23
|
+
export declare const CURRENT_VERSION = "0.0.6";
|
|
25
24
|
/**
|
|
26
25
|
* The internal transit timetable format.
|
|
27
26
|
*/
|
|
28
27
|
export declare class Timetable {
|
|
29
28
|
private readonly stopsAdjacency;
|
|
30
29
|
private readonly routesAdjacency;
|
|
31
|
-
private readonly
|
|
32
|
-
|
|
30
|
+
private readonly serviceRoutes;
|
|
31
|
+
private readonly activeStops;
|
|
32
|
+
constructor(stopsAdjacency: StopAdjacency[], routesAdjacency: Route[], routes: ServiceRoute[]);
|
|
33
33
|
/**
|
|
34
34
|
* Serializes the Timetable into a binary array.
|
|
35
35
|
*
|
|
@@ -43,6 +43,15 @@ export declare class Timetable {
|
|
|
43
43
|
* @returns The deserialized Timetable object.
|
|
44
44
|
*/
|
|
45
45
|
static fromData(data: Uint8Array): Timetable;
|
|
46
|
+
/**
|
|
47
|
+
* Checks if the given stop is active on the timetable.
|
|
48
|
+
* An active stop is a stop reached by a route that is active on the timetable
|
|
49
|
+
* or by a transfer reachable from an active route.
|
|
50
|
+
*
|
|
51
|
+
* @param stopId - The ID of the stop to check.
|
|
52
|
+
* @returns True if the stop is active, false otherwise.
|
|
53
|
+
*/
|
|
54
|
+
isActive(stopId: StopId): boolean;
|
|
46
55
|
/**
|
|
47
56
|
* Retrieves the route associated with the given route ID.
|
|
48
57
|
*
|
|
@@ -85,4 +94,3 @@ export declare class Timetable {
|
|
|
85
94
|
*/
|
|
86
95
|
findReachableRoutes(fromStops: Set<StopId>, transportModes?: Set<RouteType>): Map<Route, StopId>;
|
|
87
96
|
}
|
|
88
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
version https://git-lfs.github.com/spec/v1
|
|
2
|
-
oid sha256:
|
|
3
|
-
size
|
|
2
|
+
oid sha256:9d01e1988e595441682589f20612343670f6c01d18df037c389d0946a4ca6e61
|
|
3
|
+
size 5121353
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
version https://git-lfs.github.com/spec/v1
|
|
2
|
-
oid sha256:
|
|
3
|
-
size
|
|
2
|
+
oid sha256:c2ba83dc99279de7efd87f05c5b49c16f4dbf509e6c3f77af8f98b3273afb9e2
|
|
3
|
+
size 18173715
|
package/src/cli/minotor.ts
CHANGED
|
@@ -67,11 +67,10 @@ program
|
|
|
67
67
|
log.setDefaultLevel(log.levels.ERROR);
|
|
68
68
|
}
|
|
69
69
|
const parser = new GtfsParser(gtfsPath, profiles[options.profileName]);
|
|
70
|
-
const
|
|
71
|
-
new Date(options.date),
|
|
72
|
-
);
|
|
73
|
-
fs.writeFileSync(options.timetableOutputPath, timetable.serialize());
|
|
70
|
+
const stopsIndex = await parser.parseStops();
|
|
74
71
|
fs.writeFileSync(options.stopsOutputPath, stopsIndex.serialize());
|
|
72
|
+
const timetable = await parser.parseTimetable(new Date(options.date));
|
|
73
|
+
fs.writeFileSync(options.timetableOutputPath, timetable.serialize());
|
|
75
74
|
},
|
|
76
75
|
);
|
|
77
76
|
|
|
@@ -21,9 +21,8 @@ describe('GTFS parser', () => {
|
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
it('should correctly parse timetable from GTFS feed', async () => {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
);
|
|
24
|
+
const timetable = await parser.parseTimetable(new Date('2007-01-10'));
|
|
25
|
+
const stopsIndex = await parser.parseStops();
|
|
27
26
|
|
|
28
27
|
const furCreekResId =
|
|
29
28
|
stopsIndex.findStopBySourceStopId('FUR_CREEK_RES')?.id;
|
|
@@ -33,7 +32,7 @@ describe('GTFS parser', () => {
|
|
|
33
32
|
|
|
34
33
|
const route = timetable.getRoute(3);
|
|
35
34
|
assert(route);
|
|
36
|
-
assert.strictEqual(route.serviceRoute(),
|
|
35
|
+
assert.strictEqual(route.serviceRoute(), 2);
|
|
37
36
|
const beattyAirportId =
|
|
38
37
|
stopsIndex.findStopBySourceStopId('BEATTY_AIRPORT')?.id;
|
|
39
38
|
const bullfrogId = stopsIndex.findStopBySourceStopId('BULLFROG')?.id;
|
|
@@ -48,8 +47,8 @@ describe('GTFS parser', () => {
|
|
|
48
47
|
|
|
49
48
|
const routes = timetable.routesPassingThrough(furCreekResId);
|
|
50
49
|
assert.strictEqual(routes.length, 2);
|
|
51
|
-
assert.strictEqual(routes[0]?.serviceRoute(),
|
|
52
|
-
assert.strictEqual(routes[1]?.serviceRoute(),
|
|
50
|
+
assert.strictEqual(routes[0]?.serviceRoute(), 3);
|
|
51
|
+
assert.strictEqual(routes[1]?.serviceRoute(), 3);
|
|
53
52
|
|
|
54
53
|
const serviceRoute = timetable.getServiceRouteInfo(route);
|
|
55
54
|
assert(serviceRoute);
|
|
@@ -24,7 +24,6 @@ describe('GTFS routes parser', () => {
|
|
|
24
24
|
{
|
|
25
25
|
type: 'BUS',
|
|
26
26
|
name: 'B1',
|
|
27
|
-
routes: [],
|
|
28
27
|
},
|
|
29
28
|
],
|
|
30
29
|
[
|
|
@@ -32,7 +31,6 @@ describe('GTFS routes parser', () => {
|
|
|
32
31
|
{
|
|
33
32
|
type: 'TRAM',
|
|
34
33
|
name: 'T1',
|
|
35
|
-
routes: [],
|
|
36
34
|
},
|
|
37
35
|
],
|
|
38
36
|
]),
|
|
@@ -56,7 +54,6 @@ describe('GTFS routes parser', () => {
|
|
|
56
54
|
{
|
|
57
55
|
type: 'BUS',
|
|
58
56
|
name: 'B1',
|
|
59
|
-
routes: [],
|
|
60
57
|
},
|
|
61
58
|
],
|
|
62
59
|
]),
|
|
@@ -2,8 +2,7 @@ import assert from 'node:assert';
|
|
|
2
2
|
import { Readable } from 'node:stream';
|
|
3
3
|
import { describe, it } from 'node:test';
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import { indexStops, ParsedStopsMap, parseStops } from '../stops.js';
|
|
5
|
+
import { parseStops } from '../stops.js';
|
|
7
6
|
|
|
8
7
|
describe('GTFS stops parser', () => {
|
|
9
8
|
describe('parseStops', () => {
|
|
@@ -114,126 +113,4 @@ describe('GTFS stops parser', () => {
|
|
|
114
113
|
assert.equal(childStop2.platform, '2');
|
|
115
114
|
});
|
|
116
115
|
});
|
|
117
|
-
|
|
118
|
-
describe('indexStops', () => {
|
|
119
|
-
it('should correctly index parsed stops', () => {
|
|
120
|
-
const parsedStopsMap: ParsedStopsMap = new Map();
|
|
121
|
-
|
|
122
|
-
parsedStopsMap.set('Parent8504100', {
|
|
123
|
-
id: 0,
|
|
124
|
-
sourceStopId: 'Parent8504100',
|
|
125
|
-
name: 'Fribourg/Freiburg',
|
|
126
|
-
lat: 46.8031492395272,
|
|
127
|
-
lon: 7.15104780338173,
|
|
128
|
-
locationType: 'STATION',
|
|
129
|
-
children: [1, 2],
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
parsedStopsMap.set('8504100:0:1', {
|
|
133
|
-
id: 1,
|
|
134
|
-
sourceStopId: '8504100:0:1',
|
|
135
|
-
name: 'Fribourg/Freiburg',
|
|
136
|
-
lat: 46.8018210323626,
|
|
137
|
-
lon: 7.14993389242926,
|
|
138
|
-
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
139
|
-
children: [],
|
|
140
|
-
parent: 0,
|
|
141
|
-
platform: '1',
|
|
142
|
-
parentSourceId: 'Parent8504100',
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
parsedStopsMap.set('8504100:0:2', {
|
|
146
|
-
id: 2,
|
|
147
|
-
sourceStopId: '8504100:0:2',
|
|
148
|
-
name: 'Fribourg/Freiburg',
|
|
149
|
-
lat: 46.8010031847878,
|
|
150
|
-
lon: 7.14920625704902,
|
|
151
|
-
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
152
|
-
children: [],
|
|
153
|
-
parent: 0,
|
|
154
|
-
platform: '2',
|
|
155
|
-
parentSourceId: 'Parent8504100',
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
const indexedStops = indexStops(parsedStopsMap);
|
|
159
|
-
|
|
160
|
-
assert.equal(indexedStops.size, 3);
|
|
161
|
-
|
|
162
|
-
const station = indexedStops.get(0);
|
|
163
|
-
assert.ok(station);
|
|
164
|
-
assert.equal(station.sourceStopId, 'Parent8504100');
|
|
165
|
-
assert.deepEqual(station.children, [1, 2]);
|
|
166
|
-
|
|
167
|
-
const platform1 = indexedStops.get(1);
|
|
168
|
-
assert.ok(platform1);
|
|
169
|
-
assert.equal(platform1.sourceStopId, '8504100:0:1');
|
|
170
|
-
assert.equal(platform1.platform, '1');
|
|
171
|
-
assert.equal(platform1.parent, 0);
|
|
172
|
-
|
|
173
|
-
const platform2 = indexedStops.get(2);
|
|
174
|
-
assert.ok(platform2);
|
|
175
|
-
assert.equal(platform2.sourceStopId, '8504100:0:2');
|
|
176
|
-
assert.equal(platform2.platform, '2');
|
|
177
|
-
assert.equal(platform2.parent, 0);
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
it('should filter stops based on validStops set', () => {
|
|
181
|
-
const parsedStopsMap: ParsedStopsMap = new Map();
|
|
182
|
-
|
|
183
|
-
parsedStopsMap.set('Parent8504100', {
|
|
184
|
-
id: 0,
|
|
185
|
-
sourceStopId: 'Parent8504100',
|
|
186
|
-
name: 'Fribourg/Freiburg',
|
|
187
|
-
lat: 46.8031492395272,
|
|
188
|
-
lon: 7.15104780338173,
|
|
189
|
-
locationType: 'STATION',
|
|
190
|
-
children: [1, 2, 3],
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
parsedStopsMap.set('8504100:0:1', {
|
|
194
|
-
id: 1,
|
|
195
|
-
sourceStopId: '8504100:0:1',
|
|
196
|
-
name: 'Fribourg/Freiburg',
|
|
197
|
-
lat: 46.8018210323626,
|
|
198
|
-
lon: 7.14993389242926,
|
|
199
|
-
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
200
|
-
children: [],
|
|
201
|
-
parent: 0,
|
|
202
|
-
parentSourceId: 'Parent8504100',
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
parsedStopsMap.set('8504100:0:2', {
|
|
206
|
-
id: 2,
|
|
207
|
-
sourceStopId: '8504100:0:2',
|
|
208
|
-
name: 'Fribourg/Freiburg',
|
|
209
|
-
lat: 46.8010031847878,
|
|
210
|
-
lon: 7.14920625704902,
|
|
211
|
-
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
212
|
-
children: [],
|
|
213
|
-
parent: 0,
|
|
214
|
-
parentSourceId: 'Parent8504100',
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
parsedStopsMap.set('8504100:0:3', {
|
|
218
|
-
id: 3,
|
|
219
|
-
sourceStopId: '8504100:0:3',
|
|
220
|
-
name: 'Fribourg/Freiburg',
|
|
221
|
-
lat: 46.8,
|
|
222
|
-
lon: 7.14,
|
|
223
|
-
locationType: 'SIMPLE_STOP_OR_PLATFORM',
|
|
224
|
-
children: [],
|
|
225
|
-
parent: 0,
|
|
226
|
-
parentSourceId: 'Parent8504100',
|
|
227
|
-
});
|
|
228
|
-
const validStops = new Set<StopId>([1, 2]);
|
|
229
|
-
|
|
230
|
-
const indexedStops = indexStops(parsedStopsMap, validStops);
|
|
231
|
-
|
|
232
|
-
assert.equal(indexedStops.size, 3);
|
|
233
|
-
assert.ok(indexedStops.has(0));
|
|
234
|
-
assert.ok(indexedStops.has(1));
|
|
235
|
-
assert.ok(indexedStops.has(2));
|
|
236
|
-
assert.ok(!indexedStops.has(3));
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
116
|
});
|
|
@@ -3,7 +3,7 @@ import { Readable } from 'node:stream';
|
|
|
3
3
|
import { describe, it } from 'node:test';
|
|
4
4
|
|
|
5
5
|
import { Duration } from '../../timetable/duration.js';
|
|
6
|
-
import {
|
|
6
|
+
import { GtfsStopsMap } from '../stops.js';
|
|
7
7
|
import { parseTransfers } from '../transfers.js';
|
|
8
8
|
|
|
9
9
|
describe('GTFS transfers parser', () => {
|
|
@@ -16,7 +16,7 @@ describe('GTFS transfers parser', () => {
|
|
|
16
16
|
mockedStream.push('"1100097","8014447","2","240"\n');
|
|
17
17
|
mockedStream.push(null);
|
|
18
18
|
|
|
19
|
-
const stopsMap:
|
|
19
|
+
const stopsMap: GtfsStopsMap = new Map([
|
|
20
20
|
[
|
|
21
21
|
'1100084',
|
|
22
22
|
{
|
|
@@ -95,7 +95,7 @@ describe('GTFS transfers parser', () => {
|
|
|
95
95
|
mockedStream.push('"1100097","8014447","5","240"\n');
|
|
96
96
|
mockedStream.push(null);
|
|
97
97
|
|
|
98
|
-
const stopsMap:
|
|
98
|
+
const stopsMap: GtfsStopsMap = new Map([
|
|
99
99
|
[
|
|
100
100
|
'1100084',
|
|
101
101
|
{
|
|
@@ -150,7 +150,7 @@ describe('GTFS transfers parser', () => {
|
|
|
150
150
|
mockedStream.push('"1100084","8014440","2","180"\n');
|
|
151
151
|
mockedStream.push(null);
|
|
152
152
|
|
|
153
|
-
const stopsMap:
|
|
153
|
+
const stopsMap: GtfsStopsMap = new Map([
|
|
154
154
|
[
|
|
155
155
|
'1100084',
|
|
156
156
|
{
|
|
@@ -185,7 +185,7 @@ describe('GTFS transfers parser', () => {
|
|
|
185
185
|
mockedStream.push('"1100084","8014440","2","180"\n');
|
|
186
186
|
mockedStream.push(null);
|
|
187
187
|
|
|
188
|
-
const stopsMap:
|
|
188
|
+
const stopsMap: GtfsStopsMap = new Map([
|
|
189
189
|
[
|
|
190
190
|
'1100084',
|
|
191
191
|
{
|
|
@@ -220,7 +220,7 @@ describe('GTFS transfers parser', () => {
|
|
|
220
220
|
mockedStream.push('"1100084","8014440:0:1","2"\n');
|
|
221
221
|
mockedStream.push(null);
|
|
222
222
|
|
|
223
|
-
const stopsMap:
|
|
223
|
+
const stopsMap: GtfsStopsMap = new Map([
|
|
224
224
|
[
|
|
225
225
|
'1100084',
|
|
226
226
|
{
|
|
@@ -266,7 +266,7 @@ describe('GTFS transfers parser', () => {
|
|
|
266
266
|
);
|
|
267
267
|
mockedStream.push(null);
|
|
268
268
|
|
|
269
|
-
const stopsMap:
|
|
269
|
+
const stopsMap: GtfsStopsMap = new Map();
|
|
270
270
|
|
|
271
271
|
const transfers = await parseTransfers(mockedStream, stopsMap);
|
|
272
272
|
assert.deepEqual(transfers, new Map());
|