Skip to main content

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 as commute_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_KEY in the environment (or pass api_key=) and install the [ors] extra. method becomes "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). method is "heuristic".
  • A routing/network failure silently degrades to the heuristic — estimate_commute never 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


Download files

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

Source Distribution

commute_estimate_hirewire-0.1.0.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

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

commute_estimate_hirewire-0.1.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file commute_estimate_hirewire-0.1.0.tar.gz.

File metadata

File hashes

Hashes for commute_estimate_hirewire-0.1.0.tar.gz
Algorithm Hash digest
SHA256 590950917e3d4cb63f48586a9eaaf3713d8505c2d174863e0c44de4ca5502995
MD5 d98df1dd2c77536e0975a74b103996a9
BLAKE2b-256 e234f726c14bd7cb4f764a002d8508dfe5c951008fa394309d0be1817e83b315

See more details on using hashes here.

File details

Details for the file commute_estimate_hirewire-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for commute_estimate_hirewire-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5784ad228da8301e0362f008e3aa2b11d5fd649290f9372350278f4b55ddfd35
MD5 ae29054f7f917c39c89eec8a672e2e49
BLAKE2b-256 d3b9a5a29067d0a70172a4cf0101f66040f9037256793f8a51b43a603788055d

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