@osmix/gtfs 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/README.md +200 -0
- package/dist/from-gtfs.d.ts +76 -0
- package/dist/from-gtfs.d.ts.map +1 -0
- package/dist/from-gtfs.js +211 -0
- package/dist/from-gtfs.js.map +1 -0
- package/dist/gtfs-archive.d.ts +71 -0
- package/dist/gtfs-archive.d.ts.map +1 -0
- package/dist/gtfs-archive.js +102 -0
- package/dist/gtfs-archive.js.map +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/src/from-gtfs.d.ts +76 -0
- package/dist/src/from-gtfs.d.ts.map +1 -0
- package/dist/src/from-gtfs.js +211 -0
- package/dist/src/from-gtfs.js.map +1 -0
- package/dist/src/gtfs-archive.d.ts +71 -0
- package/dist/src/gtfs-archive.d.ts.map +1 -0
- package/dist/src/gtfs-archive.js +102 -0
- package/dist/src/gtfs-archive.js.map +1 -0
- package/dist/src/index.d.ts +39 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +39 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/types.d.ts +139 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +48 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils.d.ts +25 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +210 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/test/from-gtfs.test.d.ts +2 -0
- package/dist/test/from-gtfs.test.d.ts.map +1 -0
- package/dist/test/from-gtfs.test.js +389 -0
- package/dist/test/from-gtfs.test.js.map +1 -0
- package/dist/test/helpers.d.ts +14 -0
- package/dist/test/helpers.d.ts.map +1 -0
- package/dist/test/helpers.js +84 -0
- package/dist/test/helpers.js.map +1 -0
- package/dist/types.d.ts +139 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +48 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +25 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +211 -0
- package/dist/utils.js.map +1 -0
- package/package.json +53 -0
- package/src/from-gtfs.ts +259 -0
- package/src/gtfs-archive.ts +138 -0
- package/src/index.ts +54 -0
- package/src/types.ts +184 -0
- package/src/utils.ts +226 -0
- package/test/from-gtfs.test.ts +501 -0
- package/test/helpers.ts +118 -0
- package/tsconfig.build.json +5 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { fromGtfs, GtfsArchive, GtfsOsmBuilder, isGtfsZip, routeTypeToOsmRoute, wheelchairBoardingToOsm, } from "../src";
|
|
3
|
+
import { routeToTags, stopToTags } from "../src/utils";
|
|
4
|
+
import { createSharedShapeGtfsZip, createTestGtfsZip } from "./helpers";
|
|
5
|
+
// Path to the Monaco GTFS fixture
|
|
6
|
+
const MONACO_GTFS_PATH = new URL("../../../fixtures/monaco-gtfs.zip", import.meta.url);
|
|
7
|
+
describe("routeTypeToOsmRoute", () => {
|
|
8
|
+
test("maps GTFS route types to OSM route values", () => {
|
|
9
|
+
expect(routeTypeToOsmRoute("0")).toBe("tram");
|
|
10
|
+
expect(routeTypeToOsmRoute("1")).toBe("subway");
|
|
11
|
+
expect(routeTypeToOsmRoute("2")).toBe("train");
|
|
12
|
+
expect(routeTypeToOsmRoute("3")).toBe("bus");
|
|
13
|
+
expect(routeTypeToOsmRoute("4")).toBe("ferry");
|
|
14
|
+
expect(routeTypeToOsmRoute("5")).toBe("tram");
|
|
15
|
+
expect(routeTypeToOsmRoute("6")).toBe("aerialway");
|
|
16
|
+
expect(routeTypeToOsmRoute("7")).toBe("funicular");
|
|
17
|
+
expect(routeTypeToOsmRoute("11")).toBe("trolleybus");
|
|
18
|
+
expect(routeTypeToOsmRoute("12")).toBe("train");
|
|
19
|
+
});
|
|
20
|
+
test("defaults to bus for unknown types", () => {
|
|
21
|
+
expect(routeTypeToOsmRoute("99")).toBe("bus");
|
|
22
|
+
expect(routeTypeToOsmRoute("")).toBe("bus");
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
describe("wheelchairBoardingToOsm", () => {
|
|
26
|
+
test("maps wheelchair boarding values", () => {
|
|
27
|
+
expect(wheelchairBoardingToOsm("1")).toBe("yes");
|
|
28
|
+
expect(wheelchairBoardingToOsm("2")).toBe("no");
|
|
29
|
+
expect(wheelchairBoardingToOsm("0")).toBeUndefined();
|
|
30
|
+
expect(wheelchairBoardingToOsm(undefined)).toBeUndefined();
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
describe("stopToTags", () => {
|
|
34
|
+
test("tags regular stops as platforms", () => {
|
|
35
|
+
const tags = stopToTags({
|
|
36
|
+
stop_id: "stop1",
|
|
37
|
+
stop_name: "Main St",
|
|
38
|
+
stop_lat: "40.7128",
|
|
39
|
+
stop_lon: "-74.0060",
|
|
40
|
+
location_type: "0",
|
|
41
|
+
});
|
|
42
|
+
expect(tags["public_transport"]).toBe("platform");
|
|
43
|
+
expect(tags["name"]).toBe("Main St");
|
|
44
|
+
});
|
|
45
|
+
test("tags stations correctly", () => {
|
|
46
|
+
const tags = stopToTags({
|
|
47
|
+
stop_id: "station1",
|
|
48
|
+
stop_name: "Central Station",
|
|
49
|
+
stop_lat: "40.7128",
|
|
50
|
+
stop_lon: "-74.0060",
|
|
51
|
+
location_type: "1",
|
|
52
|
+
});
|
|
53
|
+
expect(tags["public_transport"]).toBe("station");
|
|
54
|
+
});
|
|
55
|
+
test("tags entrances without public_transport tag", () => {
|
|
56
|
+
const tags = stopToTags({
|
|
57
|
+
stop_id: "entrance1",
|
|
58
|
+
stop_name: "Station Entrance A",
|
|
59
|
+
stop_lat: "40.7128",
|
|
60
|
+
stop_lon: "-74.0060",
|
|
61
|
+
location_type: "2",
|
|
62
|
+
});
|
|
63
|
+
// Entrances should have railway=subway_entrance but NOT public_transport
|
|
64
|
+
expect(tags["railway"]).toBe("subway_entrance");
|
|
65
|
+
expect(tags["public_transport"]).toBeUndefined();
|
|
66
|
+
expect(tags["name"]).toBe("Station Entrance A");
|
|
67
|
+
});
|
|
68
|
+
test("tags boarding areas as platforms", () => {
|
|
69
|
+
const tags = stopToTags({
|
|
70
|
+
stop_id: "boarding1",
|
|
71
|
+
stop_name: "Platform A",
|
|
72
|
+
stop_lat: "40.7128",
|
|
73
|
+
stop_lon: "-74.0060",
|
|
74
|
+
location_type: "4",
|
|
75
|
+
});
|
|
76
|
+
expect(tags["public_transport"]).toBe("platform");
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
describe("routeToTags", () => {
|
|
80
|
+
test("normalizes valid hex colors", () => {
|
|
81
|
+
const tags = routeToTags({
|
|
82
|
+
route_id: "route1",
|
|
83
|
+
route_short_name: "1",
|
|
84
|
+
route_type: "3",
|
|
85
|
+
route_color: "ff0000",
|
|
86
|
+
route_text_color: "FFFFFF",
|
|
87
|
+
});
|
|
88
|
+
expect(tags["color"]).toBe("#FF0000");
|
|
89
|
+
expect(tags["text_color"]).toBe("#FFFFFF");
|
|
90
|
+
});
|
|
91
|
+
test("accepts colors with # prefix", () => {
|
|
92
|
+
const tags = routeToTags({
|
|
93
|
+
route_id: "route1",
|
|
94
|
+
route_short_name: "1",
|
|
95
|
+
route_type: "3",
|
|
96
|
+
route_color: "#00FF00",
|
|
97
|
+
});
|
|
98
|
+
expect(tags["color"]).toBe("#00FF00");
|
|
99
|
+
});
|
|
100
|
+
test("accepts 3-character shorthand colors", () => {
|
|
101
|
+
const tags = routeToTags({
|
|
102
|
+
route_id: "route1",
|
|
103
|
+
route_short_name: "1",
|
|
104
|
+
route_type: "3",
|
|
105
|
+
route_color: "F00",
|
|
106
|
+
});
|
|
107
|
+
expect(tags["color"]).toBe("#FF0000");
|
|
108
|
+
});
|
|
109
|
+
test("rejects invalid hex colors", () => {
|
|
110
|
+
const tags = routeToTags({
|
|
111
|
+
route_id: "route1",
|
|
112
|
+
route_short_name: "1",
|
|
113
|
+
route_type: "3",
|
|
114
|
+
route_color: "ZZZZZZ",
|
|
115
|
+
route_text_color: "not-a-color",
|
|
116
|
+
});
|
|
117
|
+
// Invalid colors should not be added to tags
|
|
118
|
+
expect(tags["color"]).toBeUndefined();
|
|
119
|
+
expect(tags["text_color"]).toBeUndefined();
|
|
120
|
+
});
|
|
121
|
+
test("handles missing colors", () => {
|
|
122
|
+
const tags = routeToTags({
|
|
123
|
+
route_id: "route1",
|
|
124
|
+
route_short_name: "1",
|
|
125
|
+
route_type: "3",
|
|
126
|
+
});
|
|
127
|
+
expect(tags["color"]).toBeUndefined();
|
|
128
|
+
expect(tags["text_color"]).toBeUndefined();
|
|
129
|
+
});
|
|
130
|
+
test("sets route type and name correctly", () => {
|
|
131
|
+
const tags = routeToTags({
|
|
132
|
+
route_id: "route1",
|
|
133
|
+
route_short_name: "R1",
|
|
134
|
+
route_long_name: "Red Line",
|
|
135
|
+
route_type: "1",
|
|
136
|
+
});
|
|
137
|
+
expect(tags["route"]).toBe("subway");
|
|
138
|
+
expect(tags["name"]).toBe("Red Line");
|
|
139
|
+
expect(tags["ref"]).toBe("R1");
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
describe("GtfsArchive", () => {
|
|
143
|
+
test("parses a GTFS zip file lazily", async () => {
|
|
144
|
+
const zipData = await createTestGtfsZip();
|
|
145
|
+
const archive = GtfsArchive.fromZip(zipData);
|
|
146
|
+
// Check files are listed
|
|
147
|
+
const files = archive.listFiles();
|
|
148
|
+
expect(files).toContain("agency.txt");
|
|
149
|
+
expect(files).toContain("stops.txt");
|
|
150
|
+
expect(files).toContain("routes.txt");
|
|
151
|
+
// Parse agencies on demand
|
|
152
|
+
const agencies = await Array.fromAsync(archive.iter("agency.txt"));
|
|
153
|
+
expect(agencies.length).toBe(1);
|
|
154
|
+
expect(agencies[0]?.agency_name).toBe("Test Transit");
|
|
155
|
+
// Parse stops on demand
|
|
156
|
+
const stops = await Array.fromAsync(archive.iter("stops.txt"));
|
|
157
|
+
expect(stops.length).toBe(3);
|
|
158
|
+
expect(stops[0]?.stop_name).toBe("Main St Station");
|
|
159
|
+
// Parse routes on demand
|
|
160
|
+
const routes = await Array.fromAsync(archive.iter("routes.txt"));
|
|
161
|
+
expect(routes.length).toBe(1);
|
|
162
|
+
expect(routes[0]?.route_short_name).toBe("1");
|
|
163
|
+
});
|
|
164
|
+
test("iterates stops without loading all at once", async () => {
|
|
165
|
+
const zipData = await createTestGtfsZip();
|
|
166
|
+
const archive = GtfsArchive.fromZip(zipData);
|
|
167
|
+
const stops = [];
|
|
168
|
+
for await (const stop of archive.iter("stops.txt")) {
|
|
169
|
+
stops.push(stop);
|
|
170
|
+
}
|
|
171
|
+
expect(stops.length).toBe(3);
|
|
172
|
+
expect(stops[0]?.stop_name).toBe("Main St Station");
|
|
173
|
+
});
|
|
174
|
+
test("iter() returns correctly typed records", async () => {
|
|
175
|
+
const zipData = await createTestGtfsZip();
|
|
176
|
+
const archive = GtfsArchive.fromZip(zipData);
|
|
177
|
+
// TypeScript should infer the correct type for each file
|
|
178
|
+
for await (const stop of archive.iter("stops.txt")) {
|
|
179
|
+
// stop is GtfsStop
|
|
180
|
+
expect(stop.stop_id).toBeDefined();
|
|
181
|
+
expect(stop.stop_lat).toBeDefined();
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
for await (const route of archive.iter("routes.txt")) {
|
|
185
|
+
// route is GtfsRoute
|
|
186
|
+
expect(route.route_id).toBeDefined();
|
|
187
|
+
expect(route.route_type).toBeDefined();
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
for await (const shape of archive.iter("shapes.txt")) {
|
|
191
|
+
// shape is GtfsShapePoint
|
|
192
|
+
expect(shape.shape_id).toBeDefined();
|
|
193
|
+
expect(shape.shape_pt_lat).toBeDefined();
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
describe("isGtfsZip", () => {
|
|
199
|
+
test("detects GTFS zip created in tests", async () => {
|
|
200
|
+
const zipData = await createTestGtfsZip();
|
|
201
|
+
expect(isGtfsZip(zipData)).toBe(true);
|
|
202
|
+
});
|
|
203
|
+
test("detects Monaco GTFS fixture as GTFS", async () => {
|
|
204
|
+
const file = Bun.file(MONACO_GTFS_PATH);
|
|
205
|
+
const zipData = new Uint8Array(await file.arrayBuffer());
|
|
206
|
+
expect(isGtfsZip(zipData)).toBe(true);
|
|
207
|
+
});
|
|
208
|
+
test("returns false for non-GTFS zip", async () => {
|
|
209
|
+
const encoder = new TextEncoder();
|
|
210
|
+
const { zipSync } = await import("fflate");
|
|
211
|
+
const bytes = zipSync({
|
|
212
|
+
"readme.txt": encoder.encode("not a gtfs feed"),
|
|
213
|
+
"data.csv": encoder.encode("col1,col2\n1,2\n"),
|
|
214
|
+
});
|
|
215
|
+
expect(isGtfsZip(bytes)).toBe(false);
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
describe("fromGtfs", () => {
|
|
219
|
+
test("converts GTFS to OSM with shapes", async () => {
|
|
220
|
+
const zipData = await createTestGtfsZip();
|
|
221
|
+
const osm = await fromGtfs(zipData, { id: "test-transit" });
|
|
222
|
+
// Should have stops as nodes
|
|
223
|
+
expect(osm.nodes.size).toBeGreaterThanOrEqual(3);
|
|
224
|
+
// Should have route as way
|
|
225
|
+
expect(osm.ways.size).toBe(1);
|
|
226
|
+
// Check node tags
|
|
227
|
+
const stopNodes = [];
|
|
228
|
+
for (let i = 0; i < osm.nodes.size; i++) {
|
|
229
|
+
const tags = osm.nodes.tags.getTags(i);
|
|
230
|
+
if (tags?.["public_transport"]) {
|
|
231
|
+
stopNodes.push({ index: i, tags });
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
expect(stopNodes.length).toBe(3);
|
|
235
|
+
// First stop should have correct tags
|
|
236
|
+
const firstStop = stopNodes.find((n) => n.tags?.["name"] === "Main St Station");
|
|
237
|
+
expect(firstStop).toBeDefined();
|
|
238
|
+
expect(firstStop?.tags?.["ref"]).toBe("stop1");
|
|
239
|
+
expect(firstStop?.tags?.["wheelchair"]).toBe("yes");
|
|
240
|
+
// Check way tags
|
|
241
|
+
const wayTags = osm.ways.tags.getTags(0);
|
|
242
|
+
expect(wayTags?.["route"]).toBe("bus");
|
|
243
|
+
expect(wayTags?.["ref"]).toBe("1");
|
|
244
|
+
expect(wayTags?.["name"]).toBe("Downtown Express");
|
|
245
|
+
});
|
|
246
|
+
test("can exclude stops entirely", async () => {
|
|
247
|
+
const zipData = await createTestGtfsZip();
|
|
248
|
+
const osm = await fromGtfs(zipData, { id: "routes-only" }, { includeStops: false });
|
|
249
|
+
// Should have only shape nodes, no stop nodes
|
|
250
|
+
let stopCount = 0;
|
|
251
|
+
for (let i = 0; i < osm.nodes.size; i++) {
|
|
252
|
+
const tags = osm.nodes.tags.getTags(i);
|
|
253
|
+
if (tags?.["public_transport"]) {
|
|
254
|
+
stopCount++;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
expect(stopCount).toBe(0);
|
|
258
|
+
// Should still have the route
|
|
259
|
+
expect(osm.ways.size).toBe(1);
|
|
260
|
+
});
|
|
261
|
+
test("can exclude routes entirely", async () => {
|
|
262
|
+
const zipData = await createTestGtfsZip();
|
|
263
|
+
const osm = await fromGtfs(zipData, { id: "stops-only" }, { includeRoutes: false });
|
|
264
|
+
// Should have stops
|
|
265
|
+
let stopCount = 0;
|
|
266
|
+
for (let i = 0; i < osm.nodes.size; i++) {
|
|
267
|
+
const tags = osm.nodes.tags.getTags(i);
|
|
268
|
+
if (tags?.["public_transport"]) {
|
|
269
|
+
stopCount++;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
expect(stopCount).toBe(3);
|
|
273
|
+
// Should have no routes
|
|
274
|
+
expect(osm.ways.size).toBe(0);
|
|
275
|
+
});
|
|
276
|
+
test("creates separate ways for routes sharing the same shape", async () => {
|
|
277
|
+
const zipData = await createSharedShapeGtfsZip();
|
|
278
|
+
const osm = await fromGtfs(zipData, { id: "shared-shape" }, { includeStops: false });
|
|
279
|
+
// Should have 2 ways - one for each route, even though they share a shape
|
|
280
|
+
expect(osm.ways.size).toBe(2);
|
|
281
|
+
// Collect way tags
|
|
282
|
+
const wayTagsList = [];
|
|
283
|
+
for (let i = 0; i < osm.ways.size; i++) {
|
|
284
|
+
const tags = osm.ways.tags.getTags(i);
|
|
285
|
+
if (tags)
|
|
286
|
+
wayTagsList.push(tags);
|
|
287
|
+
}
|
|
288
|
+
// Find the Red Line (route1) way
|
|
289
|
+
const redLineWay = wayTagsList.find((tags) => tags["ref"] === "R1");
|
|
290
|
+
expect(redLineWay).toBeDefined();
|
|
291
|
+
expect(redLineWay?.["name"]).toBe("Red Line");
|
|
292
|
+
expect(redLineWay?.["route"]).toBe("subway");
|
|
293
|
+
expect(redLineWay?.["color"]).toBe("#FF0000");
|
|
294
|
+
// Should have 2 trips (trip1 and trip2)
|
|
295
|
+
expect(Number(redLineWay?.["gtfs:trip_count"])).toBe(2);
|
|
296
|
+
expect(redLineWay?.["gtfs:trip_ids"]).toBe("trip1;trip2");
|
|
297
|
+
// Find the Blue Express (route2) way
|
|
298
|
+
const blueExpressWay = wayTagsList.find((tags) => tags["ref"] === "B2");
|
|
299
|
+
expect(blueExpressWay).toBeDefined();
|
|
300
|
+
expect(blueExpressWay?.["name"]).toBe("Blue Express");
|
|
301
|
+
expect(blueExpressWay?.["route"]).toBe("bus");
|
|
302
|
+
expect(blueExpressWay?.["color"]).toBe("#0000FF");
|
|
303
|
+
// Should have 1 trip (trip3)
|
|
304
|
+
expect(Number(blueExpressWay?.["gtfs:trip_count"])).toBe(1);
|
|
305
|
+
expect(blueExpressWay?.["gtfs:trip_ids"]).toBe("trip3");
|
|
306
|
+
// Both should reference the same shape
|
|
307
|
+
expect(redLineWay?.["gtfs:shape_id"]).toBe("shared_shape");
|
|
308
|
+
expect(blueExpressWay?.["gtfs:shape_id"]).toBe("shared_shape");
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
describe("GtfsOsmBuilder", () => {
|
|
312
|
+
test("can be used for step-by-step conversion", async () => {
|
|
313
|
+
const zipData = await createTestGtfsZip();
|
|
314
|
+
const archive = GtfsArchive.fromZip(zipData);
|
|
315
|
+
const stops = await Array.fromAsync(archive.iter("stops.txt"));
|
|
316
|
+
const routes = await Array.fromAsync(archive.iter("routes.txt"));
|
|
317
|
+
expect(stops.length).toBe(3);
|
|
318
|
+
expect(routes.length).toBe(1);
|
|
319
|
+
const builder = new GtfsOsmBuilder({ id: "manual-test" });
|
|
320
|
+
await builder.processStops(archive);
|
|
321
|
+
await builder.processRoutes(archive);
|
|
322
|
+
const osm = builder.buildOsm();
|
|
323
|
+
expect(osm.nodes.size).toBeGreaterThanOrEqual(3);
|
|
324
|
+
expect(osm.ways.size).toBe(1);
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
describe("Monaco GTFS fixture", () => {
|
|
328
|
+
test("parses Monaco GTFS archive", async () => {
|
|
329
|
+
const file = Bun.file(MONACO_GTFS_PATH);
|
|
330
|
+
const zipData = await file.arrayBuffer();
|
|
331
|
+
const archive = GtfsArchive.fromZip(zipData);
|
|
332
|
+
// Check expected files exist
|
|
333
|
+
expect(archive.hasFile("agency.txt")).toBe(true);
|
|
334
|
+
expect(archive.hasFile("stops.txt")).toBe(true);
|
|
335
|
+
expect(archive.hasFile("routes.txt")).toBe(true);
|
|
336
|
+
expect(archive.hasFile("shapes.txt")).toBe(true);
|
|
337
|
+
expect(archive.hasFile("trips.txt")).toBe(true);
|
|
338
|
+
expect(archive.hasFile("stop_times.txt")).toBe(true);
|
|
339
|
+
// Parse agency
|
|
340
|
+
const agencies = await Array.fromAsync(archive.iter("agency.txt"));
|
|
341
|
+
expect(agencies.length).toBe(1);
|
|
342
|
+
// Parse stops
|
|
343
|
+
const stops = await Array.fromAsync(archive.iter("stops.txt"));
|
|
344
|
+
expect(stops.length).toBe(98);
|
|
345
|
+
// Parse routes
|
|
346
|
+
const routes = await Array.fromAsync(archive.iter("routes.txt"));
|
|
347
|
+
expect(routes.length).toBe(15);
|
|
348
|
+
});
|
|
349
|
+
test("converts Monaco GTFS to OSM with routes only", async () => {
|
|
350
|
+
const zipData = await Bun.file(MONACO_GTFS_PATH).arrayBuffer();
|
|
351
|
+
// Only include routes (no stops) to test shapes parsing
|
|
352
|
+
const osm = await fromGtfs(zipData, { id: "monaco-routes" }, { includeStops: false });
|
|
353
|
+
// Should have routes as ways (one per shape+route pair, not per trip)
|
|
354
|
+
// Previously 271 when grouping by shape only, now 315 with shape+route pairs
|
|
355
|
+
expect(osm.ways.size).toBe(315);
|
|
356
|
+
// Check a route has proper tags
|
|
357
|
+
const wayTags = osm.ways.tags.getTags(0);
|
|
358
|
+
expect(wayTags?.["route"]).toBeDefined();
|
|
359
|
+
});
|
|
360
|
+
test("converts Monaco GTFS to OSM with stops only", async () => {
|
|
361
|
+
const zipData = await Bun.file(MONACO_GTFS_PATH).arrayBuffer();
|
|
362
|
+
// Only include stops (no routes)
|
|
363
|
+
const osm = await fromGtfs(zipData, { id: "monaco-stops" }, { includeRoutes: false });
|
|
364
|
+
// Should have stops as nodes
|
|
365
|
+
expect(osm.nodes.size).toBeGreaterThan(0);
|
|
366
|
+
// No routes
|
|
367
|
+
expect(osm.ways.size).toBe(0);
|
|
368
|
+
// Check a stop has proper tags
|
|
369
|
+
let foundStop = false;
|
|
370
|
+
for (let i = 0; i < osm.nodes.size; i++) {
|
|
371
|
+
const tags = osm.nodes.tags.getTags(i);
|
|
372
|
+
if (tags?.["public_transport"]) {
|
|
373
|
+
foundStop = true;
|
|
374
|
+
expect(tags["name"]).toBeDefined();
|
|
375
|
+
break;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
expect(foundStop).toBe(true);
|
|
379
|
+
});
|
|
380
|
+
test("converts full Monaco GTFS to OSM", async () => {
|
|
381
|
+
const zipData = await Bun.file(MONACO_GTFS_PATH).arrayBuffer();
|
|
382
|
+
const osm = await fromGtfs(zipData, { id: "monaco-full" });
|
|
383
|
+
// Should have both stops and routes
|
|
384
|
+
expect(osm.nodes.size).toBeGreaterThan(0);
|
|
385
|
+
expect(osm.ways.size).toBeGreaterThan(0);
|
|
386
|
+
console.log(`Monaco GTFS: ${osm.nodes.size} nodes, ${osm.ways.size} ways`);
|
|
387
|
+
});
|
|
388
|
+
});
|
|
389
|
+
//# sourceMappingURL=from-gtfs.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"from-gtfs.test.js","sourceRoot":"","sources":["../../test/from-gtfs.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AACjD,OAAO,EACN,QAAQ,EACR,WAAW,EACX,cAAc,EACd,SAAS,EACT,mBAAmB,EACnB,uBAAuB,GACvB,MAAM,QAAQ,CAAA;AACf,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAEvE,kCAAkC;AAClC,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAC/B,mCAAmC,EACnC,MAAM,CAAC,IAAI,CAAC,GAAG,CACf,CAAA;AAED,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACpC,IAAI,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACtD,MAAM,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAC7C,MAAM,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAC/C,MAAM,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC9C,MAAM,CAAC,mBAAmB,CAAC,GAAG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CAAC,IAAI,WAAW,GAAG,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,CAAA;IAC3E,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a test GTFS zip file with sample data.
|
|
3
|
+
*/
|
|
4
|
+
export declare function createTestGtfsZip(): Promise<Uint8Array>;
|
|
5
|
+
/**
|
|
6
|
+
* Create a GTFS zip where two routes share the same shape.
|
|
7
|
+
* Used to test that each route gets its own way with correct metadata.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createSharedShapeGtfsZip(): Promise<Uint8Array>;
|
|
10
|
+
/**
|
|
11
|
+
* Create a minimal GTFS zip with just stops (no routes or shapes).
|
|
12
|
+
*/
|
|
13
|
+
export declare function createMinimalGtfsZip(): Promise<Uint8Array>;
|
|
14
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../test/helpers.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,UAAU,CAAC,CAuC7D;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,UAAU,CAAC,CAuCpE;AAED;;GAEG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,UAAU,CAAC,CAuBhE"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { zipSync } from "fflate";
|
|
2
|
+
/**
|
|
3
|
+
* Create a test GTFS zip file with sample data.
|
|
4
|
+
*/
|
|
5
|
+
export async function createTestGtfsZip() {
|
|
6
|
+
const encoder = new TextEncoder();
|
|
7
|
+
const files = {
|
|
8
|
+
"agency.txt": encoder.encode(`agency_id,agency_name,agency_url,agency_timezone
|
|
9
|
+
agency1,Test Transit,https://example.com,America/New_York`),
|
|
10
|
+
"stops.txt": encoder.encode(`stop_id,stop_name,stop_lat,stop_lon,location_type,wheelchair_boarding
|
|
11
|
+
stop1,Main St Station,40.7128,-74.0060,0,1
|
|
12
|
+
stop2,Broadway Station,40.7580,-73.9855,1,2
|
|
13
|
+
stop3,Park Ave Stop,40.7614,-73.9776,0,0`),
|
|
14
|
+
"routes.txt": encoder.encode(`route_id,route_short_name,route_long_name,route_type,route_color,route_text_color
|
|
15
|
+
route1,1,Downtown Express,3,FF0000,FFFFFF`),
|
|
16
|
+
"trips.txt": encoder.encode(`trip_id,route_id,service_id,shape_id
|
|
17
|
+
trip1,route1,weekday,shape1`),
|
|
18
|
+
"stop_times.txt": encoder.encode(`trip_id,stop_id,stop_sequence,arrival_time,departure_time
|
|
19
|
+
trip1,stop1,1,08:00:00,08:00:00
|
|
20
|
+
trip1,stop2,2,08:10:00,08:10:00
|
|
21
|
+
trip1,stop3,3,08:20:00,08:20:00`),
|
|
22
|
+
"shapes.txt": encoder.encode(`shape_id,shape_pt_lat,shape_pt_lon,shape_pt_sequence
|
|
23
|
+
shape1,40.7128,-74.0060,1
|
|
24
|
+
shape1,40.7400,-73.9900,2
|
|
25
|
+
shape1,40.7614,-73.9776,3`),
|
|
26
|
+
"calendar.txt": encoder.encode(`service_id,monday,tuesday,wednesday,thursday,friday,saturday,sunday,start_date,end_date
|
|
27
|
+
weekday,1,1,1,1,1,0,0,20240101,20241231`),
|
|
28
|
+
};
|
|
29
|
+
return zipSync(files);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Create a GTFS zip where two routes share the same shape.
|
|
33
|
+
* Used to test that each route gets its own way with correct metadata.
|
|
34
|
+
*/
|
|
35
|
+
export async function createSharedShapeGtfsZip() {
|
|
36
|
+
const encoder = new TextEncoder();
|
|
37
|
+
const files = {
|
|
38
|
+
"agency.txt": encoder.encode(`agency_id,agency_name,agency_url,agency_timezone
|
|
39
|
+
agency1,Test Transit,https://example.com,America/New_York`),
|
|
40
|
+
"stops.txt": encoder.encode(`stop_id,stop_name,stop_lat,stop_lon
|
|
41
|
+
stop1,Stop A,40.7128,-74.0060
|
|
42
|
+
stop2,Stop B,40.7614,-73.9776`),
|
|
43
|
+
"routes.txt": encoder.encode(`route_id,route_short_name,route_long_name,route_type,route_color
|
|
44
|
+
route1,R1,Red Line,1,FF0000
|
|
45
|
+
route2,B2,Blue Express,3,0000FF`),
|
|
46
|
+
// Both trips use the same shape but different routes
|
|
47
|
+
"trips.txt": encoder.encode(`trip_id,route_id,service_id,shape_id
|
|
48
|
+
trip1,route1,daily,shared_shape
|
|
49
|
+
trip2,route1,daily,shared_shape
|
|
50
|
+
trip3,route2,daily,shared_shape`),
|
|
51
|
+
"stop_times.txt": encoder.encode(`trip_id,stop_id,stop_sequence
|
|
52
|
+
trip1,stop1,1
|
|
53
|
+
trip1,stop2,2
|
|
54
|
+
trip2,stop1,1
|
|
55
|
+
trip2,stop2,2
|
|
56
|
+
trip3,stop1,1
|
|
57
|
+
trip3,stop2,2`),
|
|
58
|
+
"shapes.txt": encoder.encode(`shape_id,shape_pt_lat,shape_pt_lon,shape_pt_sequence
|
|
59
|
+
shared_shape,40.7128,-74.0060,1
|
|
60
|
+
shared_shape,40.7400,-73.9900,2
|
|
61
|
+
shared_shape,40.7614,-73.9776,3`),
|
|
62
|
+
};
|
|
63
|
+
return zipSync(files);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Create a minimal GTFS zip with just stops (no routes or shapes).
|
|
67
|
+
*/
|
|
68
|
+
export async function createMinimalGtfsZip() {
|
|
69
|
+
const encoder = new TextEncoder();
|
|
70
|
+
const files = {
|
|
71
|
+
"agency.txt": encoder.encode(`agency_id,agency_name,agency_url,agency_timezone
|
|
72
|
+
agency1,Minimal Transit,https://example.com,America/New_York`),
|
|
73
|
+
"stops.txt": encoder.encode(`stop_id,stop_name,stop_lat,stop_lon
|
|
74
|
+
stop1,Test Stop,40.7128,-74.0060`),
|
|
75
|
+
"routes.txt": encoder.encode(`route_id,route_short_name,route_long_name,route_type
|
|
76
|
+
route1,M,Metro Line,1`),
|
|
77
|
+
"trips.txt": encoder.encode(`trip_id,route_id,service_id
|
|
78
|
+
trip1,route1,daily`),
|
|
79
|
+
"stop_times.txt": encoder.encode(`trip_id,stop_id,stop_sequence
|
|
80
|
+
trip1,stop1,1`),
|
|
81
|
+
};
|
|
82
|
+
return zipSync(files);
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../test/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAEhC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB;IACtC,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAA;IAEjC,MAAM,KAAK,GAA+B;QACzC,YAAY,EACX,OAAO,CAAC,MAAM,CAAC;0DACwC,CAAC;QAEzD,WAAW,EACV,OAAO,CAAC,MAAM,CAAC;;;yCAGuB,CAAC;QAExC,YAAY,EACX,OAAO,CAAC,MAAM,CAAC;0CACwB,CAAC;QAEzC,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC;4BACF,CAAC;QAE3B,gBAAgB,EACf,OAAO,CAAC,MAAM,CAAC;;;gCAGc,CAAC;QAE/B,YAAY,EACX,OAAO,CAAC,MAAM,CAAC;;;0BAGQ,CAAC;QAEzB,cAAc,EACb,OAAO,CAAC,MAAM,CAAC;wCACsB,CAAC;KACvC,CAAA;IAED,OAAO,OAAO,CAAC,KAAK,CAAC,CAAA;AACtB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB;IAC7C,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAA;IAEjC,MAAM,KAAK,GAA+B;QACzC,YAAY,EACX,OAAO,CAAC,MAAM,CAAC;0DACwC,CAAC;QAEzD,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC;;8BAEA,CAAC;QAE7B,YAAY,EACX,OAAO,CAAC,MAAM,CAAC;;gCAEc,CAAC;QAE/B,qDAAqD;QACrD,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC;;;gCAGE,CAAC;QAE/B,gBAAgB,EAAE,OAAO,CAAC,MAAM,CAAC;;;;;;cAMrB,CAAC;QAEb,YAAY,EACX,OAAO,CAAC,MAAM,CAAC;;;gCAGc,CAAC;KAC/B,CAAA;IAED,OAAO,OAAO,CAAC,KAAK,CAAC,CAAA;AACtB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB;IACzC,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAA;IAEjC,MAAM,KAAK,GAA+B;QACzC,YAAY,EACX,OAAO,CAAC,MAAM,CAAC;6DAC2C,CAAC;QAE5D,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC;iCACG,CAAC;QAEhC,YAAY,EACX,OAAO,CAAC,MAAM,CAAC;sBACI,CAAC;QAErB,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC;mBACX,CAAC;QAElB,gBAAgB,EAAE,OAAO,CAAC,MAAM,CAAC;cACrB,CAAC;KACb,CAAA;IAED,OAAO,OAAO,CAAC,KAAK,CAAC,CAAA;AACtB,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GTFS (General Transit Feed Specification) type definitions.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* GTFS stop from stops.txt.
|
|
8
|
+
* Represents a transit stop or station.
|
|
9
|
+
*/
|
|
10
|
+
export interface GtfsStop {
|
|
11
|
+
stop_id: string;
|
|
12
|
+
stop_code?: string;
|
|
13
|
+
stop_name: string;
|
|
14
|
+
stop_desc?: string;
|
|
15
|
+
stop_lat: string;
|
|
16
|
+
stop_lon: string;
|
|
17
|
+
zone_id?: string;
|
|
18
|
+
stop_url?: string;
|
|
19
|
+
/** 0 = stop, 1 = station, 2 = entrance/exit, 3 = generic node, 4 = boarding area */
|
|
20
|
+
location_type?: string;
|
|
21
|
+
parent_station?: string;
|
|
22
|
+
stop_timezone?: string;
|
|
23
|
+
/** 0 = no info, 1 = accessible, 2 = not accessible */
|
|
24
|
+
wheelchair_boarding?: string;
|
|
25
|
+
level_id?: string;
|
|
26
|
+
platform_code?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* GTFS route from routes.txt.
|
|
30
|
+
* Represents a transit route/line.
|
|
31
|
+
*/
|
|
32
|
+
export interface GtfsRoute {
|
|
33
|
+
route_id: string;
|
|
34
|
+
agency_id?: string;
|
|
35
|
+
route_short_name?: string;
|
|
36
|
+
route_long_name?: string;
|
|
37
|
+
route_desc?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Route type:
|
|
40
|
+
* 0 = Tram, 1 = Subway, 2 = Rail, 3 = Bus, 4 = Ferry,
|
|
41
|
+
* 5 = Cable tram, 6 = Aerial lift, 7 = Funicular,
|
|
42
|
+
* 11 = Trolleybus, 12 = Monorail
|
|
43
|
+
*/
|
|
44
|
+
route_type: string;
|
|
45
|
+
route_url?: string;
|
|
46
|
+
route_color?: string;
|
|
47
|
+
route_text_color?: string;
|
|
48
|
+
route_sort_order?: string;
|
|
49
|
+
continuous_pickup?: string;
|
|
50
|
+
continuous_drop_off?: string;
|
|
51
|
+
network_id?: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* GTFS shape point from shapes.txt.
|
|
55
|
+
* Defines the geographic path of a route.
|
|
56
|
+
*/
|
|
57
|
+
export interface GtfsShapePoint {
|
|
58
|
+
shape_id: string;
|
|
59
|
+
shape_pt_lat: string;
|
|
60
|
+
shape_pt_lon: string;
|
|
61
|
+
shape_pt_sequence: string;
|
|
62
|
+
shape_dist_traveled?: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* GTFS trip from trips.txt.
|
|
66
|
+
* Represents a specific trip on a route.
|
|
67
|
+
*/
|
|
68
|
+
export interface GtfsTrip {
|
|
69
|
+
trip_id: string;
|
|
70
|
+
route_id: string;
|
|
71
|
+
service_id: string;
|
|
72
|
+
trip_headsign?: string;
|
|
73
|
+
trip_short_name?: string;
|
|
74
|
+
direction_id?: string;
|
|
75
|
+
block_id?: string;
|
|
76
|
+
shape_id?: string;
|
|
77
|
+
wheelchair_accessible?: string;
|
|
78
|
+
bikes_allowed?: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* GTFS stop time from stop_times.txt.
|
|
82
|
+
* Links trips to stops with timing info.
|
|
83
|
+
*/
|
|
84
|
+
export interface GtfsStopTime {
|
|
85
|
+
trip_id: string;
|
|
86
|
+
arrival_time?: string;
|
|
87
|
+
departure_time?: string;
|
|
88
|
+
stop_id: string;
|
|
89
|
+
stop_sequence: string;
|
|
90
|
+
stop_headsign?: string;
|
|
91
|
+
pickup_type?: string;
|
|
92
|
+
drop_off_type?: string;
|
|
93
|
+
continuous_pickup?: string;
|
|
94
|
+
continuous_drop_off?: string;
|
|
95
|
+
shape_dist_traveled?: string;
|
|
96
|
+
timepoint?: string;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* GTFS agency from agency.txt.
|
|
100
|
+
*/
|
|
101
|
+
export interface GtfsAgency {
|
|
102
|
+
agency_id?: string;
|
|
103
|
+
agency_name: string;
|
|
104
|
+
agency_url: string;
|
|
105
|
+
agency_timezone: string;
|
|
106
|
+
agency_lang?: string;
|
|
107
|
+
agency_phone?: string;
|
|
108
|
+
agency_fare_url?: string;
|
|
109
|
+
agency_email?: string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Parsed GTFS feed with all relevant files.
|
|
113
|
+
*/
|
|
114
|
+
export interface GtfsFeed {
|
|
115
|
+
agencies: GtfsAgency[];
|
|
116
|
+
stops: GtfsStop[];
|
|
117
|
+
routes: GtfsRoute[];
|
|
118
|
+
trips: GtfsTrip[];
|
|
119
|
+
stopTimes: GtfsStopTime[];
|
|
120
|
+
shapes: GtfsShapePoint[];
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Options for GTFS to OSM conversion.
|
|
124
|
+
*/
|
|
125
|
+
export interface GtfsConversionOptions {
|
|
126
|
+
/** Whether to include stops as nodes. Default: true */
|
|
127
|
+
includeStops?: boolean;
|
|
128
|
+
/** Whether to include routes as ways. Default: true */
|
|
129
|
+
includeRoutes?: boolean;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Map GTFS route_type to OSM route tag value.
|
|
133
|
+
*/
|
|
134
|
+
export declare function routeTypeToOsmRoute(routeType: string): string;
|
|
135
|
+
/**
|
|
136
|
+
* Map GTFS wheelchair_boarding to OSM wheelchair tag value.
|
|
137
|
+
*/
|
|
138
|
+
export declare function wheelchairBoardingToOsm(value: string | undefined): string | undefined;
|
|
139
|
+
//# sourceMappingURL=types.d.ts.map
|