Skip to main content

Efficient and Compact Library for Approximate Instant Routing

Project description

eclair-routing

Efficient and Compact Library for Approximate Instant Routing

A lightweight, fast alternative to OSRM, ORS, or Google Maps for estimating travel distances and times between geographic points — without a road network graph.

The idea

Traditional routing engines (OSRM, OpenRouteService, Google Maps, Here) rely on detailed road network graphs. They're precise, but heavy: large datasets to download, complex setups, and significant compute costs.

eclair-routing takes a different approach: estimate travel time using the Haversine formula (great-circle distance), a speed model that accounts for trip length, and an optional H3 hexagonal grid of speed factors to adjust for population density.

The result is surprisingly accurate for many use cases (logistics planning, fleet optimization, isochrone estimation) while being:

  • Fast — Rust core with NumPy integration, no network calls
  • Light — no road graph data needed, just an optional config file
  • Simplepip install eclair-routing, one class, three methods
  • Free — Apache 2.0, no API keys, no limits

How it works

  1. Haversine distance between two points, multiplied by a distance factor that varies with trip length to approximate actual driving distance
  2. Speed model where average speed increases with distance (short urban trips are slower, long highway trips are faster): speed = vmin + (vmax - vmin) * (1 - e^(-k * distance))
  3. H3 density adjustment (optional): the straight line between origin and destination is traced through H3 hexagons (resolution 7, ~5km edge). Each hex can have a speed factor (0 to 1). The harmonic mean of factors along the path adjusts the travel time — crossing a dense city slows you down

Install

pip install eclair-routing

From source (development)

git clone https://github.com/maroudja/eclair.git
cd eclair

python -m venv .venv
source .venv/bin/activate

pip install maturin numpy
maturin develop

# Optional: install dev dependencies for tests
pip install pytest

Run tests

pytest tests/ -v
cargo test --lib

Usage

Quick start

from eclair_routing import Router, Point

router = Router("car")
result = router.estimate(Point(48.8566, 2.3522), Point(45.7640, 4.8357))
print(result)  # TravelResult(distance=470.4 km, time=332 min)

Transport modes

Five built-in modes: car, truck, bike, scooter, foot.

from eclair_routing import Router, Point

router = Router("truck")
result = router.estimate(Point(48.8566, 2.3522), Point(43.2965, 5.3698))
print(f"{result.distance_km:.0f} km, {result.time_hours:.1f} h")

Distance and time matrices

from eclair_routing import Router, Point

router = Router("car")

cities = [
    Point(48.8566, 2.3522),   # Paris
    Point(45.7640, 4.8357),   # Lyon
    Point(43.2965, 5.3698),   # Marseille
]

# Square matrix (n x n)
dist_matrix, time_matrix = router.matrix(cities)

# Non-square matrix (origins x destinations)
origins = [Point(48.8566, 2.3522), Point(45.7640, 4.8357)]
destinations = [Point(43.2965, 5.3698), Point(43.6047, 1.4442)]

dist_matrix, time_matrix = router.matrix_od(origins, destinations)

Custom H3 density config

router = Router("car", config_path="factors.parquet")  # CSV or Parquet
router = Router("car", config_path=None)                # disable config

The config file maps H3 cell indexes (resolution 7) to speed factors:

h3_index,factor
872a1008fffffff,0.3
872a1009fffffff,0.8
  • factor = 1.0 — normal speed (no adjustment)
  • factor = 0.5 — half speed (travel time doubled)
  • factor = 0.1 — very slow (dense city center)
  • Hexagons not in the file default to 1.0

Expert API — EclairEngine

For full control over speed-model parameters, use EclairEngine directly:

from eclair_routing import EclairEngine

engine = EclairEngine(
    vmin=25.0,       # min speed km/h (short trips)
    vmax=100.0,      # max speed km/h (long trips)
    k=0.02,          # speed curve steepness
    f_long=1.25,     # asymptotic distance factor (long trips)
    f_peak=1.45,     # peak distance factor (medium trips)
    d_peak_km=5.0,   # distance at which factor peaks (km)
)

dist, time = engine.estimate_travel(48.8566, 2.3522, 45.7640, 4.8357)
print(f"{dist/1000:.0f} km, {time/3600:.1f} hours")

Benchmark

Accuracy compared to OSRM (car, foot, bike) and HERE API (truck, scooter) on random point pairs across France.

