aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-08-20 14:36:49 +0500
committerAbyss777 <abyss@fox5.ru>2016-08-20 14:36:49 +0500
commit804c56a76dc8406e4ff072289a4a9f97322dfe83 (patch)
tree00500092593d3cb64d5c814fe7d6a2adf9a23d35 /src
parent1ce8c1945e36acd56b7ceb87b900a0efa14e9ecd (diff)
downloadtrackermap-server-804c56a76dc8406e4ff072289a4a9f97322dfe83.tar.gz
trackermap-server-804c56a76dc8406e4ff072289a4a9f97322dfe83.tar.bz2
trackermap-server-804c56a76dc8406e4ff072289a4a9f97322dfe83.zip
Removed rounding and BigDecimal for distance and averageSpeed
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/reports/ReportUtils.java15
-rw-r--r--src/org/traccar/reports/model/BaseReport.java5
2 files changed, 8 insertions, 12 deletions
diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java
index baa799e90..34f04ac87 100644
--- a/src/org/traccar/reports/ReportUtils.java
+++ b/src/org/traccar/reports/ReportUtils.java
@@ -44,19 +44,18 @@ public final class ReportUtils {
}
public static double calculateDistance(Position firstPosition, Position lastPosition, boolean useOdometer) {
- BigDecimal distance = new BigDecimal("0.0");
+ double distance = 0.0;
if (useOdometer && firstPosition.getAttributes().containsKey(Position.KEY_ODOMETER)
&& lastPosition.getAttributes().containsKey(Position.KEY_ODOMETER)) {
- distance = new BigDecimal(lastPosition.getAttributes().get(Position.KEY_ODOMETER).toString())
- .subtract(new BigDecimal(firstPosition.getAttributes().get(Position.KEY_ODOMETER).toString()))
- .multiply(new BigDecimal(1000));
+ distance = (((Number) lastPosition.getAttributes().get(Position.KEY_ODOMETER)).doubleValue()
+ - ((Number) firstPosition.getAttributes().get(Position.KEY_ODOMETER)).doubleValue())
+ * 1000;
} else if (firstPosition.getAttributes().containsKey(Position.KEY_TOTAL_DISTANCE)
&& lastPosition.getAttributes().containsKey(Position.KEY_TOTAL_DISTANCE)) {
- distance = new BigDecimal(lastPosition.getAttributes().get(Position.KEY_TOTAL_DISTANCE).toString())
- .subtract(new BigDecimal(firstPosition.getAttributes().get(Position.KEY_TOTAL_DISTANCE)
- .toString()));
+ distance = ((Number) lastPosition.getAttributes().get(Position.KEY_TOTAL_DISTANCE)).doubleValue()
+ - ((Number) firstPosition.getAttributes().get(Position.KEY_TOTAL_DISTANCE)).doubleValue();
}
- return distance.setScale(2, RoundingMode.HALF_EVEN).doubleValue();
+ return distance;
}
public static String calculateFuel(Position firstPosition, Position lastPosition) {
diff --git a/src/org/traccar/reports/model/BaseReport.java b/src/org/traccar/reports/model/BaseReport.java
index 8c5807c9b..246cdede0 100644
--- a/src/org/traccar/reports/model/BaseReport.java
+++ b/src/org/traccar/reports/model/BaseReport.java
@@ -16,9 +16,6 @@
*/
package org.traccar.reports.model;
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-
public class BaseReport {
private long deviceId;
@@ -54,7 +51,7 @@ public class BaseReport {
return averageSpeed;
}
public void setAverageSpeed(Double averageSpeed) {
- this.averageSpeed = new BigDecimal(averageSpeed.toString()).setScale(3, RoundingMode.HALF_EVEN).doubleValue();
+ this.averageSpeed = averageSpeed;
}
private double maxSpeed; // knots