aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/handler
diff options
context:
space:
mode:
authorK-J-Dod24 <kieran.dodson@complexus.uk>2023-05-10 10:26:14 +0100
committerK-J-Dod24 <kieran.dodson@complexus.uk>2023-05-10 10:26:14 +0100
commitb81025ee361467848ec2a1771499a3b959fd7535 (patch)
tree2492d5aa2a37daf6414b9907dd2819919595f06b /src/main/java/org/traccar/handler
parent445366d9a49fbee7a28a41e1f95423c07b54b725 (diff)
parentd797671b2ce6fb70ac868bb96f87be8b2a85e4f9 (diff)
downloadtrackermap-server-b81025ee361467848ec2a1771499a3b959fd7535.tar.gz
trackermap-server-b81025ee361467848ec2a1771499a3b959fd7535.tar.bz2
trackermap-server-b81025ee361467848ec2a1771499a3b959fd7535.zip
Merge branch 'Teltonika-io32-coolantTemp' of https://github.com/Complexus-Limited/traccar into Teltonika-io32-coolantTemp
Diffstat (limited to 'src/main/java/org/traccar/handler')
-rw-r--r--src/main/java/org/traccar/handler/events/GeofenceEventHandler.java27
1 files changed, 10 insertions, 17 deletions
diff --git a/src/main/java/org/traccar/handler/events/GeofenceEventHandler.java b/src/main/java/org/traccar/handler/events/GeofenceEventHandler.java
index 0ab9ca217..096f71373 100644
--- a/src/main/java/org/traccar/handler/events/GeofenceEventHandler.java
+++ b/src/main/java/org/traccar/handler/events/GeofenceEventHandler.java
@@ -16,15 +16,12 @@
package org.traccar.handler.events;
import io.netty.channel.ChannelHandler;
-import org.traccar.config.Config;
import org.traccar.helper.model.PositionUtil;
import org.traccar.model.Calendar;
import org.traccar.model.Event;
import org.traccar.model.Geofence;
import org.traccar.model.Position;
-import org.traccar.session.ConnectionManager;
import org.traccar.session.cache.CacheManager;
-import org.traccar.storage.Storage;
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -37,18 +34,11 @@ import java.util.Map;
@ChannelHandler.Sharable
public class GeofenceEventHandler extends BaseEventHandler {
- private final Config config;
private final CacheManager cacheManager;
- private final ConnectionManager connectionManager;
- private final Storage storage;
@Inject
- public GeofenceEventHandler(
- Config config, CacheManager cacheManager, ConnectionManager connectionManager, Storage storage) {
- this.config = config;
+ public GeofenceEventHandler(CacheManager cacheManager) {
this.cacheManager = cacheManager;
- this.connectionManager = connectionManager;
- this.storage = storage;
}
@Override
@@ -72,12 +62,15 @@ public class GeofenceEventHandler extends BaseEventHandler {
Map<Event, Position> events = new HashMap<>();
for (long geofenceId : oldGeofences) {
- long calendarId = cacheManager.getObject(Geofence.class, geofenceId).getCalendarId();
- Calendar calendar = calendarId != 0 ? cacheManager.getObject(Calendar.class, calendarId) : null;
- if (calendar == null || calendar.checkMoment(position.getFixTime())) {
- Event event = new Event(Event.TYPE_GEOFENCE_EXIT, position);
- event.setGeofenceId(geofenceId);
- events.put(event, position);
+ Geofence geofence = cacheManager.getObject(Geofence.class, geofenceId);
+ if (geofence != null) {
+ long calendarId = geofence.getCalendarId();
+ Calendar calendar = calendarId != 0 ? cacheManager.getObject(Calendar.class, calendarId) : null;
+ if (calendar == null || calendar.checkMoment(position.getFixTime())) {
+ Event event = new Event(Event.TYPE_GEOFENCE_EXIT, position);
+ event.setGeofenceId(geofenceId);
+ events.put(event, position);
+ }
}
}
for (long geofenceId : newGeofences) {