Cette page est affichée en anglais. Une traduction française est en cours.
ConfigsJul 3, 2026·3 min de lecture

OSRM — High-Performance Open Source Routing Engine

OSRM computes shortest paths on road networks using OpenStreetMap data, delivering sub-second route calculations for driving, cycling, and walking.

Prêt pour agents

Installation avec revue préalable

Cet actif nécessite une revue. Le prompt copié demande un dry-run, affiche les écritures, puis continue seulement après confirmation.

Needs Confirmation · 64/100Policy : confirmer
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
OSRM Overview
Commande avec revue préalable
npx -y tokrepo@latest install 30d7ed39-767a-11f1-9bc6-00163e2b0d79 --target codex

Dry-run d'abord, confirmez les écritures, puis lancez cette commande.

Introduction

OSRM (Open Source Routing Machine) is a C++ routing engine that computes fastest paths on road networks derived from OpenStreetMap. It preprocesses map data into a compact graph representation, enabling sub-second responses for route, table, match, trip, and nearest queries.

What OSRM Does

  • Computes point-to-point routes with turn-by-turn instructions
  • Generates distance and duration matrices for many-to-many queries
  • Matches GPS traces to road segments via map matching
  • Solves traveling salesman approximations with the trip service
  • Finds nearest road segments for snapping coordinates to the network

Architecture Overview

OSRM uses a multi-level Dijkstra (MLD) or contraction hierarchies (CH) algorithm. During preprocessing, the road graph is extracted from OSM PBF files using Lua profiles that define vehicle-specific speeds and restrictions. The preprocessed data is loaded into memory by the HTTP server (osrm-routed), which handles concurrent requests via a thread pool and responds with JSON including geometry, duration, and step-by-step instructions.

Self-Hosting & Configuration

  • Run with Docker using the official ghcr.io/project-osrm/osrm-backend image
  • Download region-specific OSM extracts from Geofabrik or planet.openstreetmap.org
  • Customize routing behavior by editing Lua profiles for car, bicycle, or foot
  • Use MLD algorithm for faster preprocessing and comparable query speed to CH
  • Deploy behind a reverse proxy with caching for production workloads

Key Features

  • Sub-second response times even for cross-country routes on a single machine
  • HTTP API compatible with the OSRM API v1 specification used by many frontends
  • Lua-scripted profiles allow customizing speeds, turn penalties, and access restrictions
  • Supports alternative routes, waypoints, and route annotations (speed, duration per segment)
  • Compact preprocessed data fits continental datasets in moderate RAM

Comparison with Similar Tools

  • GraphHopper — Java-based, supports more profiles out of the box, easier customization
  • Valhalla — multi-modal routing with transit support, dynamic costing, tiled data
  • Google Directions API — cloud service, broader data coverage, usage-based pricing
  • pgRouting — SQL-based routing inside PostgreSQL, slower but tightly integrated with spatial queries

FAQ

Q: How much RAM does OSRM need? A: A planet-wide dataset requires roughly 64 GB RAM. Country-level extracts typically need 2-8 GB.

Q: Can OSRM handle real-time traffic? A: OSRM uses static edge weights. For live traffic, you need to reprocess data or use tools that support dynamic costing.

Q: Does it support public transit routing? A: No. OSRM focuses on road-network routing. For multi-modal transit, consider Valhalla or OpenTripPlanner.

Q: How often should I update the map data? A: Reprocess from a fresh OSM extract weekly or monthly depending on how current your routes need to be.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires