How the trip cost is calculated

The exact method behind the trip cost calculator: what the routing and elevation services return, the formula, every constant the model uses, a worked example and the limits you should know about.

1. From place names to a route Real data

When you type a place, the site's server asks Photon, a geocoder built on OpenStreetMap data, for up to six matches and shows them as suggestions. Picking one fixes its latitude and longitude.

With both ends chosen, the server asks the OSRM routing engine for the driving route. OSRM returns the route length in metres, an estimated driving time in seconds, and the full geometry of the road as a list of coordinates (a long trip can have thousands). The calculator shows the length rounded to 0.1 km and the time rounded to the minute. OSRM picks the fastest route on OpenStreetMap roads under normal conditions; it does not know about live traffic or closures.

2. Climb and descent along the route Real data, sampled

The route geometry is thinned to 40 evenly spaced points, always keeping the start and the end. The server sends those points to Open-Elevation, which returns the ground height at each one from SRTM terrain data. Then, walking from point to point:

  • every rise is added to the elevation gain;
  • every fall is added to the elevation loss.

Summing every rise matters. A route from the coast over a 1,000 m pass and back down to the coast has a net height change of zero, but the car still has to lift itself 1,000 m on the way up. Using only start and end height would miss that completely.

Results are cached in memory for 30 minutes and calls to the free services are spaced at least 250 ms apart, so the site does not overload services that other people rely on. Nothing about your search is stored beyond that cache.

3. The cost formula Arithmetic

For a petrol or diesel car:

litres = distance_km ÷ 100 × L_per_100km + climb_litres
cost   = litres × price_per_litre + tolls

For an electric car:

kWh  = distance_km ÷ 100 × kWh_per_100km + climb_kWh − descent_credit_kWh
cost = kWh × price_per_kWh + tolls

The consumption you enter should be your car's average on similar roads. The climb term is added on top because a typical average already includes ordinary small hills but not a long mountain climb.

4. The climb allowance First-order physics estimate

Lifting a mass m by a height h takes energy E = m × g × h, with g = 9.81 m/s². The engine or motor has to supply that energy, and it loses some on the way:

ConstantValue usedWhat it stands for
Reference mass, petrol/diesel car1,500 kgA typical passenger car; the tool does not ask for your car's weight
Reference mass, electric car1,900 kgHeavier because of the battery
Engine efficiency25%Share of the fuel's energy that becomes motion
Electric drive efficiency90%Battery to wheels
Regenerative braking recovery60%Share of the descent's energy an EV puts back in the battery
Petrol energy content34.2 MJ/LUsed to turn climb energy into litres
Diesel energy content38.6 MJ/LSame, for diesel

These are round, typical values chosen for the model, not measurements of any particular car. For scale: with them, a petrol car climbing 1,000 m needs 1.72 L extra and a diesel car 1.52 L; an EV needs 5.75 kWh extra and gets back 3.11 kWh coming down the same 1,000 m.

Petrol and diesel cars get no credit for descents. Going downhill, a combustion car brakes or uses engine braking, and that energy becomes heat. It is a deliberately cautious simplification: a driver who coasts down long gentle slopes will use a little less fuel than the estimate.

5. Worked example

A 214 km mountain route that climbs 1,850 m in total and descends 1,620 m (it ends higher than it starts). Prices are example values, not a country's reference price.

  • Petrol car at 6.8 L/100 km, €1.95/L: 214 ÷ 100 × 6.8 = 14.55 L for the distance. The climb adds 1,500 kg × 9.81 × 1,850 m ÷ 25% ÷ 34.2 MJ/L = 3.18 L. Total 17.74 L, costing €34.59.
  • EV at 16.5 kWh/100 km, €0.24/kWh: 35.31 kWh for the distance. The climb adds 10.64 kWh, the descent gives back 5.03 kWh, so the net extra is 5.61 kWh. Total 40.92 kWh, costing €9.82.

6. Prices Dated official data

There is no free, reliable live feed of fuel and electricity prices for every country, so the calculator starts from dated official figures and lets you overwrite them:

  • EU petrol and diesel: the European Commission's Weekly Oil Bulletin (full table).
  • European household electricity: Eurostat's half-yearly statistics (full table).
  • UK: DESNZ weekly road fuel prices and the Ofgem price cap unit rate.
  • US: EIA weekly retail fuel prices and monthly residential electricity prices (full table).

Household electricity is a home-charging price. Public charging usually costs more per kWh; the home vs public charging page shows by how much and how to adjust. Every data refresh and correction is dated on the updates page.

7. Known limits

  • 40 elevation samples. On a 50 km route the points are about 1.3 km apart; on a 1,000 km route about 26 km apart, so small hills between samples disappear and the climb is underestimated.
  • Terrain, not road height. The elevation is the ground height at each point. Tunnels and bridges can show climbs the road does not actually make.
  • No speed, weather or load model. Fast motorway driving, cold weather, air conditioning, roof boxes and passengers all raise consumption. Enter a consumption figure that fits the trip; the conversions guide lists official figures for these effects.
  • No charging losses on top. The EV estimate prices the energy the car uses. Energy drawn from the wall is a few percent higher (see the charging page), unless the consumption you enter already includes losses, as EPA ratings do.
  • Tolls are manual. No free routing service returns toll prices, so add them yourself if your route has any.

Frequently asked questions

Why sample only 40 elevation points?

Open-Elevation is a free shared service, so each route is limited to one request of 40 points. On a long route the points are far apart, which smooths out small hills: the climb shown is usually lower than the true total.

Why do petrol and diesel cars get no credit for going downhill?

A combustion car going downhill mostly brakes or coasts; the energy turns into heat instead of going back into the tank. EVs can recover part of it through regenerative braking, so they get a 60% credit.

Is the drive time live?

No. OSRM estimates driving time from road types and speeds under normal conditions. It does not know about current traffic, roadworks or weather.

Sources

Related pages

Last reviewed: 2026-10-25. Found an error? Email contact@pumporplug.com; corrections are listed on the updates page.