aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/traccar/MainModule.java2
-rw-r--r--src/main/java/org/traccar/geocoder/OpenCageGeocoder.java9
-rw-r--r--src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java2
-rw-r--r--src/main/java/org/traccar/protocol/WatchProtocolDecoder.java11
-rw-r--r--src/main/java/org/traccar/protocol/WialonProtocolDecoder.java14
-rw-r--r--src/test/java/org/traccar/geocoder/GeocoderTest.java2
-rw-r--r--src/test/java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java3
-rw-r--r--src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java3
-rw-r--r--src/test/java/org/traccar/protocol/WialonProtocolDecoderTest.java3
9 files changed, 35 insertions, 14 deletions
diff --git a/src/main/java/org/traccar/MainModule.java b/src/main/java/org/traccar/MainModule.java
index d72e04588..842f7e3ce 100644
--- a/src/main/java/org/traccar/MainModule.java
+++ b/src/main/java/org/traccar/MainModule.java
@@ -181,7 +181,7 @@ public class MainModule extends AbstractModule {
case "mapquest":
return new MapQuestGeocoder(url, key, cacheSize, addressFormat);
case "opencage":
- return new OpenCageGeocoder(url, key, cacheSize, addressFormat);
+ return new OpenCageGeocoder(url, key, language, cacheSize, addressFormat);
case "bingmaps":
return new BingMapsGeocoder(url, key, cacheSize, addressFormat);
case "factual":
diff --git a/src/main/java/org/traccar/geocoder/OpenCageGeocoder.java b/src/main/java/org/traccar/geocoder/OpenCageGeocoder.java
index 56161e52c..bbcc00cd0 100644
--- a/src/main/java/org/traccar/geocoder/OpenCageGeocoder.java
+++ b/src/main/java/org/traccar/geocoder/OpenCageGeocoder.java
@@ -21,16 +21,19 @@ import javax.json.JsonObject;
public class OpenCageGeocoder extends JsonGeocoder {
- private static String formatUrl(String url, String key) {
+ private static String formatUrl(String url, String key, String language) {
if (url == null) {
url = "https://api.opencagedata.com/geocode/v1";
}
url += "/json?q=%f,%f&no_annotations=1&key=" + key;
+ if (language != null) {
+ url += "&language=" + language;
+ }
return url;
}
- public OpenCageGeocoder(String url, String key, int cacheSize, AddressFormat addressFormat) {
- super(formatUrl(url, key), cacheSize, addressFormat);
+ public OpenCageGeocoder(String url, String key, String language, int cacheSize, AddressFormat addressFormat) {
+ super(formatUrl(url, key, language), cacheSize, addressFormat);
}
@Override
diff --git a/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java
index 89ae48b3a..f83a49941 100644
--- a/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java
@@ -362,7 +362,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
if (cid != 0 && lac != 0) {
CellTower cellTower = CellTower.fromLacCid(lac, cid);
long operator = position.getInteger(Position.KEY_OPERATOR);
- if (operator != 0) {
+ if (operator >= 1000) {
cellTower.setOperator(operator);
}
position.setNetwork(new Network(cellTower));
diff --git a/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java b/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java
index cf58b0fed..4ab7875b7 100644
--- a/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/WatchProtocolDecoder.java
@@ -149,9 +149,14 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
int mnc = !values[index].isEmpty() ? Integer.parseInt(values[index++]) : 0;
for (int i = 0; i < cellCount; i++) {
- network.addCellTower(CellTower.from(mcc, mnc,
- Integer.parseInt(values[index++]), Integer.parseInt(values[index++]),
- Integer.parseInt(values[index++])));
+ int lac = Integer.parseInt(values[index++]);
+ int cid = Integer.parseInt(values[index++]);
+ String rssi = values[index++];
+ if (!rssi.isEmpty()) {
+ network.addCellTower(CellTower.from(mcc, mnc, lac, cid, Integer.parseInt(rssi)));
+ } else {
+ network.addCellTower(CellTower.from(mcc, mnc, lac, cid));
+ }
}
if (index < values.length && !values[index].isEmpty()) {
diff --git a/src/main/java/org/traccar/protocol/WialonProtocolDecoder.java b/src/main/java/org/traccar/protocol/WialonProtocolDecoder.java
index 80299ff08..19d9dd6c8 100644
--- a/src/main/java/org/traccar/protocol/WialonProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/WialonProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2021 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2022 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,13 +47,13 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder {
.compile();
private static final Pattern PATTERN = new PatternBuilder()
- .number("(dd)(dd)(dd);") // date (ddmmyy)
- .number("(dd)(dd)(dd);") // time (hhmmss)
+ .number("(?:NA|(dd)(dd)(dd));") // date (ddmmyy)
+ .number("(?:NA|(dd)(dd)(dd));") // time (hhmmss)
.number("(?:NA|(dd)(dd.d+));") // latitude
.expression("(?:NA|([NS]));")
.number("(?:NA|(ddd)(dd.d+));") // longitude
.expression("(?:NA|([EW]));")
- .number("(d+.?d*)?;") // speed
+ .number("(?:NA|(d+.?d*))?;") // speed
.number("(?:NA|(d+.?d*))?;") // course
.number("(?:NA|(-?d+.?d*));") // altitude
.number("(?:NA|(d+))") // satellites
@@ -95,7 +95,11 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
- position.setTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS));
+ if (parser.hasNext(6)) {
+ position.setTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS));
+ } else {
+ position.setTime(new Date());
+ }
if (parser.hasNext(9)) {
position.setLatitude(parser.nextCoordinate());
diff --git a/src/test/java/org/traccar/geocoder/GeocoderTest.java b/src/test/java/org/traccar/geocoder/GeocoderTest.java
index 9134194f2..91431fd6a 100644
--- a/src/test/java/org/traccar/geocoder/GeocoderTest.java
+++ b/src/test/java/org/traccar/geocoder/GeocoderTest.java
@@ -41,7 +41,7 @@ public class GeocoderTest {
@Test
public void testOpenCage() {
Geocoder geocoder = new OpenCageGeocoder(
- "http://api.opencagedata.com/geocode/v1", "SECRET", 0, new AddressFormat());
+ "http://api.opencagedata.com/geocode/v1", "SECRET", null, 0, new AddressFormat());
String address = geocoder.getAddress(34.116302, -118.051519, null);
assertEquals("Charleston Road, California, US", address);
}
diff --git a/src/test/java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java
index 082d410c2..c3c32369c 100644
--- a/src/test/java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java
@@ -15,6 +15,9 @@ public class TeltonikaProtocolDecoderTest extends ProtocolTest {
"000F313233343536373839303132333435"));
verifyPositions(decoder, binary(
+ "00000000000000da08030000017fcedf499600280431be0eded45d0038012d100000fa100901000200b300b4004501500415034702fa00054232a1180000cd3b2fce281d43001f02c700000006f10000a029000000017fcedea99600280432070eded3dd00380046130009000f0801010200b300b400450150051502470205423276180009cd3b2fce281d43001f02c700000027f10000a0290000000179d50853180027f65d3f0ed67212001500f1110061000f0801010200b300b4004501500515034702054234f4180061cd53d1ce28c043003e02c700000147f1000000290003000052cb"));
+
+ verifyPositions(decoder, binary(
"00000000000000b98e0200000179555c7bf8010b3a1cfbebc142b00000000000000000ec000f000900f00000150000c80000450200710100740001070100fa0000ec01000500b500000018000000430d560044000000190000000100f1000000000000000000000179555c83c8010b3a1cfbebc142b0000000000000000185000f000900f00000150000c80000450200710100740001070100fa00018511000500b500000018000000430d560044000000190000000100f100000000000000000200003251"));
verifyPositions(decoder, binary(
diff --git a/src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java
index 98e83f491..4fab19f26 100644
--- a/src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java
@@ -20,6 +20,9 @@ public class WatchProtocolDecoderTest extends ProtocolTest {
Position.PREFIX_TEMP + 1, 35.29);
verifyPosition(decoder, buffer(
+ "[SG*9159059735*0066*UD2,230322,082138,A,59.55285,N,016.66185,E,0.0,000,26,14,80,70,0,50,00000000,1,1,240,7,34505,80806406,,00]"));
+
+ verifyPosition(decoder, buffer(
"[SG*9059056143*0053*UD,251021,223408,A,41.46500,N,081.53128,W,0.926,000,0,00,70,70,0,50,00000000,0,1,,,,00]"));
verifyPosition(decoder, buffer(
diff --git a/src/test/java/org/traccar/protocol/WialonProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/WialonProtocolDecoderTest.java
index 7387f5325..12724c32f 100644
--- a/src/test/java/org/traccar/protocol/WialonProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/WialonProtocolDecoderTest.java
@@ -14,6 +14,9 @@ public class WialonProtocolDecoderTest extends ProtocolTest {
"#L#2.0;42001300083;;CE45"));
verifyAttributes(decoder, text(
+ "#D#NA;NA;5429.681944502211763;N;02654.60403650999069;E;NA;NA;NA;NA;NA;NA;NA;1.0;NA;m1:1:9196679,d1:1:15397,t1:1:20,b1:1:162,fuel1:2:21588.0,pv1:2:35.98,finish:1:1;0x9b0"));
+
+ verifyAttributes(decoder, text(
"#D#120319;112003;NA;NA;NA;NA;0.000;NA;NA;0;NA;NA;NA;NA;NA;101_521347:1:521246,101_158:1:510,101_521055:1:510,101_521055_2.9:1:509,101_521056:1:3;626B"));
verifyNull(decoder, text(