diff options
author | Anton Tananaev <anton@traccar.org> | 2023-05-14 10:28:44 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2023-05-14 10:28:44 -0700 |
commit | f68d23d79d0321ef47f72fff2388b5f4aac1beff (patch) | |
tree | 4e6b85435a5b4e8b5816bf5895cce0e3ab0069e7 /src/main/java/org/traccar/handler | |
parent | 78e18b3da86de2e2c5f2aa67ff03c3827708d6a0 (diff) | |
download | trackermap-server-f68d23d79d0321ef47f72fff2388b5f4aac1beff.tar.gz trackermap-server-f68d23d79d0321ef47f72fff2388b5f4aac1beff.tar.bz2 trackermap-server-f68d23d79d0321ef47f72fff2388b5f4aac1beff.zip |
Per device motion threshold
Diffstat (limited to 'src/main/java/org/traccar/handler')
-rw-r--r-- | src/main/java/org/traccar/handler/MotionHandler.java | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/handler/MotionHandler.java b/src/main/java/org/traccar/handler/MotionHandler.java index 10312f9b3..297527b4d 100644 --- a/src/main/java/org/traccar/handler/MotionHandler.java +++ b/src/main/java/org/traccar/handler/MotionHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 - 2022 Anton Tananaev (anton@traccar.org) + * Copyright 2017 - 2023 Anton Tananaev (anton@traccar.org) * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,8 +18,10 @@ package org.traccar.handler; import io.netty.channel.ChannelHandler; import org.traccar.BaseDataHandler; +import org.traccar.config.Keys; +import org.traccar.helper.model.AttributeUtil; import org.traccar.model.Position; -import org.traccar.reports.common.TripsConfig; +import org.traccar.session.cache.CacheManager; import javax.inject.Inject; import javax.inject.Singleton; @@ -28,17 +30,19 @@ import javax.inject.Singleton; @ChannelHandler.Sharable public class MotionHandler extends BaseDataHandler { - private final double speedThreshold; + private final CacheManager cacheManager; @Inject - public MotionHandler(TripsConfig tripsConfig) { - speedThreshold = tripsConfig.getSpeedThreshold(); + public MotionHandler(CacheManager cacheManager) { + this.cacheManager = cacheManager; } @Override protected Position handlePosition(Position position) { if (!position.hasAttribute(Position.KEY_MOTION)) { - position.set(Position.KEY_MOTION, position.getSpeed() > speedThreshold); + double threshold = AttributeUtil.lookup( + cacheManager, Keys.EVENT_MOTION_SPEED_THRESHOLD, position.getDeviceId()); + position.set(Position.KEY_MOTION, position.getSpeed() > threshold); } return position; } |