aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/PiligrimProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-10-19 12:04:22 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-10-19 12:04:22 +1300
commit43814126839b863ac73452d395a0ec5e0d817d46 (patch)
treecb2a0b3842734dbc421d65f3c42e872f875a3f7c /src/org/traccar/protocol/PiligrimProtocolDecoder.java
parentc46e2e86536abfe36096e4d86cd3d82f0d4e64eb (diff)
downloadtrackermap-server-43814126839b863ac73452d395a0ec5e0d817d46.tar.gz
trackermap-server-43814126839b863ac73452d395a0ec5e0d817d46.tar.bz2
trackermap-server-43814126839b863ac73452d395a0ec5e0d817d46.zip
Clean up some check style issues
Diffstat (limited to 'src/org/traccar/protocol/PiligrimProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/PiligrimProtocolDecoder.java29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/org/traccar/protocol/PiligrimProtocolDecoder.java b/src/org/traccar/protocol/PiligrimProtocolDecoder.java
index 7de056f99..1e9ab620d 100644
--- a/src/org/traccar/protocol/PiligrimProtocolDecoder.java
+++ b/src/org/traccar/protocol/PiligrimProtocolDecoder.java
@@ -34,6 +34,7 @@ import org.jboss.netty.handler.codec.http.HttpVersion;
import org.jboss.netty.handler.codec.http.QueryStringDecoder;
import org.traccar.BaseProtocolDecoder;
+import org.traccar.helper.DateBuilder;
import org.traccar.model.Event;
import org.traccar.model.Position;
@@ -102,24 +103,18 @@ public class PiligrimProtocolDecoder extends BaseProtocolDecoder {
position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
- // Time
- Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
- time.clear();
- time.set(Calendar.DAY_OF_MONTH, buf.readUnsignedByte());
- time.set(Calendar.MONTH, (buf.getByte(buf.readerIndex()) & 0x0f) - 1);
- time.set(Calendar.YEAR, 2010 + (buf.readUnsignedByte() >> 4));
- time.set(Calendar.HOUR_OF_DAY, buf.readUnsignedByte());
- time.set(Calendar.MINUTE, buf.readUnsignedByte());
- time.set(Calendar.SECOND, buf.readUnsignedByte());
- position.setTime(time.getTime());
-
- // Latitude
+ DateBuilder dateBuilder = new DateBuilder()
+ .setDay(buf.readUnsignedByte())
+ .setMonth(buf.getByte(buf.readerIndex()) & 0x0f)
+ .setYear(2010 + (buf.readUnsignedByte() >> 4))
+ .setTime(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte());
+ position.setTime(dateBuilder.getDate());
+
double latitude = buf.readUnsignedByte();
latitude += buf.readUnsignedByte() / 60.0;
latitude += buf.readUnsignedByte() / 6000.0;
latitude += buf.readUnsignedByte() / 600000.0;
- // Longitude
double longitude = buf.readUnsignedByte();
longitude += buf.readUnsignedByte() / 60.0;
longitude += buf.readUnsignedByte() / 6000.0;
@@ -127,8 +122,12 @@ public class PiligrimProtocolDecoder extends BaseProtocolDecoder {
// Hemisphere
int flags = buf.readUnsignedByte();
- if ((flags & 0x01) != 0) latitude = -latitude;
- if ((flags & 0x02) != 0) longitude = -longitude;
+ if ((flags & 0x01) != 0) {
+ latitude = -latitude;
+ }
+ if ((flags & 0x02) != 0) {
+ longitude = -longitude;
+ }
position.setLatitude(latitude);
position.setLongitude(longitude);