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/Trips.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/Trips.java')
-rw-r--r-- | src/org/traccar/reports/Trips.java | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/org/traccar/reports/Trips.java b/src/org/traccar/reports/Trips.java index 2171d5f93..514c5d1c4 100644 --- a/src/org/traccar/reports/Trips.java +++ b/src/org/traccar/reports/Trips.java @@ -25,6 +25,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.TripReport; import org.traccar.web.CsvBuilder; @@ -36,6 +37,7 @@ public final class Trips { } private static TripReport calculateTrip(ArrayList<Position> positions, int startIndex, int endIndex) { + boolean ignoreOdometerConfig = Context.getConfig().getBoolean(ReportUtils.IGNORE_ODOMETER); Position startTrip = positions.get(startIndex); Position endTrip = positions.get(endIndex); @@ -53,15 +55,22 @@ public final class Trips { long tripDuration = endTrip.getFixTime().getTime() - positions.get(startIndex).getFixTime().getTime(); long deviceId = startTrip.getDeviceId(); trip.setDeviceId(deviceId); - String deviceName = Context.getDeviceManager().getDeviceById(deviceId).getName(); - trip.setDeviceName(deviceName); + Device device = Context.getDeviceManager().getDeviceById(deviceId); + trip.setDeviceName(device.getName()); trip.setStartPositionId(startTrip.getId()); trip.setStartTime(startTrip.getFixTime()); trip.setStartAddress(startTrip.getAddress()); trip.setEndPositionId(endTrip.getId()); trip.setEndTime(endTrip.getFixTime()); trip.setEndAddress(endTrip.getAddress()); - trip.setDistance(ReportUtils.calculateDistance(startTrip, endTrip)); + boolean ignoreOdometer = false; + if (device.getAttributes().containsKey(ReportUtils.IGNORE_ODOMETER)) { + ignoreOdometer = Boolean.parseBoolean(device.getAttributes() + .get(ReportUtils.IGNORE_ODOMETER).toString()); + } else { + ignoreOdometer = ignoreOdometerConfig; + } + trip.setDistance(ReportUtils.calculateDistance(startTrip, endTrip, !ignoreOdometer)); trip.setDuration(tripDuration); trip.setAverageSpeed(speedSum / (endIndex - startIndex)); trip.setMaxSpeed(speedMax); |