aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-01-24 17:45:35 -0800
committerAnton Tananaev <anton@traccar.org>2023-01-24 17:45:35 -0800
commite5a52e47b5fcae268ee89748ffe9bc05ab726c31 (patch)
treedbda8bab7b19d3ed6bb399b9fb185d7ffa3cee5c
parent1c91d35263f1d00c00db44f7b2ff373aacb28478 (diff)
downloadtrackermap-server-e5a52e47b5fcae268ee89748ffe9bc05ab726c31.tar.gz
trackermap-server-e5a52e47b5fcae268ee89748ffe9bc05ab726c31.tar.bz2
trackermap-server-e5a52e47b5fcae268ee89748ffe9bc05ab726c31.zip
Computed attributes for properties
-rw-r--r--src/main/java/org/traccar/handler/ComputedAttributesHandler.java46
1 files changed, 37 insertions, 9 deletions
diff --git a/src/main/java/org/traccar/handler/ComputedAttributesHandler.java b/src/main/java/org/traccar/handler/ComputedAttributesHandler.java
index c9f1f63d7..620852502 100644
--- a/src/main/java/org/traccar/handler/ComputedAttributesHandler.java
+++ b/src/main/java/org/traccar/handler/ComputedAttributesHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 - 2022 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2023 Anton Tananaev (anton@traccar.org)
* Copyright 2017 Andrey Kunitsyn (andrey@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -116,17 +116,45 @@ public class ComputedAttributesHandler extends BaseDataHandler {
}
if (result != null) {
try {
- switch (attribute.getType()) {
- case "number":
- Number numberValue = (Number) result;
- position.getAttributes().put(attribute.getAttribute(), numberValue);
+ switch (attribute.getAttribute()) {
+ case "valid":
+ position.setValid((Boolean) result);
break;
- case "boolean":
- Boolean booleanValue = (Boolean) result;
- position.getAttributes().put(attribute.getAttribute(), booleanValue);
+ case "latitude":
+ position.setLatitude(((Number) result).doubleValue());
+ break;
+ case "longitude":
+ position.setLongitude(((Number) result).doubleValue());
+ break;
+ case "altitude":
+ position.setAltitude(((Number) result).doubleValue());
+ break;
+ case "speed":
+ position.setSpeed(((Number) result).doubleValue());
+ break;
+ case "course":
+ position.setCourse(((Number) result).doubleValue());
+ break;
+ case "address":
+ position.setAddress((String) result);
+ break;
+ case "accuracy":
+ position.setAccuracy(((Number) result).doubleValue());
break;
default:
- position.getAttributes().put(attribute.getAttribute(), result.toString());
+ switch (attribute.getType()) {
+ case "number":
+ Number numberValue = (Number) result;
+ position.getAttributes().put(attribute.getAttribute(), numberValue);
+ break;
+ case "boolean":
+ Boolean booleanValue = (Boolean) result;
+ position.getAttributes().put(attribute.getAttribute(), booleanValue);
+ break;
+ default:
+ position.getAttributes().put(attribute.getAttribute(), result.toString());
+ }
+ break;
}
} catch (ClassCastException error) {
LOGGER.warn("Attribute cast error", error);