diff options
author | Abyss777 <abyss@fox5.ru> | 2016-07-25 08:59:36 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2016-07-25 08:59:36 +0500 |
commit | f6333c73fe8bdd0027bb16a715193e1587b934a2 (patch) | |
tree | 340e9f66b9c3891665a0284e4a3ca8c813d87827 /src/org/traccar/database/DeviceManager.java | |
parent | 866c3073ef48a24d86834a391a4d3d91209a6eed (diff) | |
download | trackermap-server-f6333c73fe8bdd0027bb16a715193e1587b934a2.tar.gz trackermap-server-f6333c73fe8bdd0027bb16a715193e1587b934a2.tar.bz2 trackermap-server-f6333c73fe8bdd0027bb16a715193e1587b934a2.zip |
- Move lastPosition update to the end of pipeline
- Optimize MotionEventHandler to do not use Device.motion
- Remove Device.motion from model and database
- some optimizations
Diffstat (limited to 'src/org/traccar/database/DeviceManager.java')
-rw-r--r-- | src/org/traccar/database/DeviceManager.java | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/org/traccar/database/DeviceManager.java b/src/org/traccar/database/DeviceManager.java index 4dd7b41cb..5a0c87985 100644 --- a/src/org/traccar/database/DeviceManager.java +++ b/src/org/traccar/database/DeviceManager.java @@ -105,7 +105,6 @@ public class DeviceManager implements IdentityManager { } } device.setStatus(Device.STATUS_OFFLINE); - device.setMotion(Device.STATUS_STOPPED); } } for (Long cachedDeviceId : devicesById.keySet()) { @@ -176,7 +175,6 @@ public class DeviceManager implements IdentityManager { if (devicesById.containsKey(device.getId())) { Device cachedDevice = devicesById.get(device.getId()); cachedDevice.setStatus(device.getStatus()); - cachedDevice.setMotion(device.getMotion()); } } @@ -191,10 +189,14 @@ public class DeviceManager implements IdentityManager { positions.remove(deviceId); } + public boolean isLatestPosition(Position position) { + Position lastPosition = getLastPosition(position.getDeviceId()); + return lastPosition == null || position.getFixTime().compareTo(lastPosition.getFixTime()) > 0; + } + public void updateLatestPosition(Position position) throws SQLException { - Position lastPosition = getLastPosition(position.getDeviceId()); - if (lastPosition == null || position.getFixTime().compareTo(lastPosition.getFixTime()) > 0) { + if (isLatestPosition(position)) { dataManager.updateLatestPosition(position); |