aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornamo <namo@gurtam.com>2017-10-20 13:52:15 +0300
committernamo <namo@gurtam.com>2017-10-20 13:52:15 +0300
commitcf1f0c95cb2f948abfffc5cb207926c916e636c0 (patch)
tree5ada29ae0b4c92abaa336ecb396df1dc11cd51ed /src
parentf20b926497a4d61b6fefcdba57c0ebfb23ef5fc2 (diff)
downloadtrackermap-server-cf1f0c95cb2f948abfffc5cb207926c916e636c0.tar.gz
trackermap-server-cf1f0c95cb2f948abfffc5cb207926c916e636c0.tar.bz2
trackermap-server-cf1f0c95cb2f948abfffc5cb207926c916e636c0.zip
flespi integration: listening messages (rev.4)
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/protocol/FlespiProtocolDecoder.java24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/org/traccar/protocol/FlespiProtocolDecoder.java b/src/org/traccar/protocol/FlespiProtocolDecoder.java
index 1940673c3..3a12cd7b8 100644
--- a/src/org/traccar/protocol/FlespiProtocolDecoder.java
+++ b/src/org/traccar/protocol/FlespiProtocolDecoder.java
@@ -88,21 +88,25 @@ public class FlespiProtocolDecoder extends BaseProtocolDecoder {
position.setTime(new Date((long) object.getJsonNumber("timestamp").doubleValue() * 1000));
JsonNumber lat = object.getJsonNumber("position.latitude");
JsonNumber lon = object.getJsonNumber("position.longitude");
- position.setLatitude(lat != null ? lat.doubleValue() : 0);
- position.setLongitude(lon != null ? lon.doubleValue() : 0);
-
+ if (lat != null && lon != null) {
+ position.setLatitude(lat.doubleValue());
+ position.setLongitude(lon.doubleValue());
+ }
JsonNumber speed = object.getJsonNumber("position.speed");
- position.setSpeed(speed != null ? speed.doubleValue() : 0);
-
+ if (speed != null) {
+ position.setSpeed(speed.doubleValue());
+ }
JsonNumber course = object.getJsonNumber("position.direction");
- position.setCourse(course != null ? course.doubleValue() : 0);
-
+ if (course != null) {
+ position.setCourse(course.doubleValue());
+ }
JsonNumber altitude = object.getJsonNumber("position.altitude");
- position.setAltitude(altitude != null ? altitude.doubleValue() : 0);
+ if (altitude != null) {
+ position.setAltitude(altitude.doubleValue());
+ }
- int satellites = object.getInt("position.satellites", 0);
position.setValid(object.getBoolean("position.valid", true));
- position.set(Position.KEY_SATELLITES, satellites);
+ position.set(Position.KEY_SATELLITES, object.getInt("position.satellites", 0));
if (object.getBoolean("alarm.event.trigger", false)) {
position.set(Position.KEY_ALARM, Position.ALARM_GENERAL);