Core idea: Given a route (A β B) and a departure time, calculate what weather the driver will encounter at each point along the way, accounting for travel time.
The weather "moves with you" β you don't just get the weather at the destination, you get a timeline of conditions as you drive through them.
| Time | Location | Temp | Rain | Wind | Conditions |
|---|---|---|---|---|---|
| 16:30 | π Budapest (start) | 32Β°C | 0 mm | 12 km/h | βοΈ Clear, hot |
| 17:15 | π Hatvan | 30Β°C | 0 mm | 15 km/h | β Partly cloudy |
| 18:00 | π FΓΌzesabony | 28Β°C | 2.1 mm | 25 km/h | π§οΈ Light rain |
| 18:45 | π Miskolc (arrive) | 26Β°C | 4.3 mm | 35 km/h | π§οΈ Rain, gusty |
| Parameter | Format | Example |
|---|---|---|
| Route | Google Maps URL or list of city names | https://maps.google.com/.../@47.5,19.0 or "Budapest, Hatvan, Miskolc" |
| Departure time | ISO datetime or relative | 2026-08-08T16:30 or "now" or "+2h" |
| Precision | low / medium / high | --precision medium |
| Parameter | Format | Example |
|---|---|---|
| Stops | location + duration | --stop "Hatvan:60min" |
| Speed override | km/h average | --speed 100 (default: use route estimate) |
| Output format | html / json / email | --format html |
| Level | Waypoint Frequency | Example (BudapestβMiskolc, 180km) |
|---|---|---|
| low | Start + End only | 2 points |
| medium | Every ~30-40 min of driving | 4-5 points |
| high | Every ~15-20 min of driving | 8-10 points |
Option A β Google Maps Directions API (requires API key, paid after quota)
Option B β OSRM (Open Source Routing Machine) β free, self-hosted or public demo server
Option C β Manual waypoints β user provides city list, we geocode and estimate times
Recommended: Option B (OSRM) with fallback to Option C.
https://router.project-osrm.org/route/v1/driving/{coords}
def sample_waypoints(route_geometry, precision, stops):
"""
Given a route polyline and precision level,
return a list of (lat, lon, estimated_arrival_time) tuples.
"""
total_duration = route.duration # seconds
intervals = {
"low": [0, total_duration], # start + end
"medium": range(0, total_duration, 1800), # every 30 min
"high": range(0, total_duration, 900), # every 15 min
}
for elapsed in intervals[precision]:
point = interpolate_along_route(geometry, elapsed / total_duration)
arrival = departure_time + timedelta(seconds=elapsed) + stop_delay(elapsed, stops)
waypoints.append((point.lat, point.lon, arrival, nearest_city(point)))
return waypoints
def get_route_weather(waypoints):
"""Fetch forecast for each waypoint at its specific arrival time."""
results = []
for lat, lon, arrival_time, city_name in waypoints:
# Open-Meteo hourly forecast β free, no key needed
forecast = fetch_open_meteo(
lat=lat, lon=lon,
start=arrival_time.replace(minute=0),
end=arrival_time.replace(minute=0) + timedelta(hours=1),
params=["temperature_2m", "precipitation", "cloud_cover",
"wind_speed_10m", "wind_gusts_10m", "weather_code"]
)
results.append({
"city": city_name,
"lat": lat, "lon": lon,
"arrival": arrival_time,
"weather": interpolate_to_exact_time(forecast, arrival_time)
})
return results
When the user declares a stop (e.g., --stop "Hatvan:60min"):
i18n.js)πΊοΈ Route Weather: Budapest β Miskolc
Departure: Sat Aug 8, 16:30 β’ Distance: 181 km β’ Duration: 2h 15min β’ Precision: medium
| β±οΈ Time | π Location | π‘οΈ | π§οΈ | π¨ | Conditions |
|---|---|---|---|---|---|
| 16:30 | Budapest (start) | 32Β°C | β | 12 km/h | βοΈ Clear |
| 17:15 | Hatvan | 30Β°C | β | 15 km/h | β Partly cloudy |
| 17:15β18:15 | β Stop: Hatvan (1h) | β Warm, dry during stop | |||
| 19:00 | FΓΌzesabony | 28Β°C | 2.1 mm | 25 km/h | π¦οΈ Light showers |
| 19:45 | Miskolc (arrive) | 26Β°C | 4.3 mm | 35 km/h | π§οΈ Rain + wind β οΈ |
β οΈ Rain expected in the Miskolc area from 19:00. Consider earlier departure or rain gear.
# Basic usage
./scripts/route-weather/route-weather.py \
--from "Budapest" --to "Miskolc" \
--depart "2026-08-08T16:30" \
--precision medium
# With Google Maps link
./scripts/route-weather/route-weather.py \
--url "https://www.google.com/maps/dir/Budapest/Miskolc" \
--depart now \
--precision high
# With stops
./scripts/route-weather/route-weather.py \
--from "Budapest" --to "Miskolc" \
--depart "+1h" \
--precision medium \
--stop "Hatvan:60min" \
--stop "FΓΌzesabony:15min"
# Output options
--format html # default: generates HTML report
--format json # machine-readable
--dry-run # show plan without fetching weather
--output route-weather.html
scripts/route-weather/ βββ route-weather.py # Main script βββ template.html # HTML report template βββ route_engine.py # OSRM routing + waypoint sampling βββ geocoder.py # Reverse geocoding (coords β city name) βββ README.md shared/ βββ config.py # Add route-weather defaults βββ i18n.js # Reuse existing translations (add route keys)
| Service | Purpose | Cost | Rate Limit |
|---|---|---|---|
| OSRM (public demo) | Route calculation | Free | Fair use |
| Open-Meteo | Weather forecast | Free | 10,000/day |
| Nominatim (OSM) | Reverse geocoding | Free | 1 req/sec |
No API keys needed. All services are free and open. Existing requests library is sufficient β no new Python deps.
--from / --to / --depart / --precision--stop "City:duration")run-and-publish.py (optional daily route?)| Risk | Impact | Mitigation |
|---|---|---|
| OSRM public demo goes down | No route calculation | Fallback: straight-line interpolation with estimated speed |
| Nominatim rate limit (1/sec) | Slow for high-precision routes | Batch + cache; use Hungarian settlement DB offline |
| Open-Meteo only hourly resolution | Arrival at :35 gets :00 data | Linear interpolation between hours |
| Google Maps URL format changes | Parsing breaks | Keep manual --from/--to as primary; URL is convenience |