aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/reports
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-11-23 17:34:25 +0500
committerAbyss777 <abyss@fox5.ru>2016-11-23 17:34:25 +0500
commite89bbb8ee9dd1dd1f19fb33f1f9291c6ae5f43db (patch)
tree51376f73260c9bbc89064ba2b5f2a428b6d46785 /src/org/traccar/reports
parentdbbe99269140f057d3f72acca557730a6b10e902 (diff)
downloadtrackermap-server-e89bbb8ee9dd1dd1f19fb33f1f9291c6ae5f43db.tar.gz
trackermap-server-e89bbb8ee9dd1dd1f19fb33f1f9291c6ae5f43db.tar.bz2
trackermap-server-e89bbb8ee9dd1dd1f19fb33f1f9291c6ae5f43db.zip
Implement attributes helpers
Diffstat (limited to 'src/org/traccar/reports')
-rw-r--r--src/org/traccar/reports/ReportUtils.java15
-rw-r--r--src/org/traccar/reports/Summary.java8
2 files changed, 9 insertions, 14 deletions
diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java
index 7fcc767e9..6c686503c 100644
--- a/src/org/traccar/reports/ReportUtils.java
+++ b/src/org/traccar/reports/ReportUtils.java
@@ -63,18 +63,17 @@ public final class ReportUtils {
double distance = 0.0;
double firstOdometer = 0.0;
double lastOdometer = 0.0;
- if (firstPosition.getAttributes().containsKey(Position.KEY_ODOMETER)) {
- firstOdometer = ((Number) firstPosition.getAttributes().get(Position.KEY_ODOMETER)).doubleValue();
- }
- if (lastPosition.getAttributes().containsKey(Position.KEY_ODOMETER)) {
- lastOdometer = ((Number) lastPosition.getAttributes().get(Position.KEY_ODOMETER)).doubleValue();
- }
+ firstOdometer = firstPosition.getDouble(Position.KEY_ODOMETER);
+
+
+ lastOdometer = lastPosition.getDouble(Position.KEY_ODOMETER);
+
if (useOdometer && (firstOdometer != 0.0 || lastOdometer != 0.0)) {
distance = lastOdometer - firstOdometer;
} else if (firstPosition.getAttributes().containsKey(Position.KEY_TOTAL_DISTANCE)
&& lastPosition.getAttributes().containsKey(Position.KEY_TOTAL_DISTANCE)) {
- distance = ((Number) lastPosition.getAttributes().get(Position.KEY_TOTAL_DISTANCE)).doubleValue()
- - ((Number) firstPosition.getAttributes().get(Position.KEY_TOTAL_DISTANCE)).doubleValue();
+ distance = lastPosition.getDouble(Position.KEY_TOTAL_DISTANCE)
+ - firstPosition.getDouble(Position.KEY_TOTAL_DISTANCE);
}
return distance;
}
diff --git a/src/org/traccar/reports/Summary.java b/src/org/traccar/reports/Summary.java
index 95a3737a1..b404b0ed5 100644
--- a/src/org/traccar/reports/Summary.java
+++ b/src/org/traccar/reports/Summary.java
@@ -49,12 +49,8 @@ public final class Summary {
if (firstPosition == null) {
firstPosition = position;
}
- if (previousPosition != null
- && position.getAttributes().get(Position.KEY_IGNITION) != null
- && Boolean.parseBoolean(position.getAttributes().get(Position.KEY_IGNITION).toString())
- && previousPosition.getAttributes().get(Position.KEY_IGNITION) != null
- && Boolean.parseBoolean(previousPosition.getAttributes()
- .get(Position.KEY_IGNITION).toString())) {
+ if (previousPosition != null && position.getBoolean(Position.KEY_IGNITION)
+ && previousPosition.getBoolean(Position.KEY_IGNITION)) {
result.addEngineHours(position.getFixTime().getTime()
- previousPosition.getFixTime().getTime());
}