Skip to content

Latest commit

ย 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿšš RoutePro KSA - Truck Route & Fuel Calculator

Fleet road routing & fuel system for KSA heavy-truck operations โ€” zero-build, single-file web app.

A pure client-side application for planning multi-stop truck routes, simulating the fuel & mission math (distance, liters, tank sufficiency, driving time, mandatory rest breaks, road delays, ETA) and pushing results into KML (Google Earth), a Google Maps directions link, or a WhatsApp summary โ€” everything inside one HTML file.

HTML5 CSS3 JavaScript Tailwind CSS Leaflet OpenStreetMap Geoapify Routing Font Awesome 100% Client-Side No Build Required Status: Active


โœจ Features

๐ŸŽฏ Feature What it does
๐Ÿ—บ๏ธ Multi-stop route planning Start point, drag-and-drop reorderable destination stops, optional return point
๐Ÿ–ฑ๏ธ Click-to-set on map Click anywhere and set it as Start / Add as Stop / Return from one popup
๐Ÿ“ Live coordinate preview Markers + permanent tooltips update as you type lat, lon and auto-fit the view
๐Ÿ” Jump-to-coordinates widget Paste lat, lon and fly the map to that spot instantly
๐Ÿงญ 5 base-map styles Standard OSM, English Streets (Esri), Voyager (CARTO), Light Map (Carto), Hybrid Satellite (Esri)
โš–๏ธ Truck load presets Light Truck (3.5t) / Medium Truck (15t) / Heavy Truck Partial (28t) / Heavy Truck Full (42t) / Extra Heavy (45t) โ€” configurable in Settings; each auto-applies a realistic km/L efficiency
๐Ÿ›ป Vehicle Profile confirmation Choose a Geoapify routing profile + confirm vehicle dimensions (weight/height/width/length) per calculation
โ›ฝ Fuel tank module Tank fuel, auxiliary fuel (PTO / idling / reefer), km/L, price (SAR/L) โ€” surplus or refuel-deficit status
๐Ÿ›ก๏ธ Saudi TGA Compliance Mode Enforces configurable max driving, mandatory breaks, and daily rest rules for KSA driver hours-of-service
โฑ๏ธ Mission timeline & ETA Departure date/time โ†’ arrival, split into driving / breaks / daily rest / delays
๐Ÿ›ฃ๏ธ Geoapify truck routing Real road polyline & distance; Haversine straight-line fallback with dashed line if offline
๐Ÿ“ฆ Exports & integrations KML (Google Earth pins + path), Google Maps link (with waypoints), WhatsApp summary
๐Ÿ’พ Profile save / load Full parameter set exported / imported as JSON profile files
๐Ÿ—„๏ธ SQLite database Routes saved locally in browser via sql.js + IndexedDB persistence
โš™๏ธ Settings panel Live preview + show/hide KML, GMaps, WhatsApp toolbar buttons โ€” saved in localStorage

๐Ÿš€ Quick Start

No build step โ€” just open the file:

  1. Open index.html in any modern browser.
    • Double-clicking works for basic use, but some map tiles and CDN resources may be blocked by browser file:// security policies.
    • For the full experience, serve it via a local server, e.g.:
      • VS Code Live Server extension
      • python -m http.server 8080 then open http://localhost:8080
  2. Enter your Geoapify API key in Settings (the app uses a user-provided key, not a hardcoded one).
  3. Enter a start coordinate in lat, lon format, e.g. Riyadh: 24.7136, 46.6753.
    • Easier: toggle Click to Set: ON, click the map โ€” or use the Jump to Coordinates widget.
  4. Add destination stops with + Add Stop (drag ๐Ÿ–๏ธ to re-order) and set an optional return point (leave empty for one-way).
  5. Choose truck load weight, set available fuel, extra fuel, km/L, price/L (SAR), max speed, delays and departure date/time.
  6. Keep Saudi TGA Compliance ON (default) for KSA driver rules โ€” or switch OFF for custom rest intervals.
  7. Press ๐Ÿงฎ Calculate Truck Route & Fuel and read the summary cards + modal.

โš ๏ธ Internet is required โ€” tile servers, Geoapify routing API and CDNs load at runtime. If the router is unavailable, the app falls back to straight-line (approximate) distances with a dashed route preview.


๐Ÿ”‘ Geoapify API Key

This app uses a user-based API key model:

  • Each user enters their own Geoapify API key in Settings.
  • The key is stored only in the userโ€™s browser localStorage.
  • The key is never sent to any server except Geoapify itself during routing requests.

