From 823bc46474e40f0fdb678f22e1269f32f75264c2 Mon Sep 17 00:00:00 2001 From: Evgeny S Maksimov Date: Thu, 14 Feb 2019 19:10:17 +0300 Subject: Fixed geofences processing order --- src/org/traccar/events/GeofenceEventHandler.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/org') diff --git a/src/org/traccar/events/GeofenceEventHandler.java b/src/org/traccar/events/GeofenceEventHandler.java index ea379dbdb..313553195 100644 --- a/src/org/traccar/events/GeofenceEventHandler.java +++ b/src/org/traccar/events/GeofenceEventHandler.java @@ -60,20 +60,20 @@ public class GeofenceEventHandler extends BaseEventHandler { device.setGeofenceIds(currentGeofences); Map events = new HashMap<>(); - for (long geofenceId : newGeofences) { + for (long geofenceId : oldGeofences) { long calendarId = geofenceManager.getById(geofenceId).getCalendarId(); Calendar calendar = calendarId != 0 ? Context.getCalendarManager().getById(calendarId) : null; if (calendar == null || calendar.checkMoment(position.getFixTime())) { - Event event = new Event(Event.TYPE_GEOFENCE_ENTER, position.getDeviceId(), position.getId()); + Event event = new Event(Event.TYPE_GEOFENCE_EXIT, position.getDeviceId(), position.getId()); event.setGeofenceId(geofenceId); events.put(event, position); } } - for (long geofenceId : oldGeofences) { + for (long geofenceId : newGeofences) { long calendarId = geofenceManager.getById(geofenceId).getCalendarId(); Calendar calendar = calendarId != 0 ? Context.getCalendarManager().getById(calendarId) : null; if (calendar == null || calendar.checkMoment(position.getFixTime())) { - Event event = new Event(Event.TYPE_GEOFENCE_EXIT, position.getDeviceId(), position.getId()); + Event event = new Event(Event.TYPE_GEOFENCE_ENTER, position.getDeviceId(), position.getId()); event.setGeofenceId(geofenceId); events.put(event, position); } -- cgit v1.2.3