Negative values for the "Distance" attribute

dimonchik7 years ago

Hello Anton, hello friends.
Tell me why the "Distance" attribute is negative?
Traccar v.3.14
Thank you!
Фото

Anton Tananaev7 years ago

It means that either your device reports wrong odometer, or positions are coming in wrong order.

dimonchik7 years ago

Thank you very much Anton!

Hi there.
I'm having the same problem with one off my cars.
I have two cars configurated in server, and already set server to ignore odometer from devices, but one of the cars still getting negative distances.
Theres Any kind of solution for this problem?
I'm using teltonika FM1010 devices.

Thanks

Anton Tananaev7 years ago

It can be happening if device reports locations in wrong order. There is no solution for it other than reconfigure your device to send in correct order.

kyawtun5 years ago

How about ignoring position which has fixtime before the last position fixtime? If it is viable, I can send PR for the patch with it is a user configurable option.

Anton Tananaev5 years ago

Then you can lose large portions of the data.

kyawtun5 years ago

The issue, at least on my server, could not be explained just by wrong ordering.

For example, the following trip which show -1.04 km.

mysql> select id, servertime, fixtime, SUBSTRING(attributes, LOCATE('totalDistance', attributes) + 15, 13) as odometer from tc_positions where deviceid = 642 and fixtime >= '2019-09-05 13:33:12' and fixtime <= '2019-09-05 13:45:51' order by servertime asc limit 100;
+----------+---------------------+---------------------+---------------+
| id       | servertime          | fixtime             | odometer      |
+----------+---------------------+---------------------+---------------+
| 91994244 | 2019-09-05 13:33:14 | 2019-09-05 13:33:12 | 3331006.24,"m |
| 91994260 | 2019-09-05 13:33:18 | 2019-09-05 13:33:16 | 3331020.3,"mo |
| 91994466 | 2019-09-05 13:33:25 | 2019-09-05 13:33:24 | 3331093.8,"mo |
| 91994370 | 2019-09-05 13:33:38 | 2019-09-05 13:33:36 | 3331150.84,"m |
| 91994373 | 2019-09-05 13:33:39 | 2019-09-05 13:33:38 | 3331153.1,"mo |
| 91994397 | 2019-09-05 13:33:43 | 2019-09-05 13:33:42 | 3331155.21,"m |
| 91994492 | 2019-09-05 13:33:58 | 2019-09-05 13:33:56 | 3331175.04,"m |
| 91994630 | 2019-09-05 13:34:02 | 2019-09-05 13:34:00 | 3331180.4,"mo |
| 91994522 | 2019-09-05 13:34:04 | 2019-09-05 13:34:02 | 3331176.21,"m |
| 91994589 | 2019-09-05 13:34:16 | 2019-09-05 13:34:14 | 3331111.99,"m |
| 91994631 | 2019-09-05 13:34:26 | 2019-09-05 13:34:24 | 3331097.49,"m |
| 91994637 | 2019-09-05 13:34:28 | 2019-09-05 13:34:26 | 3331102.43,"m |
| 91994710 | 2019-09-05 13:34:43 | 2019-09-05 13:34:38 | 3331188.08,"m |
| 91994744 | 2019-09-05 13:34:50 | 2019-09-05 13:34:48 | 3331276.1,"mo |
| 91994797 | 2019-09-05 13:35:00 | 2019-09-05 13:34:58 | 3331372.89,"m |
| 91994848 | 2019-09-05 13:35:10 | 2019-09-05 13:35:08 | 3331478.97,"m |
| 91994897 | 2019-09-05 13:35:18 | 2019-09-05 13:35:16 | 3331552.17,"m |
| 91994962 | 2019-09-05 13:35:29 | 2019-09-05 13:35:22 | 3331590.71,"m |
| 91995144 | 2019-09-05 13:35:40 | 2019-09-05 13:35:38 | 3331598.54,"m |
| 91995073 | 2019-09-05 13:35:50 | 2019-09-05 13:35:48 | 3331598.68,"m |
| 91995169 | 2019-09-05 13:36:08 | 2019-09-05 13:36:06 | 3331598.12,"m |
| 91995288 | 2019-09-05 13:36:30 | 2019-09-05 13:36:28 | 3331592.6,"mo |
| 91995356 | 2019-09-05 13:36:42 | 2019-09-05 13:36:40 | 3331592.79,"m |
| 91995376 | 2019-09-05 13:36:46 | 2019-09-05 13:36:44 | 3331588.83,"m |
| 91995413 | 2019-09-05 13:36:52 | 2019-09-05 13:36:50 | 3331578.67,"m |
| 91995568 | 2019-09-05 13:36:54 | 2019-09-05 13:36:52 | 3331574.26,"m |
| 91995456 | 2019-09-05 13:37:00 | 2019-09-05 13:36:58 | 3331558.47,"m |
| 91995612 | 2019-09-05 13:37:28 | 2019-09-05 13:37:26 | 3331521.2,"mo |
| 91995814 | 2019-09-05 13:37:58 | 2019-09-05 13:37:56 | 3331535.15,"m |
| 91995929 | 2019-09-05 13:38:16 | 2019-09-05 13:38:14 | 3331577.56,"m |
| 91995935 | 2019-09-05 13:38:18 | 2019-09-05 13:38:16 | 3331576.62,"m |
| 91995995 | 2019-09-05 13:38:28 | 2019-09-05 13:38:26 | 3331565.57,"m |
| 91996005 | 2019-09-05 13:38:30 | 2019-09-05 13:38:28 | 3331562.05,"m |
| 91996018 | 2019-09-05 13:38:32 | 2019-09-05 13:38:30 | 3331557.39,"m |
| 91996044 | 2019-09-05 13:38:36 | 2019-09-05 13:38:34 | 3331544.67,"m |
| 91996119 | 2019-09-05 13:38:50 | 2019-09-05 13:38:48 | 3331503.64,"m |
| 91996319 | 2019-09-05 13:39:26 | 2019-09-05 13:39:24 | 3331473.64,"m |
| 91996548 | 2019-09-05 13:39:48 | 2019-09-05 13:39:46 | 3331433.69,"m |
| 91996653 | 2019-09-05 13:40:08 | 2019-09-05 13:40:06 | 3331380.94,"m |
| 91996728 | 2019-09-05 13:40:24 | 2019-09-05 13:40:22 | 3331378.45,"m |
| 91996649 | 2019-09-05 13:40:28 | 2019-09-05 13:40:26 | 3331387.54,"m |
| 91996657 | 2019-09-05 13:40:30 | 2019-09-05 13:40:28 | 3331381.97,"m |
| 91996676 | 2019-09-05 13:40:32 | 2019-09-05 13:40:30 | 3331371.86,"m |
| 91996734 | 2019-09-05 13:40:43 | 2019-09-05 13:40:40 | 3331285.13,"m |
| 91996784 | 2019-09-05 13:40:53 | 2019-09-05 13:40:50 | 3331188.59,"m |
| 91996838 | 2019-09-05 13:41:02 | 2019-09-05 13:41:00 | 3331094.92,"m |
| 91996891 | 2019-09-05 13:41:12 | 2019-09-05 13:41:10 | 3331011.15,"m |
| 91996962 | 2019-09-05 13:41:24 | 2019-09-05 13:41:22 | 3330933.29,"m |
| 91997043 | 2019-09-05 13:41:40 | 2019-09-05 13:41:36 | 3330870.9,"mo |
| 91997151 | 2019-09-05 13:42:00 | 2019-09-05 13:41:59 | 3330818.66,"m |
| 91997317 | 2019-09-05 13:42:37 | 2019-09-05 13:42:35 | 3330770.13,"m |
| 91997325 | 2019-09-05 13:42:39 | 2019-09-05 13:42:37 | 3330760.95,"m |
| 91997403 | 2019-09-05 13:42:55 | 2019-09-05 13:42:53 | 3330620.77,"m |
| 91997510 | 2019-09-05 13:43:15 | 2019-09-05 13:43:13 | 3330504.91,"m |
| 91997692 | 2019-09-05 13:43:47 | 2019-09-05 13:43:45 | 3330385.92,"m |
| 91997783 | 2019-09-05 13:44:01 | 2019-09-05 13:43:59 | 3330263.92,"m |
| 91997849 | 2019-09-05 13:44:13 | 2019-09-05 13:44:11 | 3330126.51,"m |
| 91997911 | 2019-09-05 13:44:25 | 2019-09-05 13:44:23 | 3329995.36,"m |
| 91998023 | 2019-09-05 13:44:45 | 2019-09-05 13:44:43 | 3329984.19,"m |
| 91998160 | 2019-09-05 13:45:09 | 2019-09-05 13:45:07 | 3329993.14,"m |
| 91998171 | 2019-09-05 13:45:11 | 2019-09-05 13:45:09 | 3329992.66,"m |
| 91998192 | 2019-09-05 13:45:15 | 2019-09-05 13:45:13 | 3329987.27,"m |
| 91998207 | 2019-09-05 13:45:19 | 2019-09-05 13:45:17 | 3329981.65,"m |
| 91998215 | 2019-09-05 13:45:21 | 2019-09-05 13:45:19 | 3329977.37,"m |
| 91998253 | 2019-09-05 13:45:29 | 2019-09-05 13:45:27 | 3329958.7,"mo |
| 91998285 | 2019-09-05 13:45:33 | 2019-09-05 13:45:31 | 3329941.06,"m |
| 91998300 | 2019-09-05 13:45:35 | 2019-09-05 13:45:33 | 3329938.5,"mo |
| 91998334 | 2019-09-05 13:45:41 | 2019-09-05 13:45:39 | 3329947.44,"m |
| 91998341 | 2019-09-05 13:45:43 | 2019-09-05 13:45:41 | 3329951.47,"m |
| 91998394 | 2019-09-05 13:45:53 | 2019-09-05 13:45:51 | 3329968.55,"m |
+----------+---------------------+---------------------+---------------+
70 rows in set (0.00 sec)

