vulture-wasm 0.5.1 → 0.6.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/README.md +29 -29
- package/package.json +1 -1
- package/vulture_wasm_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# vulture-wasm
|
|
2
2
|
|
|
3
|
-
WebAssembly bindings for [vulture](https://github.com/urschrei/vulture)
|
|
3
|
+
WebAssembly bindings for [vulture](https://github.com/urschrei/vulture), a Rust implementation of [RAPTOR](https://www.microsoft.com/en-us/research/publication/round-based-public-transit-routing/) (Delling, Pajor, Werneck) public-transit routing. Single ES module, built with [wasm-bindgen](https://rustwasm.github.io/wasm-bindgen/) and [wasm-pack](https://rustwasm.github.io/wasm-pack/).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Pass GTFS zip bytes to `new VultureTimetable(zipBytes, "YYYY-MM-DD")`, then query the handle. No HTTP code in the wasm blob.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Bundle: ~700 KB raw, ~290 KB gzipped.
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
@@ -15,7 +15,7 @@ npm install vulture-wasm
|
|
|
15
15
|
```js
|
|
16
16
|
import init, { VultureTimetable, runArrival, runRange } from "vulture-wasm";
|
|
17
17
|
|
|
18
|
-
await init();
|
|
18
|
+
await init();
|
|
19
19
|
|
|
20
20
|
const zipBytes = new Uint8Array(
|
|
21
21
|
await (await fetch("/path/to/feed.zip")).arrayBuffer(),
|
|
@@ -49,31 +49,31 @@ const tt = new VultureTimetable(
|
|
|
49
49
|
- `tt.stopName(stopIdx)`, `tt.stopCoords(stopIdx)`, `tt.routeName(routeIdx)`, `tt.routeAgency(routeIdx)` — display-data accessors.
|
|
50
50
|
- `tt.allStops()` — bulk catalogue of `{idx, id, name, lat, lon, location_type, parent_station}` per stop. `location_type` is the GTFS integer (0 = stop or platform, 1 = parent station, 2 = entrance/exit, 3 = generic node, 4 = boarding area); `parent_station` is the parent's GTFS id or `null`.
|
|
51
51
|
- `tt.allRoutes()` — bulk catalogue of `{idx, id, name, agency, route_type, route_color}` per route. `route_type` is the GTFS integer (0 = tram, 1 = metro, 2 = rail, 3 = bus, 4 = ferry, 5 = cable, 6 = aerial, 7 = funicular, …); `route_color` is `"#rrggbb"` or `null`.
|
|
52
|
-
- `tt.stationStops(parentId)` —
|
|
52
|
+
- `tt.stationStops(parentId)` — `Uint32Array` of child platform indices for a parent-station GTFS id. Pass to `originStops` / `targetStops` for any-platform queries. Queries rooted at a `location_type = 1` stop return zero journeys without this expansion.
|
|
53
53
|
- `tt.withWalkingFootpaths(maxDistMeters, walkSpeedMetersPerSec)` — replace the footpath set with one derived from stop coordinates.
|
|
54
54
|
- `tt.resetFootpaths()` — restore the original `transfers.txt` set.
|
|
55
|
-
- `tt.features()` — snapshot of the loaded feed as a JS object
|
|
56
|
-
- `tt.suggestions()` —
|
|
55
|
+
- `tt.features()` — snapshot of the loaded feed as a JS object (camelCase fields): stop / route / trip counts, `transfers.txt` breakdown by `transfer_type`, parent-station and shaped-trip counts, wheelchair-flag counts, and footpath-graph state (`walkingFootpathsAdded`, `footpathsClosed`, `nFootpaths`). Counts are fixed at construction; footpath fields update on mutation.
|
|
56
|
+
- `tt.suggestions()` — advisory string array derived from the snapshot, e.g. `"transfers.txt is empty: call withWalkingFootpaths(...)"`. Empty when the feed is in a happy-path state.
|
|
57
57
|
|
|
58
58
|
Free functions:
|
|
59
59
|
|
|
60
60
|
- `runArrival(tt, originStops, targetStops, maxTransfers, departSeconds, requireWheelchair)` — single-departure query. Returns an array of journeys with timed legs.
|
|
61
|
-
- `runRange(tt, originStops, targetStops, maxTransfers, departures, requireWheelchair)` — depart-in-window Pareto profile. Returns `[{depart, journey}]
|
|
61
|
+
- `runRange(tt, originStops, targetStops, maxTransfers, departures, requireWheelchair)` — depart-in-window Pareto profile. Returns `[{depart, journey}]`; `journey` matches a `runArrival` entry (`origin`, `target`, `arrival`, `legs`).
|
|
62
62
|
|
|
63
|
-
Each leg in `journey.legs
|
|
63
|
+
Each leg in `journey.legs`: `{board_stop, alight_stop, route, trip, route_id, depart, arrive, shape}`. `shape` is a `[lat, lon][]` polyline from the trip's `shapes.txt`, or `null` when absent.
|
|
64
64
|
|
|
65
65
|
`originStops` / `targetStops` / `departures` are `Uint32Array`s; times are seconds since midnight on the service date. Full type signatures are in the bundled `vulture_wasm.d.ts`.
|
|
66
66
|
|
|
67
67
|
## Native-only features
|
|
68
68
|
|
|
69
|
-
The wasm bindings
|
|
69
|
+
The wasm bindings omit:
|
|
70
70
|
|
|
71
|
-
- **Custom `Label` impls** and the bundled **`ArrivalAndWalk`** / **`ArrivalAndFare`** labels. Generics monomorphise per call-site
|
|
72
|
-
- **`assert_footpaths_closed()`** —
|
|
73
|
-
- **`new_with_overnight_days(...)`** — multi-day load for
|
|
74
|
-
- **`RaptorCachePool`** —
|
|
71
|
+
- **Custom `Label` impls** and the bundled **`ArrivalAndWalk`** / **`ArrivalAndFare`** labels. Generics monomorphise per call-site; a wasm binding can ship only pre-baked label types. `runArrival` / `runRange` use the default arrival-time label.
|
|
72
|
+
- **`assert_footpaths_closed()`** — closed-footpath single-pass `O(E)` relaxation.
|
|
73
|
+
- **`new_with_overnight_days(...)`** — multi-day load for queries that cross the day boundary.
|
|
74
|
+
- **`RaptorCachePool`** — parallel fan-out; browsers do not expose rayon-style threading by default.
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
For any of these, use the native [`vulture`](https://crates.io/crates/vulture) crate.
|
|
77
77
|
|
|
78
78
|
## Examples
|
|
79
79
|
|
|
@@ -123,7 +123,7 @@ for (const j of journeys) {
|
|
|
123
123
|
|
|
124
124
|
### 2. Departure window (range query)
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
Pareto-optimal options across a range of departures (here, every 5 minutes from 09:00 to 10:00):
|
|
127
127
|
|
|
128
128
|
```js
|
|
129
129
|
import init, { VultureTimetable, runRange } from "vulture-wasm";
|
|
@@ -165,7 +165,7 @@ for (const entry of profile) {
|
|
|
165
165
|
|
|
166
166
|
### 3. Walking footpaths from coordinates
|
|
167
167
|
|
|
168
|
-
|
|
168
|
+
Augment a sparse `transfers.txt` (e.g. Helsinki HSL) from stop coordinates and compare:
|
|
169
169
|
|
|
170
170
|
```js
|
|
171
171
|
import init, { VultureTimetable, runArrival } from "vulture-wasm";
|
|
@@ -198,7 +198,7 @@ console.log(`with footpaths: ${after.length} journey(s)`);
|
|
|
198
198
|
|
|
199
199
|
### 4. Querying entire stations (parent-station expansion)
|
|
200
200
|
|
|
201
|
-
|
|
201
|
+
Parent stations (`location_type = 1`) have no boardings of their own; expand to their child platforms (`location_type = 0`) before querying.
|
|
202
202
|
|
|
203
203
|
```js
|
|
204
204
|
import init, { VultureTimetable, runArrival } from "vulture-wasm";
|
|
@@ -237,17 +237,17 @@ const journeys = runArrival(
|
|
|
237
237
|
console.log(`${journeys.length} journey(s) across all platform combinations`);
|
|
238
238
|
```
|
|
239
239
|
|
|
240
|
-
The
|
|
240
|
+
The bundled demo uses the same helper across all three panels.
|
|
241
241
|
|
|
242
242
|
## Perf
|
|
243
243
|
|
|
244
|
-
|
|
244
|
+
No automated browser benchmark yet. The [live demo](https://urschrei.github.io/vulture/) runs every query client-side against the bundled Delhi Metro feed; time it in your browser's performance panel.
|
|
245
245
|
|
|
246
|
-
|
|
246
|
+
Native single-query latency is in the [main README](https://github.com/urschrei/vulture#perf): single-digit microseconds for a small metro feed, single-digit milliseconds for a large regional feed, tens of milliseconds for the heaviest. Browser numbers are slower than native by an engine- and JIT-dependent factor.
|
|
247
247
|
|
|
248
248
|
## Soundness
|
|
249
249
|
|
|
250
|
-
The Rust engine is validated by
|
|
250
|
+
The Rust engine is validated by [`vulture-proptest`](https://github.com/urschrei/vulture/tree/main/vulture-proptest), which compares the algorithm against a brute-force reference solver on every test run. Issue-by-issue audit against the paper: [`docs/soundness.md`](https://github.com/urschrei/vulture/blob/main/docs/soundness.md). The bindings layer is exercised by `vulture-wasm/tests/smoke.mjs`.
|
|
251
251
|
|
|
252
252
|
## Build from source
|
|
253
253
|
|
|
@@ -260,11 +260,11 @@ The Rust engine is validated by a property-based test harness ([`vulture-proptes
|
|
|
260
260
|
wasm-pack build vulture-wasm --target web --release
|
|
261
261
|
```
|
|
262
262
|
|
|
263
|
-
The web (ESM) target is the
|
|
263
|
+
The web (ESM) target is the only output. It works in browsers, modern Node, and any ES-module bundler.
|
|
264
264
|
|
|
265
265
|
## Node
|
|
266
266
|
|
|
267
|
-
Same package, same import
|
|
267
|
+
Same package, same import. Node needs the wasm bytes passed in explicitly (no relative `fetch()` for the bundled `.wasm`):
|
|
268
268
|
|
|
269
269
|
```js
|
|
270
270
|
import init, { VultureTimetable, runArrival } from "vulture-wasm";
|
|
@@ -279,7 +279,7 @@ await init({ module_or_path: readFileSync(wasmPath) });
|
|
|
279
279
|
const tt = new VultureTimetable(readFileSync("feed.zip"), "2024-01-15");
|
|
280
280
|
```
|
|
281
281
|
|
|
282
|
-
|
|
282
|
+
`vulture-wasm/tests/smoke.mjs` loads the bundled Delhi Metro feed and exercises every public function:
|
|
283
283
|
|
|
284
284
|
```sh
|
|
285
285
|
wasm-pack build vulture-wasm --target web --release
|
|
@@ -288,14 +288,14 @@ node vulture-wasm/tests/smoke.mjs
|
|
|
288
288
|
|
|
289
289
|
## Demo page
|
|
290
290
|
|
|
291
|
-
`docs/demo/`
|
|
291
|
+
`docs/demo/` has three panels (stop-to-stop, departure window, walking-footpath comparison) running client-side against the bundled Delhi Metro feed. Live at <https://urschrei.github.io/vulture/>.
|
|
292
292
|
|
|
293
|
-
|
|
293
|
+
Journeys render on a MapLibre dark basemap; geometry from `leg.shape`, per-mode colour from `route.route_color` / `route.route_type`. Wiring in `docs/demo/app.js` (`drawJourney`).
|
|
294
294
|
|
|
295
295
|
## Changelog
|
|
296
296
|
|
|
297
|
-
|
|
297
|
+
[CHANGELOG](https://github.com/urschrei/vulture/blob/main/CHANGELOG.md) in the repo. `vulture` (Rust) and `vulture-wasm` (npm) have independent version streams; entries note both numbers when the bindings move with the engine.
|
|
298
298
|
|
|
299
299
|
## License
|
|
300
300
|
|
|
301
|
-
[Apache-2.0](https://github.com/urschrei/vulture/blob/main/LICENSE.md)
|
|
301
|
+
[Apache-2.0](https://github.com/urschrei/vulture/blob/main/LICENSE.md), matching the [`vulture`](https://github.com/urschrei/vulture) crate.
|
package/package.json
CHANGED
package/vulture_wasm_bg.wasm
CHANGED
|
Binary file
|