Yes, latest position always points to the latest GPS location by timestamp.
But my custom query still seems to be not executed:
<entry key='database.updateLatestPosition'>
UPDATE devices SET positionId = :id WHERE id = :deviceId;
UPDATE containers SET positionId = :id WHERE deviceId = :deviceId;
</entry>
The containers.positionId remains NULL and not set to the id of that latest position.
It's never called because you "last" position is far in the future. I though we already established that.
I deleted the positions that are far in the future while the device is still sending new positions.
The new positions sent have their devicetimes correct now. It only sends bad position times seconds after it is turned on.
So the database will be left with latest positions that are valid. But the positionId is still not updated.
Which "positionId" is not updated? It works for me, so you must be missing something.
I have a device with:
id=25
uniqueid=4209934773
positionid=12928
I turn it on and select latest position of that deviceSELECT * FROM positions WHERE deviceid=25 ORDER BY fixtime DESC LIMIT 10
The latest id is on 1500+. Shouldnt the position id be equal to the latest?
I have deleted the positions with invalid dates and the device has already sent new positions with correct dates.
Have you restarted the service after deleting invalid data? Also, have you set invalid "positionid" to "null"?
Hi folks/Alton,
i am new to Traccar and trying to insert position table data into another custom table(gs_user_events_data).but it couldn't happened although when i ran this query in sql console it worked fine..
kindly put some light on it and provide your beneficial reviews.
position table - tc_positions.
custom table - gs_user_events_data.
<entry key='database.gs_user_events_data'>
INSERT into gs_user_events_data(protocol , deviceid, dt_server, dt_tracker,altitude,lat, lng, attributes,speed)
SELECT protocol,deviceid, servertime, devicetime, altitude, latitude, longitude, attributes, speed from tc_positions;
</entry>
...
2019-04-03 18:12:02 INFO: [cd7ff5a4: 5023 > 106.193.238.240] HEX: 78780513154272470d0a
2019-04-03 18:12:02 WARN: Failed to store position - Data truncation: Incorrect datetime value: '1970-01-01 05:30:00' for column 'fixtime' at row 1 - MysqlDataTruncation (... < QueryBuilder:480 < DataManager:470 < DefaultDataHandler:40 < ...)
2019-04-03 18:12:02 WARN: [cd7ff5a4] error - class org.traccar.model.Position cannot be cast to class org.traccar.model.gs_event_data (org.traccar.model.Position and org.traccar.model.gs_event_data are in unnamed module of loader 'app') - ClassCastException (MainEventHandler:61 < ... < BaseDataHandler:29 < ... < *:29 < ... < *:29 < ... < *:29 < ... < *:29 < ... < *:29 < ... < *:29 < ... < *:29 < ... < *:29 < ... < *:29 < ... < *:29 < ... < *:29 < ... < *:29 < ... < GeocoderHandler:87 < ...)
2019-04-03 18:12:02 INFO: [cd7ff5a4] disconnected
2019-04-03 18:12:02 WARN: Geocoding failed - Empty address. Error: null - GeocoderException (JsonGeocoder:69 < *:31 < *:97 < *:94 < ...)
2019-04-03 18:12:02 WARN: Geocoding failed - Empty address. Error: null - GeocoderException (JsonGeocoder:69 < *:31 < *:97 < *:94 < ...)
2019-04-03 18:12:08 INFO: [1a0c4bfc] connected
2019-04-03 18:12:08 INFO: [1a0c4bfc: 5023 < 106.193.151.129] HEX: 78780d010358899059206311154304b40d0a
2019-04-03 18:12:08 INFO: [1a0c4bfc: 5023 > 106.193.151.129] HEX: 78780501154353e30d0a
2019-04-03 18:12:08 INFO: [1a0c4bfc: 5023 < 106.193.151.129] HEX: 78781f12130403120c01cb01fc705a07ed42481dd46b01945a0d1d0041311541792c0d0a
2019-04-03 18:12:08 INFO: [1a0c4bfc: 5023 > 106.193.151.129] HEX: 7878051215411a000d0a
2019-04-03 18:12:09 INFO: [1a0c4bfc: 5023 < 106.193.151.129] HEX: 78780a134606040002154474ef0d0a
2019-04-03 18:12:09 INFO: [1a0c4bfc: 5023 > 106.193.151.129] HEX: 78780513154417710d0a
2019-04-03 18:12:09 WARN: Failed to store position - Data truncation: Incorrect datetime value: '1970-01-01 05:30:00' for column 'fixtime' at row 1 - MysqlDataTruncation (... < QueryBuilder:480 < DataManager:470 < DefaultDataHandler:40 < ...)
2019-04-03 18:12:09 WARN: [1a0c4bfc] error - class org.traccar.model.Position cannot be cast to class org.traccar.model.gs_event_data (org.traccar.model.Position and org.traccar.model.gs_event_data are in unnamed module of loader 'app') - ClassCastException (MainEventHandler:61 < ... < BaseDataHandler:29 < ... < *:29 < ... < *:29 < ... < *:29 < ... < *:29 < ... < *:29 < ... < *:29 < ... < *:29 < ... < *:29 < ... < *:29 < ... < *:29 < ... < *:29 < ... < *:29 < ... < GeocoderHandler:87 < ...)
2019-04-03 18:12:09 INFO: [1a0c4bfc] disconnected
2019-04-03 18:12:09 WARN: Geocoding failed - Empty address. Error: null - GeocoderException (JsonGeocoder:69 < *:31 < *:97 < *:94 < ...)
So the behavior is that traccar will choose the latest device time (not servertime) and set it as devices.positionId?