MCPcopy Create free account
hub / github.com/dabreegster/route_snapper

github.com/dabreegster/route_snapper @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
138 symbols 317 edges 11 files ⚖ Apache-2.0 15 documented · 11% updated 7mo ago★ 23527 open issues

Browse by type

Functions 110 Types & classes 28
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

MapLibre route snapper

NPM

This plugin lets you draw routes and polygon areas in MapLibre GL that snap to some network (streets, usually). Unlike similar plugins that send a request to a remote API for routing, this one does the routing client-side. This works by loading a pre-built file covering a fixed area and calculating the routes locally.

Demo

Demo

Usage

See the user guide for full details and examples.

  1. Build a graph file covering some fixed area
  2. npm install route-snapper
  3. Construct the RouteSnapper object, passing in the graph file a MapLibre map
  4. Listen to events to use the drawn routes

Development

route-snapper is written in Rust, compiled to WASM to run in the browser, and has a simple Javascript wrapper library. You need wasm-pack and Python (to run a local server).

cd examples
./serve_locally.sh

Contributing

There are many ideas for improving this plugin, such as customizing the instructions, controls, and route style, and generating graph files on-the-fly from vector tile data. Check out the issues or start your own.

This project follows the Rust code of conduct and is Apache 2.0 licensed.

Related work

This tool started life in fall 2021 through Ungap the Map, for sketching potential cycle lanes along existing roads. It used a custom UI and map rendering library built on top of OpenGL. A year later, the idea was adapted to work in ATIP, using MapLibre GL. The functionality for dragging waypoints is partly inspired by Felt, Google Maps, and similar products.

Other projects with client-side routing: ngraph.path, geojson-path-finder

Extension points exported contracts — how you extend this code

browse all types & interfaces →

Core symbols most depended-on inside this repo

browse all functions →

Shape

Method 73
Function 37
Class 21
Interface 4
Enum 3

Languages

Rust68%
TypeScript32%

Modules by API surface

route-snapper/src/lib.rs57 symbols
route-snapper-ts/src/index.ts27 symbols
route-snapper/lib.js13 symbols
route-snapper-graph/src/lib.rs12 symbols
route-snapper/src/tests.rs9 symbols
osm-to-route-snapper/src/lib.rs7 symbols
route-snapper-ts/src/split.ts4 symbols
geojson-to-route-snapper/src/lib.rs4 symbols
osm-to-route-snapper/src/main.rs2 symbols
geojson-to-route-snapper/src/main.rs2 symbols
debug-graph/src/main.rs1 symbols

For agents

$ claude mcp add route_snapper \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page