aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/reports/Summary.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-08-20 13:13:09 +0300
committerGitHub <noreply@github.com>2016-08-20 13:13:09 +0300
commit6c6b62351aadd68928b9bd3e39e2bf96d78695e8 (patch)
tree8d9f5617aada94e3c8784c0bee6a201fbced54b3 /src/org/traccar/reports/Summary.java
parent6b6d28695600fee509ee37a7225dd6518879ac9c (diff)
parent804c56a76dc8406e4ff072289a4a9f97322dfe83 (diff)
downloadtrackermap-server-6c6b62351aadd68928b9bd3e39e2bf96d78695e8.tar.gz
trackermap-server-6c6b62351aadd68928b9bd3e39e2bf96d78695e8.tar.bz2
trackermap-server-6c6b62351aadd68928b9bd3e39e2bf96d78695e8.zip
Merge pull request #2228 from Abyss777/reports_trips
Implement trips reports
Diffstat (limited to 'src/org/traccar/reports/Summary.java')
-rw-r--r--src/org/traccar/reports/Summary.java20
1 files changed, 2 insertions, 18 deletions
diff --git a/src/org/traccar/reports/Summary.java b/src/org/traccar/reports/Summary.java
index 402e6d432..44fb1dd4c 100644
--- a/src/org/traccar/reports/Summary.java
+++ b/src/org/traccar/reports/Summary.java
@@ -16,8 +16,6 @@
*/
package org.traccar.reports;
-import java.math.BigDecimal;
-import java.math.RoundingMode;
import java.sql.SQLException;
import java.util.Collection;
import java.util.Date;
@@ -62,22 +60,8 @@ public final class Summary {
speedSum += position.getSpeed();
result.setMaxSpeed(position.getSpeed());
}
- if (firstPosition.getAttributes().containsKey(Position.KEY_ODOMETER)
- && previousPosition.getAttributes().containsKey(Position.KEY_ODOMETER)) {
- result.setDistance((Integer.parseInt(previousPosition.getAttributes().get(Position.KEY_ODOMETER)
- .toString())
- - Integer.parseInt(firstPosition.getAttributes().get(Position.KEY_ODOMETER).toString()))
- * 1000);
- } else if (firstPosition.getAttributes().containsKey(Position.KEY_TOTAL_DISTANCE)
- && previousPosition.getAttributes().containsKey(Position.KEY_TOTAL_DISTANCE)) {
- result.setDistance(((Number) previousPosition.getAttributes().get(Position.KEY_TOTAL_DISTANCE))
- .doubleValue()
- - ((Number) firstPosition.getAttributes().get(Position.KEY_TOTAL_DISTANCE)).doubleValue());
- }
- result.setDistance(new BigDecimal(result.getDistance())
- .setScale(2, RoundingMode.HALF_EVEN).doubleValue());
- result.setAverageSpeed(new BigDecimal(speedSum / positions.size())
- .setScale(3, RoundingMode.HALF_EVEN).doubleValue());
+ result.setDistance(ReportUtils.calculateDistance(firstPosition, previousPosition));
+ result.setAverageSpeed(speedSum / positions.size());
}
return result;
}