diff options
author | Nikolay Vlahovski <nvlahovski@gmail.com> | 2023-05-18 12:47:40 +0300 |
---|---|---|
committer | Nikolay Vlahovski <nvlahovski@gmail.com> | 2023-05-18 12:47:40 +0300 |
commit | 05a73b06f94e451239ebc61ebb2b8528705bbc61 (patch) | |
tree | 365b2ca300856126f9075a0379477b69b8eff1de /src/main | |
parent | adbe25e9daa125e989c853068bc600c61234c342 (diff) | |
download | trackermap-server-05a73b06f94e451239ebc61ebb2b8528705bbc61.tar.gz trackermap-server-05a73b06f94e451239ebc61ebb2b8528705bbc61.tar.bz2 trackermap-server-05a73b06f94e451239ebc61ebb2b8528705bbc61.zip |
Fix Latitude/Longitude Formats for negative support
Add analizeNegativePosition function in TranSyncProtocolDecoder.java
Add statusParameters variable for byte
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/traccar/protocol/TranSyncProtocolDecoder.java | 14 |
1 files changed, 12 insertions, 2 deletions
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 |