diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-04-27 12:01:43 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-04-27 12:01:43 +1200 |
commit | d560f0cfdbbe9639e681bfeedd25d4de845d6161 (patch) | |
tree | 3845758ede6bafb9ee8d5fc2bda37de446ae9f34 /src/org/traccar/protocol/UlbotechProtocolDecoder.java | |
parent | 8e24c10cdc42fdece70d420b206bb6062edb589c (diff) | |
download | trackermap-server-d560f0cfdbbe9639e681bfeedd25d4de845d6161.tar.gz trackermap-server-d560f0cfdbbe9639e681bfeedd25d4de845d6161.tar.bz2 trackermap-server-d560f0cfdbbe9639e681bfeedd25d4de845d6161.zip |
Refactor model classes
Diffstat (limited to 'src/org/traccar/protocol/UlbotechProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/protocol/UlbotechProtocolDecoder.java | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/org/traccar/protocol/UlbotechProtocolDecoder.java b/src/org/traccar/protocol/UlbotechProtocolDecoder.java index 9ad590ad4..0872f6238 100644 --- a/src/org/traccar/protocol/UlbotechProtocolDecoder.java +++ b/src/org/traccar/protocol/UlbotechProtocolDecoder.java @@ -19,14 +19,11 @@ import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.traccar.BaseProtocolDecoder; -import org.traccar.database.DataManager; import org.traccar.helper.ChannelBufferTools; -import org.traccar.helper.Log; import org.traccar.model.ExtendedInfoFormatter; import org.traccar.model.Position; import java.util.Date; -import java.util.Properties; public class UlbotechProtocolDecoder extends BaseProtocolDecoder { @@ -72,6 +69,8 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder { long seconds = buf.readUnsignedInt() & 0x7fffffffl; seconds += 946684800l; // 2000-01-01 00:00 position.setTime(new Date(seconds * 1000)); + + boolean hasLocation = false; while (buf.readableBytes() > 3) { @@ -81,10 +80,10 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder { switch (type) { case DATA_GPS: + hasLocation = true; position.setValid(true); position.setLatitude(buf.readInt() / 1000000.0); position.setLongitude(buf.readInt() / 1000000.0); - position.setAltitude(0.0); position.setSpeed(buf.readUnsignedShort() * 0.539957); position.setCourse((double) buf.readUnsignedShort()); extendedInfo.set("hdop", buf.readUnsignedShort()); @@ -98,7 +97,7 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder { position.setExtendedInfo(extendedInfo.toString()); - if (position.getValid() != null) { + if (hasLocation) { return position; } return null; |