diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-09-12 21:38:01 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-09-12 21:38:01 +1200 |
commit | a7d9e52831ff5f6f360a7e5a264ae7021c9882c7 (patch) | |
tree | e3d60b805e90da5fe24c695ef392ce8a74bc4209 | |
parent | 804421836ad9c4c8ab34415a3f00c3e7ad0af524 (diff) | |
download | traccar-server-a7d9e52831ff5f6f360a7e5a264ae7021c9882c7.tar.gz traccar-server-a7d9e52831ff5f6f360a7e5a264ae7021c9882c7.tar.bz2 traccar-server-a7d9e52831ff5f6f360a7e5a264ae7021c9882c7.zip |
Fix distance calculation rounding
-rw-r--r-- | src/org/traccar/DistanceHandler.java | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/org/traccar/DistanceHandler.java b/src/org/traccar/DistanceHandler.java index 57dddfe87..6232c555f 100644 --- a/src/org/traccar/DistanceHandler.java +++ b/src/org/traccar/DistanceHandler.java @@ -15,12 +15,12 @@ */ package org.traccar; +import java.math.BigDecimal; +import java.math.RoundingMode; import org.traccar.helper.DistanceCalculator; import org.traccar.model.Event; import org.traccar.model.Position; -import java.math.BigDecimal; - public class DistanceHandler extends BaseDataHandler { private Position getLastPosition(long deviceId) { @@ -44,7 +44,7 @@ public class DistanceHandler extends BaseDataHandler { position.getLatitude(), position.getLongitude(), last.getLatitude(), last.getLongitude()); - distance = BigDecimal.valueOf(distance).setScale(2).doubleValue(); + distance = BigDecimal.valueOf(distance).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); } position.set(Event.KEY_DISTANCE, distance); |