How is that possible totalDistance become less then previous

| 91994630 | 2019-09-05 13:34:02 | 2019-09-05 13:34:00 | 3331180.4,"mo |
| 91994522 | 2019-09-05 13:34:04 | 2019-09-05 13:34:02 | 3331176.21,"m |
| 91994589 | 2019-09-05 13:34:16 | 2019-09-05 13:34:14 | 3331111.99,"m |

Ordering by ascending order of position id also show decrease totalDistance for some rows

mysql> select id, servertime, fixtime, SUBSTRING(attributes, LOCATE('totalDistance', attributes) + 15, 13) as odometer from tc_positions where deviceid = 642 and fixtime >= '2019-09-05 13:33:12' and fixtime <= '2019-09-05 13:45:51' order by id asc limit 100;
+----------+---------------------+---------------------+---------------+
| id       | servertime          | fixtime             | odometer      |
+----------+---------------------+---------------------+---------------+
| 91994244 | 2019-09-05 13:33:14 | 2019-09-05 13:33:12 | 3331006.24,"m |
| 91994260 | 2019-09-05 13:33:18 | 2019-09-05 13:33:16 | 3331020.3,"mo |
| 91994370 | 2019-09-05 13:33:38 | 2019-09-05 13:33:36 | 3331150.84,"m |
| 91994373 | 2019-09-05 13:33:39 | 2019-09-05 13:33:38 | 3331153.1,"mo |
| 91994397 | 2019-09-05 13:33:43 | 2019-09-05 13:33:42 | 3331155.21,"m |
| 91994466 | 2019-09-05 13:33:25 | 2019-09-05 13:33:24 | 3331093.8,"mo |
| 91994492 | 2019-09-05 13:33:58 | 2019-09-05 13:33:56 | 3331175.04,"m |
| 91994522 | 2019-09-05 13:34:04 | 2019-09-05 13:34:02 | 3331176.21,"m |
| 91994589 | 2019-09-05 13:34:16 | 2019-09-05 13:34:14 | 3331111.99,"m |
| 91994630 | 2019-09-05 13:34:02 | 2019-09-05 13:34:00 | 3331180.4,"mo |
| 91994631 | 2019-09-05 13:34:26 | 2019-09-05 13:34:24 | 3331097.49,"m |
| 91994637 | 2019-09-05 13:34:28 | 2019-09-05 13:34:26 | 3331102.43,"m |
| 91994710 | 2019-09-05 13:34:43 | 2019-09-05 13:34:38 | 3331188.08,"m |
| 91994744 | 2019-09-05 13:34:50 | 2019-09-05 13:34:48 | 3331276.1,"mo |
| 91994797 | 2019-09-05 13:35:00 | 2019-09-05 13:34:58 | 3331372.89,"m |
| 91994848 | 2019-09-05 13:35:10 | 2019-09-05 13:35:08 | 3331478.97,"m |
| 91994897 | 2019-09-05 13:35:18 | 2019-09-05 13:35:16 | 3331552.17,"m |
| 91994962 | 2019-09-05 13:35:29 | 2019-09-05 13:35:22 | 3331590.71,"m |
| 91995073 | 2019-09-05 13:35:50 | 2019-09-05 13:35:48 | 3331598.68,"m |
| 91995144 | 2019-09-05 13:35:40 | 2019-09-05 13:35:38 | 3331598.54,"m |
| 91995169 | 2019-09-05 13:36:08 | 2019-09-05 13:36:06 | 3331598.12,"m |
| 91995288 | 2019-09-05 13:36:30 | 2019-09-05 13:36:28 | 3331592.6,"mo |
| 91995356 | 2019-09-05 13:36:42 | 2019-09-05 13:36:40 | 3331592.79,"m |
| 91995376 | 2019-09-05 13:36:46 | 2019-09-05 13:36:44 | 3331588.83,"m |
| 91995413 | 2019-09-05 13:36:52 | 2019-09-05 13:36:50 | 3331578.67,"m |
| 91995456 | 2019-09-05 13:37:00 | 2019-09-05 13:36:58 | 3331558.47,"m |
| 91995568 | 2019-09-05 13:36:54 | 2019-09-05 13:36:52 | 3331574.26,"m |
| 91995612 | 2019-09-05 13:37:28 | 2019-09-05 13:37:26 | 3331521.2,"mo |
| 91995814 | 2019-09-05 13:37:58 | 2019-09-05 13:37:56 | 3331535.15,"m |
| 91995929 | 2019-09-05 13:38:16 | 2019-09-05 13:38:14 | 3331577.56,"m |
| 91995935 | 2019-09-05 13:38:18 | 2019-09-05 13:38:16 | 3331576.62,"m |
| 91995995 | 2019-09-05 13:38:28 | 2019-09-05 13:38:26 | 3331565.57,"m |
| 91996005 | 2019-09-05 13:38:30 | 2019-09-05 13:38:28 | 3331562.05,"m |
| 91996018 | 2019-09-05 13:38:32 | 2019-09-05 13:38:30 | 3331557.39,"m |
| 91996044 | 2019-09-05 13:38:36 | 2019-09-05 13:38:34 | 3331544.67,"m |
| 91996119 | 2019-09-05 13:38:50 | 2019-09-05 13:38:48 | 3331503.64,"m |
| 91996319 | 2019-09-05 13:39:26 | 2019-09-05 13:39:24 | 3331473.64,"m |
| 91996548 | 2019-09-05 13:39:48 | 2019-09-05 13:39:46 | 3331433.69,"m |
| 91996649 | 2019-09-05 13:40:28 | 2019-09-05 13:40:26 | 3331387.54,"m |
| 91996653 | 2019-09-05 13:40:08 | 2019-09-05 13:40:06 | 3331380.94,"m |
| 91996657 | 2019-09-05 13:40:30 | 2019-09-05 13:40:28 | 3331381.97,"m |
| 91996676 | 2019-09-05 13:40:32 | 2019-09-05 13:40:30 | 3331371.86,"m |
| 91996728 | 2019-09-05 13:40:24 | 2019-09-05 13:40:22 | 3331378.45,"m |
| 91996734 | 2019-09-05 13:40:43 | 2019-09-05 13:40:40 | 3331285.13,"m |
| 91996784 | 2019-09-05 13:40:53 | 2019-09-05 13:40:50 | 3331188.59,"m |
| 91996838 | 2019-09-05 13:41:02 | 2019-09-05 13:41:00 | 3331094.92,"m |
| 91996891 | 2019-09-05 13:41:12 | 2019-09-05 13:41:10 | 3331011.15,"m |
| 91996962 | 2019-09-05 13:41:24 | 2019-09-05 13:41:22 | 3330933.29,"m |
| 91997043 | 2019-09-05 13:41:40 | 2019-09-05 13:41:36 | 3330870.9,"mo |
| 91997151 | 2019-09-05 13:42:00 | 2019-09-05 13:41:59 | 3330818.66,"m |
| 91997317 | 2019-09-05 13:42:37 | 2019-09-05 13:42:35 | 3330770.13,"m |
| 91997325 | 2019-09-05 13:42:39 | 2019-09-05 13:42:37 | 3330760.95,"m |
| 91997403 | 2019-09-05 13:42:55 | 2019-09-05 13:42:53 | 3330620.77,"m |
| 91997510 | 2019-09-05 13:43:15 | 2019-09-05 13:43:13 | 3330504.91,"m |
| 91997692 | 2019-09-05 13:43:47 | 2019-09-05 13:43:45 | 3330385.92,"m |
| 91997783 | 2019-09-05 13:44:01 | 2019-09-05 13:43:59 | 3330263.92,"m |
| 91997849 | 2019-09-05 13:44:13 | 2019-09-05 13:44:11 | 3330126.51,"m |
| 91997911 | 2019-09-05 13:44:25 | 2019-09-05 13:44:23 | 3329995.36,"m |
| 91998023 | 2019-09-05 13:44:45 | 2019-09-05 13:44:43 | 3329984.19,"m |
| 91998160 | 2019-09-05 13:45:09 | 2019-09-05 13:45:07 | 3329993.14,"m |
| 91998171 | 2019-09-05 13:45:11 | 2019-09-05 13:45:09 | 3329992.66,"m |
| 91998192 | 2019-09-05 13:45:15 | 2019-09-05 13:45:13 | 3329987.27,"m |
| 91998207 | 2019-09-05 13:45:19 | 2019-09-05 13:45:17 | 3329981.65,"m |
| 91998215 | 2019-09-05 13:45:21 | 2019-09-05 13:45:19 | 3329977.37,"m |
| 91998253 | 2019-09-05 13:45:29 | 2019-09-05 13:45:27 | 3329958.7,"mo |
| 91998285 | 2019-09-05 13:45:33 | 2019-09-05 13:45:31 | 3329941.06,"m |
| 91998300 | 2019-09-05 13:45:35 | 2019-09-05 13:45:33 | 3329938.5,"mo |
| 91998334 | 2019-09-05 13:45:41 | 2019-09-05 13:45:39 | 3329947.44,"m |
| 91998341 | 2019-09-05 13:45:43 | 2019-09-05 13:45:41 | 3329951.47,"m |
| 91998394 | 2019-09-05 13:45:53 | 2019-09-05 13:45:51 | 3329968.55,"m |
+----------+---------------------+---------------------+---------------+
70 rows in set (0.00 sec)

So it looks like, fixtime will not work. Do you have any clue what might be problem? Concurrency issue in DeviceManager.getLastPosition possible?

kyawtun5 years ago

Will slow geocoding server api could cause such problem?

Anton Tananaev5 years ago

Yes.

Kyaw5 years ago

:-) which one? Concurrency issue or slow geocoding server api?