Straight-line distance + road drive-time estimates in one call, with a heuristic fallback.
Project description
commute-estimate-hirewire
Straight-line distance and road drive-time in one call — with a pure-Python heuristic fallback so it always returns an answer, even with no API key and no network.
Installed as
commute-estimate-hirewire; imported ascommute_estimate.
from commute_estimate import estimate_commute
est = estimate_commute((37.14, -122.07), (37.34, -121.89))
est.straight_line_miles # 16.9 — great-circle, always present
est.drive_minutes # 38.0 — road minutes (ORS) or heuristic
est.method # "ors:driving-car" | "heuristic" | "haversine_only"
Coordinates are (lat, lon) tuples throughout.
Install
pip install commute-estimate-hirewire # core only (heuristic distance/time)
pip install "commute-estimate-hirewire[ors]" # + real road routing via OpenRouteService
pip install "commute-estimate-hirewire[geocode]" # + address -> coordinates via Nominatim
pip install "commute-estimate-hirewire[ors,geocode]"
Drive time
- With an OpenRouteService key (free at https://openrouteservice.org/dev): set
ORS_API_KEYin the environment (or passapi_key=) and install the[ors]extra.methodbecomes"ors:driving-car"— real road network (traffic-free). - Without a key: drive time falls back to
straight_line_miles × detour_factor ÷ avg_speed(defaults: 1.3 and 35 mph, both tunable).methodis"heuristic". - A routing/network failure silently degrades to the heuristic —
estimate_commutenever raises.
One origin, many destinations
estimate_matrix resolves a whole one-to-many set in a single ORS request — ideal for
building a distance table:
from commute_estimate import estimate_matrix
home = (37.14, -122.07)
sites = [(37.34, -121.89), (37.80, -122.27)]
for est in estimate_matrix(home, sites):
print(est.straight_line_miles, est.drive_minutes, est.method)
Geocoding (optional)
commute_estimate.geocode.Geocoder turns an address/place string into coordinates via
OpenStreetMap Nominatim (no key), with optional on-disk caching and graceful misses:
from commute_estimate.geocode import Geocoder
geo = Geocoder(cache_path="geocode_cache.json") # caching optional
coord = geo.geocode("San Jose, CA") # (lat, lon) or None
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file commute_estimate_hirewire-0.1.0.tar.gz.
File metadata
- Download URL: commute_estimate_hirewire-0.1.0.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
590950917e3d4cb63f48586a9eaaf3713d8505c2d174863e0c44de4ca5502995
|
|
| MD5 |
d98df1dd2c77536e0975a74b103996a9
|
|
| BLAKE2b-256 |
e234f726c14bd7cb4f764a002d8508dfe5c951008fa394309d0be1817e83b315
|
File details
Details for the file commute_estimate_hirewire-0.1.0-py3-none-any.whl.
File metadata
- Download URL: commute_estimate_hirewire-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5784ad228da8301e0362f008e3aa2b11d5fd649290f9372350278f4b55ddfd35
|
|
| MD5 |
ae29054f7f917c39c89eec8a672e2e49
|
|
| BLAKE2b-256 |
d3b9a5a29067d0a70172a4cf0101f66040f9037256793f8a51b43a603788055d
|