diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-03-29 19:23:32 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-03-29 19:23:32 -0700 |
commit | 12ac2cf773b6fa621b48dc6177d8245e038a8918 (patch) | |
tree | bec56b16ac256537ae84b8bdc770ca4e99588755 | |
parent | 1f710ea91b25aec02d04b69e5b9f6dbd96230a82 (diff) | |
download | trackermap-server-12ac2cf773b6fa621b48dc6177d8245e038a8918.tar.gz trackermap-server-12ac2cf773b6fa621b48dc6177d8245e038a8918.tar.bz2 trackermap-server-12ac2cf773b6fa621b48dc6177d8245e038a8918.zip |
Support decimal heading values
-rw-r--r-- | src/org/traccar/protocol/XirgoProtocolDecoder.java | 6 | ||||
-rw-r--r-- | test/org/traccar/protocol/XirgoProtocolDecoderTest.java | 8 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/org/traccar/protocol/XirgoProtocolDecoder.java b/src/org/traccar/protocol/XirgoProtocolDecoder.java index 38c21f387..6d215e672 100644 --- a/src/org/traccar/protocol/XirgoProtocolDecoder.java +++ b/src/org/traccar/protocol/XirgoProtocolDecoder.java @@ -228,7 +228,11 @@ public class XirgoProtocolDecoder extends BaseProtocolDecoder { position.setSpeed(UnitsConverter.knotsFromKph(Double.parseDouble(values[i]))); break; case "HD": - position.setCourse(Integer.parseInt(values[i]) * 0.1); + if (values[i].contains(".")) { + position.setCourse(Double.parseDouble(values[i])); + } else { + position.setCourse(Integer.parseInt(values[i]) * 0.1); + } break; case "SV": position.set(Position.KEY_SATELLITES, Integer.parseInt(values[i])); diff --git a/test/org/traccar/protocol/XirgoProtocolDecoderTest.java b/test/org/traccar/protocol/XirgoProtocolDecoderTest.java index b2e023574..f795742fd 100644 --- a/test/org/traccar/protocol/XirgoProtocolDecoderTest.java +++ b/test/org/traccar/protocol/XirgoProtocolDecoderTest.java @@ -10,6 +10,14 @@ public class XirgoProtocolDecoderTest extends ProtocolTest { XirgoProtocolDecoder decoder = new XirgoProtocolDecoder(null); + decoder.setForm("UID,EV,D,T,LT,LN,AL,GSPT,HD,SV,HP,BV,CQ,GS,SI,IG,OT"); + + verifyPosition(decoder, text( + "$$183900034,4002,03/30/2019,02:15:22,46.848577,-114.022213,978,0.0,172.3,16,1.2,13.291,20,3,2,2,1##")); + + verifyPosition(decoder, text( + "$$184800793,4002,03/30/2019,02:10:13,46.848600,-114.022256,9723,0.0,1645,17,1.2,13.283,18,3,89011703278246523594,2,0##")); + decoder.setForm("UID,EV,D,T,LT,LN,AL,GSPT,SV,HP,BV,CQ,MI,GS,SI,IG,OT"); verifyPosition(decoder, text( |