From a7d9e52831ff5f6f360a7e5a264ae7021c9882c7 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 12 Sep 2015 21:38:01 +1200 Subject: Fix distance calculation rounding --- src/org/traccar/DistanceHandler.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/org') 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); -- cgit v1.2.3