Freika / dawarich

Self-hosted alternative to Google Location History (Google Maps Timeline)
https://dawarich.app
GNU Affero General Public License v3.0
1.82k stars 31 forks source link

Distance calculation is sometimes wildly inaccurate #155

Open tigattack opened 1 month ago

tigattack commented 1 month ago

Describe the bug

I want to preface this by saying thank you so much for developing this! I've been searching for a selfhosted replacement for Google Timeline for a long time, and this is the first time I've used something that really feels like it has potential. I am loving Dawarich :heart:

However, sometimes the calculated distance for a given set of points seems crazy compared to what I'd expect.

An example of what I'm describing is a day when I travelled as follows:

Google Timeline summarises this with what feels like fairly good accuracy:

image

Converted: 376 km total (~364 km by car, ~8 km on foot).

However Dawarich, using the same dataset (I imported a Timeline export into Dawarich), has calculated a total distance of 105,796 km for this day:

image

By no means do I expect pinpoint accuracy (after all, this sort of thing is somewhat of a guessing game at the end of the day and can only be as good as the source data allows), nor am I expecting something as algorithmically advanced as I suspect Google Timeline is... But over 100,000 km on a day where I travelled less than 400 suggests something isn't right here.

Perhaps the fault is mine and I need to tune my thresholds in Dawarich. These are my current values, though they seem fairly reasonable to me:

image

This route/day is quite a good example, and certainly one of the more extreme ones, of where distance calculation seems to have gone severely wrong. However, there seems to be many instances of this throughout my location history in Dawarich, spanning back to 2013.

Any thoughts would be appreciated.

Version

All of them IIRC, but currently 0.9.9.

Freika commented 1 month ago

Can you check if you have any points with 0, 0 coordinates? That might be the problem

tigattack commented 1 month ago

I originally did, and that was the first thing I noticed when I started looking into this. I've since scrubbed them all (with a custom script that, slightly embarrassingly, I wrote before realising your great FAQ already described a much easier way to do it!).

I also scrubbed a few thousand more points with very wrong coordinates (for some reason my phone thought I was jumping back and forth between England and Northern Ireland for a few days in 2015, that didn't help).

I've updated stats since clearing up my points.

Just to confirm:

[4] pry(main)> points = Point.where(latitude: 0, longitude: 0)
D, [2024-08-06T21:39:11.839937 #87] DEBUG -- :   Point Load (12.2ms)  SELECT "points".* FROM "points" WHERE "points"."latitude" = $1 AND "points"."longitude" = $2 /* loading for pp */ LIMIT $3  [["latitude", "0.0"], ["longitude", "0.0"], ["LIMIT", 11]]
=> []
[5] pry(main)> points.size
D, [2024-08-06T21:39:19.897070 #87] DEBUG -- :   Point Count (2.1ms)  SELECT COUNT(*) FROM "points" WHERE "points"."latitude" = $1 AND "points"."longitude" = $2  [["latitude", "0.0"], ["longitude", "0.0"]]
=> 0

Scrubbing all the bad points helped a lot and my total distance dropped considerably, however several cases of absurd distances totals remain.

Freika commented 3 weeks ago

@tigattack Unfortunately, absurd distance jumps are the responsibility of your tracking software, whether it be Owntracks, Overland or you imported data tracked by Google.

Right now there is no detection of such points, although it might be introduced in the future.

sunstep commented 2 weeks ago

To add this thread: I've been tracking points with Own tracks (Significant mode for the past few days) and currently my stats are pretty accurate. I calculated a distance of 350 km since August 19 until today and Dawarich says 320 km, which is understandable because significant mode on own tracks definitely misses some travel points. If I put it on move mode, it would have been a higher value and probably been more accurate. The only times I have had issues with very inaccurate distances, was when my Google Timeline was imported, so my guess would be that the Google Timeline import needs to be improved because what gets imported to Dawarich from Google Timeline, doesn't always match what Google Maps says.