aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authoramilasilva88 <amilasilva88@gmail.com>2015-08-15 09:29:14 +0800
committeramilasilva88 <amilasilva88@gmail.com>2015-08-15 09:29:14 +0800
commit21ed9dbbd8c7be191894b11e895c1c0094b4aac6 (patch)
tree05874665ea4642ad7e47fdeb896c39a00413bc3c /src/org/traccar
parentf2c6f5aa0248c5b40e5aebd57e905fc2769937e9 (diff)
downloadtrackermap-server-21ed9dbbd8c7be191894b11e895c1c0094b4aac6.tar.gz
trackermap-server-21ed9dbbd8c7be191894b11e895c1c0094b4aac6.tar.bz2
trackermap-server-21ed9dbbd8c7be191894b11e895c1c0094b4aac6.zip
Set Odometer only if there is a movement
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/OdometerHandler.java16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/org/traccar/OdometerHandler.java b/src/org/traccar/OdometerHandler.java
index 5a813fc3a..d5860c02e 100644
--- a/src/org/traccar/OdometerHandler.java
+++ b/src/org/traccar/OdometerHandler.java
@@ -31,11 +31,17 @@ public class OdometerHandler extends BaseDataHandler {
private Position calculateDistance(Position position) {
Position last = getLastPosition(position.getDeviceId());
if (last != null) {
- double distance = DistanceCalculator.distance(
- position.getLatitude(), position.getLongitude(),
- last.getLatitude(), last.getLongitude());
- distance = Math.round((distance) * 100.0) / 100.0;
- double odometer = distance + last.getOdometer();
+ // set odometer only on movement
+ double odometer = 0.0;
+ if (last.getSpeed() == 0 && position.getSpeed() == 0) {
+ odometer = last.getOdometer();
+ } else {
+ double distance = DistanceCalculator.distance(
+ position.getLatitude(), position.getLongitude(),
+ last.getLatitude(), last.getLongitude());
+ distance = Math.round((distance) * 100.0) / 100.0;
+ odometer = distance + last.getOdometer();
+ }
position.setOdometer(odometer);
}
return position;