aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/events/MotionEventHandler.java
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-06-16 09:30:32 +0500
committerAbyss777 <abyss@fox5.ru>2017-06-16 09:30:32 +0500
commitb5e180da135c48afc3d89665000b6de0e6a330e3 (patch)
tree1f9c604ac9898eb0c88a79c34b25f604037db55a /src/org/traccar/events/MotionEventHandler.java
parentbf57beec25228d58df8604e23d8709f6d196f3c5 (diff)
downloadtrackermap-server-b5e180da135c48afc3d89665000b6de0e6a330e3.tar.gz
trackermap-server-b5e180da135c48afc3d89665000b6de0e6a330e3.tar.bz2
trackermap-server-b5e180da135c48afc3d89665000b6de0e6a330e3.zip
Centralized motion detection
Diffstat (limited to 'src/org/traccar/events/MotionEventHandler.java')
-rw-r--r--src/org/traccar/events/MotionEventHandler.java16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/org/traccar/events/MotionEventHandler.java b/src/org/traccar/events/MotionEventHandler.java
index be8218985..e6fd10f3e 100644
--- a/src/org/traccar/events/MotionEventHandler.java
+++ b/src/org/traccar/events/MotionEventHandler.java
@@ -26,12 +26,6 @@ import org.traccar.model.Position;
public class MotionEventHandler extends BaseEventHandler {
- private double speedThreshold;
-
- public MotionEventHandler() {
- speedThreshold = Context.getConfig().getDouble("event.motion.speedThreshold", 0.01);
- }
-
@Override
protected Collection<Event> analyzePosition(Position position) {
@@ -43,16 +37,16 @@ public class MotionEventHandler extends BaseEventHandler {
return null;
}
- double speed = position.getSpeed();
- double oldSpeed = 0;
+ boolean motion = position.getBoolean(Position.KEY_MOTION);
+ boolean oldMotion = false;
Position lastPosition = Context.getIdentityManager().getLastPosition(position.getDeviceId());
if (lastPosition != null) {
- oldSpeed = lastPosition.getSpeed();
+ oldMotion = lastPosition.getBoolean(Position.KEY_MOTION);
}
- if (speed > speedThreshold && oldSpeed <= speedThreshold) {
+ if (motion && !oldMotion) {
return Collections.singleton(
new Event(Event.TYPE_DEVICE_MOVING, position.getDeviceId(), position.getId()));
- } else if (speed <= speedThreshold && oldSpeed > speedThreshold) {
+ } else if (!motion && oldMotion) {
return Collections.singleton(
new Event(Event.TYPE_DEVICE_STOPPED, position.getDeviceId(), position.getId()));
}