aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/reports/ReportUtils.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-11-06 10:36:16 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-11-06 10:36:16 +1300
commit313a51dbf23ca3ee0d5ac1d1dc37d0ff05cb2abd (patch)
tree50d3fe461d4d9d26f3e730b255001208b0b4a959 /src/org/traccar/reports/ReportUtils.java
parent395249ddf82bafec4ec1bf879a6d7282cbdc2ea9 (diff)
downloadtrackermap-server-313a51dbf23ca3ee0d5ac1d1dc37d0ff05cb2abd.tar.gz
trackermap-server-313a51dbf23ca3ee0d5ac1d1dc37d0ff05cb2abd.tar.bz2
trackermap-server-313a51dbf23ca3ee0d5ac1d1dc37d0ff05cb2abd.zip
Use distance units in Excel reports
Diffstat (limited to 'src/org/traccar/reports/ReportUtils.java')
-rw-r--r--src/org/traccar/reports/ReportUtils.java24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java
index 6cbda0ede..7fcc767e9 100644
--- a/src/org/traccar/reports/ReportUtils.java
+++ b/src/org/traccar/reports/ReportUtils.java
@@ -16,20 +16,36 @@
*/
package org.traccar.reports;
+import org.traccar.Context;
+import org.traccar.helper.Log;
+import org.traccar.model.Position;
+
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Collection;
-import org.traccar.Context;
-import org.traccar.helper.Log;
-import org.traccar.model.Position;
-
public final class ReportUtils {
private ReportUtils() {
}
+ public static String getDistanceUnit(long userId) {
+ String unit = Context.getPermissionsManager().getUser(userId).getDistanceUnit();
+ if (unit == null) {
+ unit = Context.getPermissionsManager().getServer().getDistanceUnit();
+ }
+ return unit != null ? unit : "km";
+ }
+
+ public static String getSpeedUnit(long userId) {
+ String unit = Context.getPermissionsManager().getUser(userId).getSpeedUnit();
+ if (unit == null) {
+ unit = Context.getPermissionsManager().getServer().getSpeedUnit();
+ }
+ return unit != null ? unit : "kn";
+ }
+
public static Collection<Long> getDeviceList(Collection<Long> deviceIds, Collection<Long> groupIds) {
Collection<Long> result = new ArrayList<>();
result.addAll(deviceIds);