diff options
author | Iván Ávalos <avalos@disroot.org> | 2024-08-03 20:52:00 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2024-08-03 20:52:00 -0600 |
commit | 55f6d92c09a5b1d8566b53633d07be3d31010d3b (patch) | |
tree | b86bed801b0bbadb72c7e839296dae1d28b12bbb /src/main/java/org/traccar/protocol/LeafSpyProtocolDecoder.java | |
parent | c04ad7d48331253c095fc123ded1b00f6ff871d3 (diff) | |
parent | 2788174193def918a3a1a5be3bbed24c9613323f (diff) | |
download | trackermap-server-55f6d92c09a5b1d8566b53633d07be3d31010d3b.tar.gz trackermap-server-55f6d92c09a5b1d8566b53633d07be3d31010d3b.tar.bz2 trackermap-server-55f6d92c09a5b1d8566b53633d07be3d31010d3b.zip |
Merge tag 'tags/v6.3'
Diffstat (limited to 'src/main/java/org/traccar/protocol/LeafSpyProtocolDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/LeafSpyProtocolDecoder.java | 52 |
1 files changed, 16 insertions, 36 deletions
diff --git a/src/main/java/org/traccar/protocol/LeafSpyProtocolDecoder.java b/src/main/java/org/traccar/protocol/LeafSpyProtocolDecoder.java index 6affb85c5..bc70e8c81 100644 --- a/src/main/java/org/traccar/protocol/LeafSpyProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/LeafSpyProtocolDecoder.java @@ -55,56 +55,36 @@ public class LeafSpyProtocolDecoder extends BaseHttpProtocolDecoder { for (Map.Entry<String, List<String>> entry : params.entrySet()) { for (String value : entry.getValue()) { switch (entry.getKey()) { - case "pass": + case "pass" -> { DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, value); if (deviceSession == null) { sendResponse(channel, HttpResponseStatus.BAD_REQUEST); return null; } position.setDeviceId(deviceSession.getDeviceId()); - break; - case "Lat": - position.setLatitude(Double.parseDouble(value)); - break; - case "Long": - position.setLongitude(Double.parseDouble(value)); - break; - case "RPM": + } + case "Lat" -> position.setLatitude(Double.parseDouble(value)); + case "Long" -> position.setLongitude(Double.parseDouble(value)); + case "RPM" -> { position.set(Position.KEY_RPM, Integer.parseInt(value)); position.setSpeed(convertSpeed(Double.parseDouble(value) / 63, "kmh")); - break; - case "Elv": - position.setAltitude(Double.parseDouble(value)); - break; - case "SOC": - position.set(Position.KEY_BATTERY_LEVEL, Double.parseDouble(value)); - break; - case "user": - position.set(Position.KEY_DRIVER_UNIQUE_ID, value); - break; - case "ChrgMode": - position.set(Position.KEY_CHARGE, Integer.parseInt(value) != 0); - break; - case "Odo": - position.set(Position.KEY_OBD_ODOMETER, Integer.parseInt(value) * 1000); - break; - default: + } + case "Elv" -> position.setAltitude(Double.parseDouble(value)); + case "SOC" -> position.set(Position.KEY_BATTERY_LEVEL, Double.parseDouble(value)); + case "user" -> position.set(Position.KEY_DRIVER_UNIQUE_ID, value); + case "ChrgMode" -> position.set(Position.KEY_CHARGE, Integer.parseInt(value) != 0); + case "Odo" -> position.set(Position.KEY_OBD_ODOMETER, Integer.parseInt(value) * 1000); + default -> { try { position.set(entry.getKey(), Double.parseDouble(value)); } catch (NumberFormatException e) { switch (value) { - case "true": - position.set(entry.getKey(), true); - break; - case "false": - position.set(entry.getKey(), false); - break; - default: - position.set(entry.getKey(), value); - break; + case "true" -> position.set(entry.getKey(), true); + case "false" -> position.set(entry.getKey(), false); + default -> position.set(entry.getKey(), value); } } - break; + } } } } |