diff options
author | Abyss777 <abyss@fox5.ru> | 2016-09-20 17:14:13 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2016-09-20 17:14:13 +0500 |
commit | e0a4ed2a60fd1a38a904fa7156afba6c0aee1cdb (patch) | |
tree | bf278adae8bcf10f5b7b19a6e60c1984f0c870c0 /src/org/traccar/reports/Summary.java | |
parent | 411edf2fecc6f5d2cceba20f06958f729ebcca54 (diff) | |
download | trackermap-server-e0a4ed2a60fd1a38a904fa7156afba6c0aee1cdb.tar.gz trackermap-server-e0a4ed2a60fd1a38a904fa7156afba6c0aee1cdb.tar.bz2 trackermap-server-e0a4ed2a60fd1a38a904fa7156afba6c0aee1cdb.zip |
Add parameter "report.ignoreOdometer"
Diffstat (limited to 'src/org/traccar/reports/Summary.java')
-rw-r--r-- | src/org/traccar/reports/Summary.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/org/traccar/reports/Summary.java b/src/org/traccar/reports/Summary.java index 44fb1dd4c..79e1a7c05 100644 --- a/src/org/traccar/reports/Summary.java +++ b/src/org/traccar/reports/Summary.java @@ -24,6 +24,7 @@ import javax.json.Json; import javax.json.JsonArrayBuilder; import org.traccar.Context; +import org.traccar.model.Device; import org.traccar.model.Position; import org.traccar.reports.model.SummaryReport; import org.traccar.web.CsvBuilder; @@ -35,9 +36,11 @@ public final class Summary { } private static SummaryReport calculateSummaryResult(long deviceId, Date from, Date to) throws SQLException { + boolean ignoreOdometerConfig = Context.getConfig().getBoolean(ReportUtils.IGNORE_ODOMETER); SummaryReport result = new SummaryReport(); + Device device = Context.getDeviceManager().getDeviceById(deviceId); result.setDeviceId(deviceId); - result.setDeviceName(Context.getDeviceManager().getDeviceById(deviceId).getName()); + result.setDeviceName(device.getName()); Collection<Position> positions = Context.getDataManager().getPositions(deviceId, from, to); if (positions != null && !positions.isEmpty()) { Position firstPosition = null; @@ -60,7 +63,14 @@ public final class Summary { speedSum += position.getSpeed(); result.setMaxSpeed(position.getSpeed()); } - result.setDistance(ReportUtils.calculateDistance(firstPosition, previousPosition)); + boolean ignoreOdometer = false; + if (device.getAttributes().containsKey(ReportUtils.IGNORE_ODOMETER)) { + ignoreOdometer = Boolean.parseBoolean(device.getAttributes() + .get(ReportUtils.IGNORE_ODOMETER).toString()); + } else { + ignoreOdometer = ignoreOdometerConfig; + } + result.setDistance(ReportUtils.calculateDistance(firstPosition, previousPosition, !ignoreOdometer)); result.setAverageSpeed(speedSum / positions.size()); } return result; |