aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-07-19 11:36:21 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2016-07-19 11:36:21 +1200
commit4054777eac379ce07560c44901ada659aad062ba (patch)
tree6649775fec05af73375aa1786176c91d97c9e695
parent576ce5efbf2da92b843fcb2edf9b948be41cc99a (diff)
downloadtrackermap-server-4054777eac379ce07560c44901ada659aad062ba.tar.gz
trackermap-server-4054777eac379ce07560c44901ada659aad062ba.tar.bz2
trackermap-server-4054777eac379ce07560c44901ada659aad062ba.zip
Get device id from position
-rw-r--r--src/org/traccar/BaseProtocolDecoder.java38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/org/traccar/BaseProtocolDecoder.java b/src/org/traccar/BaseProtocolDecoder.java
index 9a253e351..59205bc6f 100644
--- a/src/org/traccar/BaseProtocolDecoder.java
+++ b/src/org/traccar/BaseProtocolDecoder.java
@@ -78,25 +78,27 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder {
}
public void getLastLocation(Position position, Date deviceTime) {
- position.setOutdated(true);
-
- Position last = Context.getIdentityManager().getLastPosition(getDeviceId());
- if (last != null) {
- position.setFixTime(last.getFixTime());
- position.setValid(last.getValid());
- position.setLatitude(last.getLatitude());
- position.setLongitude(last.getLongitude());
- position.setAltitude(last.getAltitude());
- position.setSpeed(last.getSpeed());
- position.setCourse(last.getCourse());
- } else {
- position.setFixTime(new Date(0));
- }
+ if (position.getDeviceId() != 0) {
+ position.setOutdated(true);
+
+ Position last = Context.getIdentityManager().getLastPosition(position.getDeviceId());
+ if (last != null) {
+ position.setFixTime(last.getFixTime());
+ position.setValid(last.getValid());
+ position.setLatitude(last.getLatitude());
+ position.setLongitude(last.getLongitude());
+ position.setAltitude(last.getAltitude());
+ position.setSpeed(last.getSpeed());
+ position.setCourse(last.getCourse());
+ } else {
+ position.setFixTime(new Date(0));
+ }
- if (deviceTime != null) {
- position.setDeviceTime(deviceTime);
- } else {
- position.setDeviceTime(new Date());
+ if (deviceTime != null) {
+ position.setDeviceTime(deviceTime);
+ } else {
+ position.setDeviceTime(new Date());
+ }
}
}