Mode Metric Pairs Mean gap Median gap |Mean| gap |Median| gap P90 |gap| P95 |gap|
Car Time 5700 +2.65% +4.94% 9.34% 8.50% 17.03% 20.07%
Car Distance 5700 -0.95% -0.67% 6.46% 5.33% 13.10% 16.37%
Foot Time 2756 -0.09% -1.30% 3.66% 2.26% 6.37% 9.72%
Foot Distance 2756 +1.11% +3.46% 5.54% 4.29% 7.12% 8.66%
Bike Time 2756 +0.48% +0.56% 2.48% 1.50% 5.20% 7.19%
Bike Distance 2756 +1.75% +2.99% 4.22% 4.05% 6.76% 7.79%
Scooter Time 5692 +3.92% +3.43% 6.49% 4.41% 10.51% 14.49%
Scooter Distance 5692 +0.87% +2.01% 5.88% 5.13% 11.26% 13.90%
Truck Time 5700 +2.89% +4.66% 8.21% 7.55% 15.28% 17.82%
Truck Distance 5700 -0.83% -0.55% 6.25% 5.08% 12.76% 16.14%

License

Apache 2.0 — see LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eclair_routing-0.1.7.tar.gz (70.2 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

eclair_routing-0.1.7-cp313-cp313-win_amd64.whl (89.3 MB view details)

Uploaded CPython 3.13Windows x86-64

eclair_routing-0.1.7-cp313-cp313-macosx_11_0_arm64.whl (89.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

eclair_routing-0.1.7-cp313-cp313-macosx_10_12_x86_64.whl (90.3 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

eclair_routing-0.1.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (91.0 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

eclair_routing-0.1.7-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (91.3 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ ARM64

File details

Details for the file eclair_routing-0.1.7.tar.gz.

File metadata

  • Download URL: eclair_routing-0.1.7.tar.gz
  • Upload date:
  • Size: 70.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.12.4

File hashes

Hashes for eclair_routing-0.1.7.tar.gz
Algorithm Hash digest
SHA256 7db2f20b4e6b01b855a517454cceb849647d600bc623084700286fb2bd00dcf4
MD5 9fabe3df4f61facd19f53e71447dae49
BLAKE2b-256 a6718c6442eecd922c97309ecafc674eea78b646aa6a27c5b9eb8e9be199d19a

See more details on using hashes here.

File details

Details for the file eclair_routing-0.1.7-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for eclair_routing-0.1.7-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c3f6fe421082fe091afe9448cc463b8ea07d40916e3923901fc9ad50ec5d20c6
MD5 402e5b964cba93ff5d4354f2d7fdb620
BLAKE2b-256 5082045038ea78c6b17b27b7bed06816b51942a5021b7c0138b3dd87e5510972

See more details on using hashes here.

File details

Details for the file eclair_routing-0.1.7-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for eclair_routing-0.1.7-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cd0065c95fbbec3759b993f5afca0c8ee5254c3b5b02b3898beea46dddab1c30
MD5 0d222c17a1f486e3359a35a8c90906f2
BLAKE2b-256 1d70a1ccda1617afa8dab9a954c26d83a8cb538630433a57e3acb46cb70df3bf

See more details on using hashes here.

File details

Details for the file eclair_routing-0.1.7-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for eclair_routing-0.1.7-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6767f25b48550316cdcefa45106eca9ed8b9f6dae30724575f1d8bf197da90ea
MD5 1cea38780655562945b9a48480c2776b
BLAKE2b-256 2f000b6dc51889b7536e6c32183b1a3894d20154c3e7b0600a289ed89b67f352

See more details on using hashes here.

File details

Details for the file eclair_routing-0.1.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for eclair_routing-0.1.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5352bf357b71140d9701468941644bec8e6eadd2fb2f487ed55ee14f445cc500
MD5 2fe1d94b885a79be3817ab0b656f13e4
BLAKE2b-256 6f133bc1dca872a9cf3e28986bee480e6a846b1bcf2e48f89b46d38c18da7a18

See more details on using hashes here.

File details

Details for the file eclair_routing-0.1.7-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for eclair_routing-0.1.7-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 cf6abc43f909faebb59363ce4341f5ce11701afac21f1d2502d8c4bd217f8bfe
MD5 bc7bb9795905f3037a627c542e8c8e6a
BLAKE2b-256 ece71fc8029dcba1b1172ab518fbabe95559e7a7885402d142e8c928a8fc84d4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page