Suspicious Total Distance behavior

memesaregood2 months ago

Hello,

We are experiencing an issue where Total Distance is somehow spiking up and then decreasing back to some value. Is this a bug or an expected behavior? How do we proceed from here?

Screenshot at 2025-08-19 23-11-43.png

Anton Tananaev2 months ago

Is this the totalDistance attribute? It can only decrease when you update it manually.

memesaregood2 months ago

Yes, it is.

But this can't be right. I believe none of the users care enough to update this. The value just spikes up for some reason, and we can't figure out why. The math seems correct.

Anton Tananaev2 months ago

There might be another explanation - the data is uploaded in a wrong order. Then distance calculation can be messed up.

memesaregood2 months ago

Would filter.relative help in this case?

Anton Tananaev2 months ago

No, it won't.

memesaregood2 months ago

Any idea what would? There's nothing we can do against the devices or network issues.

Increasing server.buffering.threshold, so it reorders data?

Anton Tananaev2 months ago

Yes, you can try increasing buffering threshold. But the correct solution should be on the device side. Good devices offer an option to upload in correct chronological order.

memesaregooda month ago

Returning 16 days later, I have encountered this issue again. There's something wrong with the distance calculation. I've checked the data:

id       |fixtime                |devicetime             |speed             |distance          |totaldistance    |latitude          |longitude         |valid|
---------+-----------------------+-----------------------+------------------+------------------+-----------------+------------------+------------------+-----+
112293300|2025-09-03 05:18:39.000|2025-09-03 05:18:39.000|40.820015097084045|41.005100663172335|6560379.21180506 |         53.096285|103.07026333333333|true |
112293354|2025-09-03 05:18:41.000|2025-09-03 05:18:41.000| 39.06001365494537|5689.248014420947 |6571798.310220371|53.096656666666675|103.07022166666667|true |

There are no positions between these two. There is nothing abnormal in the data.
If I calculate the distance between them using the Haversine Formula you used in the DistanceCalculator, the result is 41.42 meters. How was 5 km written to the DB? Any idea?

Anton Tananaeva month ago

Where is the server time? How do you know there were no positions in between?

memesaregooda month ago

Found some other data. Seems to be network issues this time. Sorry about that.