diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2021-10-07 09:26:51 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2021-10-07 09:26:51 -0700 |
commit | 6802e2657378e8e3eec7de742d5690f3978cfa2d (patch) | |
tree | 9e6019658a9e7bfa1ee7a6e203a875fa425325f6 /src/main/java/org/traccar/protocol/DmtHttpProtocolDecoder.java | |
parent | 5121d5bc446f8e6a2350c50038a9baa5deb09d4c (diff) | |
download | trackermap-server-6802e2657378e8e3eec7de742d5690f3978cfa2d.tar.gz trackermap-server-6802e2657378e8e3eec7de742d5690f3978cfa2d.tar.bz2 trackermap-server-6802e2657378e8e3eec7de742d5690f3978cfa2d.zip |
Handle missing coordinates
Diffstat (limited to 'src/main/java/org/traccar/protocol/DmtHttpProtocolDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/DmtHttpProtocolDecoder.java | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/protocol/DmtHttpProtocolDecoder.java b/src/main/java/org/traccar/protocol/DmtHttpProtocolDecoder.java index ebf9a006c..cffc1f3eb 100644 --- a/src/main/java/org/traccar/protocol/DmtHttpProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/DmtHttpProtocolDecoder.java @@ -159,11 +159,17 @@ public class DmtHttpProtocolDecoder extends BaseHttpProtocolDecoder { Position position = new Position(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); - position.setValid(true); - position.setTime(new Date(OffsetDateTime.parse(root.getString("date")).toInstant().toEpochMilli())); - position.setLatitude(root.getJsonNumber("lat").doubleValue()); - position.setLongitude(root.getJsonNumber("lng").doubleValue()); - position.setAccuracy(root.getJsonNumber("posAcc").doubleValue()); + Date time = new Date(OffsetDateTime.parse(root.getString("date")).toInstant().toEpochMilli()); + + if (root.containsKey("lat") && root.containsKey("lng")) { + position.setValid(true); + position.setTime(time); + position.setLatitude(root.getJsonNumber("lat").doubleValue()); + position.setLongitude(root.getJsonNumber("lng").doubleValue()); + position.setAccuracy(root.getJsonNumber("posAcc").doubleValue()); + } else { + getLastLocation(position, time); + } position.set(Position.KEY_INDEX, root.getInt("sqn")); position.set(Position.KEY_EVENT, root.getInt("reason")); |