-
-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Render A/B Street's lanes and traffic simulation on top of Mapbox GL (#…
…788) [rebuild] [release]
- Loading branch information
1 parent
04b54b0
commit 00df96f
Showing
21 changed files
with
751 additions
and
91 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ members = [ | |
"map_model", | ||
"osm_viewer", | ||
"parking_mapper", | ||
"piggyback", | ||
"popdat", | ||
"santa", | ||
"sim", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[package] | ||
name = "piggyback" | ||
version = "0.1.0" | ||
authors = ["Dustin Carlino <[email protected]>"] | ||
edition = "2021" | ||
|
||
[lib] | ||
crate-type = ["cdylib", "lib"] | ||
|
||
[features] | ||
wasm = ["getrandom/js", "js-sys", "map_gui/wasm", "wasm-bindgen", "web-sys", "widgetry/wasm-backend"] | ||
|
||
[dependencies] | ||
abstio = { path = "../abstio" } | ||
abstutil = { path = "../abstutil" } | ||
geom = { path = "../geom" } | ||
getrandom = { version = "0.2.3", optional = true } | ||
js-sys = { version = "0.3.51", optional = true } | ||
log = "0.4.14" | ||
map_gui= { path = "../map_gui" } | ||
map_model = { path = "../map_model" } | ||
sim = { path = "../sim" } | ||
wasm-bindgen = { version = "0.2.70", optional = true } | ||
web-sys = { version = "0.3.47", optional = true } | ||
widgetry = { path = "../widgetry" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# A/B Street + Mapbox demo | ||
|
||
This is an example of integrating parts of A/B Street with Mapbox GL. It's a | ||
normal web app using Mapbox, but it includes a layer rendering streets and | ||
moving agents from A/B Street. | ||
|
||
The goal is to increase interoperability and meet developers where they're at. | ||
Parts of the A/B Street code-base are intended as | ||
[a platform](https://a-b-street.github.io/docs/tech/map/platform.html) to build | ||
other transportation-related things, using unique features like the detailed | ||
street rendering. But Rust and our unusual UI library are a huge barrier. | ||
Treating A/B Street as a layer that can be added to Mapbox and as a library with | ||
a simple API for controlling a traffic simulation should be an easier start. | ||
|
||
Another goal is to take advantage of all the great stuff that exists in the web | ||
ecosystem. Instead of implementing satellite layers, multi-line text entry | ||
(seriously!), and story mapping ourselves, we can just use stuff that's built | ||
aready. | ||
|
||
## How to run | ||
|
||
You'll need `wasm-pack` and `python3` setup. You'll also need the `data/system/` | ||
directory to contain some maps. | ||
|
||
Quick development: | ||
`wasm-pack build --dev --target web -- --features wasm && ./serve_locally.py` | ||
|
||
To build the WASM in release mode: | ||
`wasm-pack build --release --target web -- --features wasm && ./serve_locally.py` | ||
|
||
Maps can be specified by URL: | ||
|
||
- http://localhost:8000/?map=/data/system/us/seattle/maps/arboretum.bin | ||
|
||
No deployment instructions yet. | ||
|
||
## How it works | ||
|
||
The `PiggybackDemo` struct is a thin layer written in Rust to hook up to the | ||
rest of the A/B Street codebase. After beng initialized with a WebGL context and | ||
a map file, it can render streets and agents and control a traffic simulation. | ||
It serves as a public API, exposed via WASM. Then a regular Mapbox GL app treats | ||
it as a library and adds a custom WebGL rendering layer that calls this API. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
# This creates a .zip with all of the files needed to serve a copy of the Mapbox demo. | ||
|
||
set -x | ||
set -e | ||
|
||
wasm-pack build --release --target web -- --features wasm | ||
|
||
mkdir mapbox_demo | ||
cp -Rv index.html serve_locally.py pkg mapbox_demo | ||
|
||
mkdir -p mapbox_demo/data/system/us/seattle/maps | ||
mkdir -p mapbox_demo/data/system/de/berlin/maps | ||
# Just include a few maps | ||
cp ../data/system/us/seattle/maps/montlake.bin mapbox_demo/data/system/us/seattle/maps | ||
cp ../data/system/de/berlin/maps/neukolln.bin mapbox_demo/data/system/de/berlin/maps | ||
|
||
# Uncomment with caution! | ||
# Note this embeds a tiny slice of the data/ directory underneath mapbox_demo. | ||
# The S3 bucket has gzipped map files, but the JS / Rust layers don't handle | ||
# reading both yet. | ||
#aws s3 sync mapbox_demo s3://abstreet/dev/mapbox_demo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../data/ |
Oops, something went wrong.