From 05a73b06f94e451239ebc61ebb2b8528705bbc61 Mon Sep 17 00:00:00 2001 From: Nikolay Vlahovski Date: Thu, 18 May 2023 12:47:40 +0300 Subject: Fix Latitude/Longitude Formats for negative support Add analizeNegativePosition function in TranSyncProtocolDecoder.java Add statusParameters variable for byte --- .../java/org/traccar/protocol/TranSyncProtocolDecoder.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/main/java/org/traccar') diff --git a/src/main/java/org/traccar/protocol/TranSyncProtocolDecoder.java b/src/main/java/org/traccar/protocol/TranSyncProtocolDecoder.java index 1b7c9539c..130c916b1 100644 --- a/src/main/java/org/traccar/protocol/TranSyncProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/TranSyncProtocolDecoder.java @@ -111,6 +111,15 @@ public class TranSyncProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_EVENT, "unknown"); } } + private void analizeNegativePosition(Position position, int value) { + + if (!BitUtil.check(value, 1)) { + position.setLatitude(-position.getLatitude()); // 0/1 S/N + } + if (!BitUtil.check(value, 2)) { + position.setLongitude(-position.getLongitude()); // 0/1 W/E + } + } private void decodePowerEngineParameters(Position position, int value) { @@ -122,7 +131,6 @@ public class TranSyncProtocolDecoder extends BaseProtocolDecoder { } position.set(Position.KEY_IGNITION, BitUtil.check(value, 3)); position.set("gpsFix", BitUtil.check(value, 0)); - } private void decodeTrackerStatusParameters(Position position, int value) { @@ -169,8 +177,10 @@ public class TranSyncProtocolDecoder extends BaseProtocolDecoder { int mobileNetworkCode = buf.readUnsignedByte(); int cellTowerId = buf.readUnsignedShort(); + int statusParameters = buf.readUnsignedByte(); - decodePowerEngineParameters(position, buf.readUnsignedByte()); + decodePowerEngineParameters(position, statusParameters); + analizeNegativePosition(position, statusParameters); buf.readUnsignedByte(); // reserved -- cgit v1.2.3