Skip to content

The roadstyle program

roadstyle is the Rust engine as one program, with no Python. Each command is one job. The options have the names of roadstyle's Python keywords: --color-by lanes is color_by="lanes", and --no-arrows is arrows=False. A value that is JSON (a number, true, a list) is read as JSON.

Build it from the repository:

cargo build --release --manifest-path rust/Cargo.toml -p roadstyle-cli

The program is rust/target/release/roadstyle. roadstyle help lists the commands.

Make the page

roadstyle page makes the same page as render_edges(backend="web"): the map, its dashboard and MapLibre, in one file that works offline. Any other option is a keyword of render:

roadstyle page roads.parquet out/map.html --basemap osm --views '{"plain": {"road_fill": false}}'
roadstyle page roads.parquet out/geojson.html --no-tiles        # GeoJSON roads: the page has tiles by default
roadstyle page roads.parquet out/mvt.html --tile-format mvt
roadstyle page roads.parquet out/dashboard.html --template dashboard

A base map that is a tile URL can take a key: --api-key KEY, else the environment variable ROADSTYLE_API_KEY. Google 3D and the Street View window take --street-view-key KEY, else GOOGLE_MAPS_KEY. The program writes a key into the page only when you give one.

Draw a map in two stages

Stage 1 makes the style, one file for each source, and the road table. The program reads the roads by the file's extension: GeoParquet (.parquet, the line in the column geometry in longitude and latitude), GeoJSON (.geojson), a Shapefile (.shp, with its .dbf and .prj beside it) or a GeoPackage (.gpkg, its first feature table). It reprojects a Shapefile or a GeoPackage in another CRS to longitude and latitude. page and levels make read the same files.

roadstyle sources roads.parquet out/stage1 --format geoparquet --color-by lanes

Stage 2 makes the vector tiles from stage 1's files: one PMTiles file, or a folder of XYZ tiles with its style.json.

roadstyle tiles out/stage1 out/roads.pmtiles
roadstyle tiles out/stage1 out/xyz --format xyz --base-url https://example.org/tiles
roadstyle tiles out/stage1 out/roads_mvt.pmtiles --tile-format mvt

The tiles are MapLibre Tiles (MLT) by default, as in every other path. --tile-format mvt writes Mapbox Vector Tiles. One rule cuts the tiles for page, tiles and the other paths (Make tiles and PMTiles).

Make and solve a level area

roadstyle levels make edges.parquet out/area      # roads.parquet, pairs.csv, edits.csv
roadstyle levels make edges.parquet out/area --boundary area.geojson   # also boundary.geojson
roadstyle levels solve out/area                   # levels.csv, levels_info.json
roadstyle levels edit out/area                    # the level editor, http://127.0.0.1:8780/level_editor/
roadstyle levels edit out/area --port 8790        # another port

levels make takes the options of roadstyle-levels make: --id-col, --band-col, --order, --band-dist, --head-m, --near-rules and the tag columns (--highway-col, --layer-col, --bridge-col, --tunnel-col, --junction-col). --boundary AREA.geojson copies a GeoJSON polygon, feature or feature collection to boundary.geojson in the area folder, and the level editor draws it as the dashed line of the area's edge. It gives the same files as Python's make_area: Monaco in 0.1 s (Python 2.2 s), Tartu in 0.7 s (Python 13.2 s).

levels edit AREA_DIR is the level editor from the Rust program, with no Python. It checks that the folder has roads.parquet, then serves the editor page (the standard dashboard: one panel, the bar, both themes, the phone sheet) and saves edits.csv, heads.csv, caps.csv and levels.csv. --page DIR serves another page folder. levels edit (and serve, the same without the check that the folder has roads.parquet) answers only on 127.0.0.1, only to its own address, and saves only the editor page's own changes. Its page files are in the program. Build the page's WebAssembly package with rust/roadstyle-wasm/build_editor.sh before you build the program.

The guide Which road is on top shows the editor.