Route length calculation slightly off?

97 views
Skip to first unread message

stecker...@gmail.com

unread,
Jul 9, 2017, 9:52:27 AM7/9/17
to OSM Android bikerouting
Hi there,

I've been playing around with brouter for the last few days and I like it a lot, but there is one little thing I find a bit weird: The total distance shown at the bottom (on brouter.damsy.net) seems to be slightly (1-2%) longer than the range of x-values in the elevation profile.

Here is an example where the total distance is shown as 8.1km while the elevation profile only goes up to 7.970km:
https://brouter.damsy.net/#map=15/49.4539/8.6456/OpenStreetMap&lonlats=8.664528,49.41907|8.664259,49.420871|8.668106,49.421373|8.658471,49.435036|8.63976,49.44497|8.623753,49.448458|8.62062,49.449714|8.615255,49.455293|8.626472,49.456793

It seems to me that when you download the track as a GPX file and calculate the distance of it, you get the shorter one, while when you download the CSV file and add all distances there you get the longer one.

So where do the distances of the road sections shown in the CSV file come from? Aren't they ultimately calculated from the shape of the road section, i.e. the same information which is contained in the GPX file?

Norbert Renner

unread,
Jul 10, 2017, 3:48:10 PM7/10/17
to osm-android...@googlegroups.com

The elevation profile is an external plugin and does its own calculation
using a function provided by the Leaflet map library [1], that
implements the Haversine formula [2].

The rest should be consistent and is provided by the BRouter server,
which is using its own implementation [3].

The GPX download contains a comment line with the statistics:

<!-- track-length = 8080 filtered ascend = 9 plain-ascend = -8 cost=9328 -->

Summarizing the CSV Distance column also gives me 8080.

So I guess it depends on how you calculate the distance for the GPX.

Norbert


[1]
https://github.com/Leaflet/Leaflet/blob/703ae02aa8cbd0b87be5b01e77754b83ad732267/src/geo/crs/CRS.Earth.js#L17-L31
[2] https://en.wikipedia.org/wiki/Haversine_formula
[3]
https://github.com/abrensch/brouter/blob/56bdf76806c64a41b08e2bc028b0ae0a61aae7f9/brouter-core/src/main/java/btools/router/OsmPathElement.java#L52-L63

joyet...@gmail.com

unread,
Aug 9, 2020, 4:44:59 PM8/9/20
to OSM Android bikerouting
It also seems to me that brouter overestimates track length. For some some track I rode (198 km according to my bike computer), I drew the track on brouter, which showed a track length of 200.7 km. I exported the gpx file and imported it into garmin connect, which showed 198 km. With R (library raster, function pointDistance) I also get 198 km.

Poutnik Fornntp

unread,
Aug 9, 2020, 5:02:00 PM8/9/20
to joyet...@gmail.com, OSM Android bikerouting
There are other factors as well, like
- accuracy of the cyclocomputer
- difference of track lengths of
   - OSM road nominal
   - real road nominal
   - track followed by a bike.

Dne 9. srpna 2020 22:45:01 joyet...@gmail.com napsal:

--
You received this message because you are subscribed to the Google Groups "OSM Android bikerouting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osm-android-biker...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osm-android-bikerouting/ddf9ec7d-4029-4753-b84c-a4122cf68292o%40googlegroups.com.

Poutnik Fornntp

unread,
Aug 10, 2020, 4:05:08 AM8/10/20
to joyet...@gmail.com, OSM Android bikerouting
E.g. like real versus supposed effective wheel radius, affected by the brand of tyres, the rubber weary state and inflate pressure.

Dne 9. srpna 2020 23:01:58 Poutnik Fornntp <poutni...@gmail.com> napsal:

joyet...@gmail.com

unread,
Aug 10, 2020, 3:51:23 PM8/10/20
to OSM Android bikerouting
I agree with you that a 1% difference with a bike computer is below accuracy.
The more important part in my message was that, when I take the gpx file produced by brouter and measure the track length (either by importing it in Garmin Connect or using an R library), I get 198 km, whereas brouter gives 200.7 km. That doesn't involve my bike computer, just one and the same gpx file.

Norbert Renner

unread,
Aug 14, 2020, 3:32:14 PM8/14/20
to OSM Android bikerouting

Pierre Joyet

unread,
Aug 17, 2020, 5:36:55 PM8/17/20
to OSM Android bikerouting
Interesting, thank you. I implemented the formula in R and got a length of 198.0 km for my track (198.2 if I calculate K1 and K2 with the average latitude of the track), very similar to Garmin Connect. I still don't understand why brouter gives larger values.
Reply all
Reply to author
Forward
0 new messages