From 6e1b6dc596e50fe0460abbc252540674c72153b1 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 24 Oct 2016 22:27:30 +1300 Subject: Correctly decode negative coords (fix #2479) --- src/org/traccar/helper/Parser.java | 2 +- test/org/traccar/protocol/WatchProtocolDecoderTest.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/org/traccar/helper/Parser.java b/src/org/traccar/helper/Parser.java index dcea1c8f7..2f99d6e49 100644 --- a/src/org/traccar/helper/Parser.java +++ b/src/org/traccar/helper/Parser.java @@ -155,7 +155,7 @@ public class Parser { } if (hemisphere != null && (hemisphere.equals("S") || hemisphere.equals("W") || hemisphere.equals("-"))) { - coordinate = -coordinate; + coordinate = -Math.abs(coordinate); } return coordinate; diff --git a/test/org/traccar/protocol/WatchProtocolDecoderTest.java b/test/org/traccar/protocol/WatchProtocolDecoderTest.java index 6116c2c2b..25d4f7cc2 100644 --- a/test/org/traccar/protocol/WatchProtocolDecoderTest.java +++ b/test/org/traccar/protocol/WatchProtocolDecoderTest.java @@ -10,6 +10,9 @@ public class WatchProtocolDecoderTest extends ProtocolTest { WatchProtocolDecoder decoder = new WatchProtocolDecoder(new WatchProtocol()); + verifyPosition(decoder, text( + "[3G*6430073509*00E7*UD2,241016,081622,V,09.951861,N,-84.1422119,W,0.00,0.0,0.0,0,39,94,0,0,00000000,1,0,712,3,2007,18961,123,4,Luz,00:23:6a:34:ee:76,-70,familia,b0:c5:54:b9:90:ef,-78,fam salas delgado,fc:b4:e6:5d:50:ea,-81,QWERTY,c8:3a:35:43:0f:e8,-93")); + verifyPosition(decoder, text( "[3G*6105117105*008D*UD2,210716,231601,V,-33.480366,N,-70.7630692,E,0.00,0.0,0.0,0,100,34,0,0,00000000,3,255,730,2,29731,54315,167,29731,54316,162,29731,54317,145"), position("2016-07-21 23:16:01.000", false, -33.48037, -70.76307)); -- cgit v1.2.3