Security advice for users:

  • In your Geoapify account, restrict your API key to:
    • Allowed Origins: your deployment domain (e.g. https://your-app.vercel.app)
    • Allowed HTTP referrers: https://*.vercel.app/* (for Vercel deployments)
    • Allowed IP addresses: leave empty (Vercel uses dynamic edge IPs)
    • CORS Access-Control-Allow-Origin: set to your exact origin, not *
  • Monitor your Geoapify usage dashboard regularly.
  • Never share your API key publicly.

๐Ÿงฎ Under the Hood (calculation engine)

Road distance (km)   = Geoapify driving route      (fallback: Haversine straight line)
Driving fuel (L)     = distance รท efficiency (km/L)
Extra fuel (L)       = auxiliary / PTO / idling / reefer fuel
Fuel required (L)    = driving fuel + extra
Fuel cost (SAR)      = fuel required ร— price (SAR/L)
Driving time (h)     = distance รท max speed (km/h)
Rest time (h)        = TGA rules  OR  custom interval ร— rest hours
Total mission (h)    = driving + rests + daily rest + road delays
ETA                  = departure date/time + total mission time

โš–๏ธ Truck load โ†’ efficiency presets

Load status Weight Built-in efficiency
๐ŸŸข Light Truck (Dyna) 3.5 t 3.5 km/L
๐ŸŸก Medium Truck (Rigid 6x4) 15 t 2.5 km/L
๐ŸŸ  Heavy Truck (Partial Load 2-3 Axle Trailer) 28 t 1.9 km/L
๐Ÿ”ด Heavy Truck (Full Load 4-Axle Semi-Trailer) 42 t 1.6 km/L
โšซ Extra Heavy / Articulated (5-Axle Max Legal Limit) 45 t 1.4 km/L

Load presets are configurable in Settings. The Truck Load Weight selector affects fuel efficiency only.

๐Ÿ›ป Vehicle Profile vs Truck Load Weight

These are two separate concepts:

  • Truck Load Weight โ€” affects fuel efficiency (km/L) defaults.
  • Vehicle Profile (in the Confirm Vehicle Profile modal) โ€” affects Geoapify routing mode and vehicle dimensions (weight, height, width, length) sent to the routing API.

๐Ÿ›ก๏ธ Saudi TGA Compliance rules (default ON)

Rule Default Configurable
Max continuous driving per stint 4.5 h Settings
Mandatory break after each stint 45 min Settings
Daily rest when driving > threshold 11 h Settings

Breaks count uses the configured driving limit. With TGA OFF the app uses your custom Rest interval (km) and Rest hours per interval.


๐Ÿงฉ Inputs & Parameters

Parameter Unit Notes
Start point / destination stops / return point lat, lon Click map or paste coordinates
Truck load weight โ€” Configurable presets in Settings; first preset is default
Available fuel in tank L Default set in Settings
Extra fuel (auxiliary / PTO / idling / reefer) L Default set in Settings
Fuel efficiency km/L Auto-filled from load preset; overridable
Fuel price SAR/L Default set in Settings
Max truck speed km/h Default set in Settings
Road delay hrs Default set in Settings
Rest interval km Default set in Settings
Rest hours per interval hrs Default set in Settings
Saudi TGA compliance mode on/off ON by default; thresholds configurable in Settings
Departure date & time local datetime Defaults to current date/time
Geoapify API key โ€” User-provided; stored in browser localStorage only

๐Ÿ“Š Mission Summary

Output Description
๐Ÿ“ Total Distance Route length (km)
โ›ฝ Fuel Required Liters + cost in SAR
โฑ๏ธ Travel Duration Driving + rests + delays (h/m)
๐Ÿ“… Expected Arrival Local timestamp computed from departure
โœ… / โš ๏ธ Fuel Status Sufficient (surplus L) or refuel needed (deficit L)
๐Ÿงพ Mission Summary Load label, stop count, road vs approximate route

๐Ÿ“ Project Structure

RoutePro KSA/
โ”œโ”€โ”€ index.html   # The entire app โ€” UI, map, engine, SQLite DB & exports
โ””โ”€โ”€ README.md    # This documentation

Single-file architecture โ€” HTML structure, Tailwind styling, Leaflet map and all Vanilla JS (LogisticsOpenStreetMapApp class) ship in one file with zero compile step.

Data persistence:

  • Settings & preferences: localStorage
  • Routes database: SQLite via sql.js, persisted to IndexedDB so routes survive browser restarts

๐Ÿ› ๏ธ Built With

Stack Purpose Source
๐ŸŸจ JavaScript (ES6) All application logic โ€” no frameworks Inline
๐ŸŸฆ HTML5 + Tailwind CSS Responsive UI & styling Tailwind CDN
๐Ÿƒ Leaflet 1.9 Interactive map unpkg CDN
๐Ÿ—บ๏ธ OpenStreetMap / Esri / CARTO Base-map tile styles CDN
๐Ÿ›ฃ๏ธ Geoapify Truck driving-route API api.geoapify.com
๐Ÿ—„๏ธ sql.js 1.10.3 SQLite database in browser cdnjs
๐Ÿ…ฐ๏ธ Font Awesome 6.4 + Inter Icons & typography CDN

โœ… Notes & Limitations

  • Modern browser recommended (Chrome, Edge, Firefox, Safari).
  • KML export prefers the File System Access API (Chrome/Edge) with an automatic download fallback elsewhere.
  • Preferences and app settings persist in localStorage.
  • Routes persist in IndexedDB via sql.js. Clearing browser site data will delete saved routes.
  • The public Geoapify routing service is rate-limited โ€” when unavailable, the app falls back to approximate straight-line distances (labelled Approximate).
  • TGA logic follows common KSA driving-hours rules, with all thresholds adjustable in Settings โ€” always verify against official Transport General Authority (TGA) guidance.
  • Load weight presets and default parameters are fully configurable in Settings.
  • Internet is required for map tiles and live routing. Saved routes and settings are stored locally in the browser and persist across sessions, but full functionality requires connectivity.

๐Ÿ™Œ Credits

  • Map tiles ยฉ OpenStreetMap contributors, Esri, CARTO
  • Routing powered by Geoapify
  • Icons by Font Awesome ยท Mapping library by Leaflet

ยฉ 2026 Bernando Jr Minguita. All rights reserved.

About

RoutePro KSA is a zero-build, single-file web app for calculating heavy-truck routes, fuel consumption, TGA compliance, and journey timelines in Saudi Arabia.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages