aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/helper
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-11-06 18:44:43 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-11-06 18:44:43 +1300
commit10bd96dac0150d9b19623cd86369f8985bda802c (patch)
tree4dcce1b0e8aee230251bf741707b87f93d7a79f0 /src/org/traccar/helper
parent73112d542cb4a2fa2ac47d85ebe071c9d3c6f894 (diff)
downloadtraccar-server-10bd96dac0150d9b19623cd86369f8985bda802c.tar.gz
traccar-server-10bd96dac0150d9b19623cd86369f8985bda802c.tar.bz2
traccar-server-10bd96dac0150d9b19623cd86369f8985bda802c.zip
Refactor TAIP protocol decoder
Diffstat (limited to 'src/org/traccar/helper')
-rw-r--r--src/org/traccar/helper/DateBuilder.java14
-rw-r--r--src/org/traccar/helper/Parser.java6
2 files changed, 18 insertions, 2 deletions
diff --git a/src/org/traccar/helper/DateBuilder.java b/src/org/traccar/helper/DateBuilder.java
index 77c6821aa..0ad7a4d7b 100644
--- a/src/org/traccar/helper/DateBuilder.java
+++ b/src/org/traccar/helper/DateBuilder.java
@@ -25,13 +25,20 @@ public class DateBuilder {
public DateBuilder() {
this(TimeZone.getTimeZone("UTC"));
+ }
+ public DateBuilder(Date time) {
+ this(time, TimeZone.getTimeZone("UTC"));
}
public DateBuilder(TimeZone timeZone) {
+ this(new Date(0), timeZone);
+ }
+
+ public DateBuilder(Date time, TimeZone timeZone) {
calendar = Calendar.getInstance(timeZone);
calendar.clear();
- calendar.setTimeInMillis(0);
+ calendar.setTimeInMillis(time.getTime());
}
public DateBuilder setYear(int year) {
@@ -90,6 +97,11 @@ public class DateBuilder {
return this;
}
+ public DateBuilder addMillis(long millis) {
+ calendar.setTimeInMillis(calendar.getTimeInMillis() + millis);
+ return this;
+ }
+
public DateBuilder setTime(int hour, int minute, int second) {
return setHour(hour).setMinute(minute).setSecond(second);
}
diff --git a/src/org/traccar/helper/Parser.java b/src/org/traccar/helper/Parser.java
index 8d6dd1a64..c5f5d2e37 100644
--- a/src/org/traccar/helper/Parser.java
+++ b/src/org/traccar/helper/Parser.java
@@ -87,6 +87,7 @@ public class Parser {
}
public enum CoordinateFormat {
+ DEG_DEG,
DEG_HEM,
DEG_MIN_HEM,
DEG_MIN_MIN_HEM,
@@ -98,9 +99,12 @@ public class Parser {
public double nextCoordinate(CoordinateFormat format) {
double coordinate;
- String hemisphere;
+ String hemisphere = null;
switch (format) {
+ case DEG_DEG:
+ coordinate = Double.parseDouble(next() + '.' + next());
+ break;
case DEG_HEM:
coordinate = nextDouble();
hemisphere = next();