aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/events/GeofenceEventHandler.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/events/GeofenceEventHandler.java')
-rw-r--r--src/org/traccar/events/GeofenceEventHandler.java20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/org/traccar/events/GeofenceEventHandler.java b/src/org/traccar/events/GeofenceEventHandler.java
index d31e516ef..fbec932b1 100644
--- a/src/org/traccar/events/GeofenceEventHandler.java
+++ b/src/org/traccar/events/GeofenceEventHandler.java
@@ -57,14 +57,22 @@ public class GeofenceEventHandler extends BaseEventHandler {
Collection<Event> events = new ArrayList<>();
for (long geofenceId : newGeofences) {
- Event event = new Event(Event.TYPE_GEOFENCE_ENTER, position.getDeviceId(), position.getId());
- event.setGeofenceId(geofenceId);
- events.add(event);
+ long calendarId = geofenceManager.getGeofence(geofenceId).getCalendarId();
+ if (calendarId == 0 || Context.getCalendarManager().getCalendar(calendarId) == null
+ || Context.getCalendarManager().getCalendar(calendarId).checkMoment(position.getFixTime())) {
+ Event event = new Event(Event.TYPE_GEOFENCE_ENTER, position.getDeviceId(), position.getId());
+ event.setGeofenceId(geofenceId);
+ events.add(event);
+ }
}
for (long geofenceId : oldGeofences) {
- Event event = new Event(Event.TYPE_GEOFENCE_EXIT, position.getDeviceId(), position.getId());
- event.setGeofenceId(geofenceId);
- events.add(event);
+ long calendarId = geofenceManager.getGeofence(geofenceId).getCalendarId();
+ if (calendarId == 0 || Context.getCalendarManager().getCalendar(calendarId) == null
+ || Context.getCalendarManager().getCalendar(calendarId).checkMoment(position.getFixTime())) {
+ Event event = new Event(Event.TYPE_GEOFENCE_EXIT, position.getDeviceId(), position.getId());
+ event.setGeofenceId(geofenceId);
+ events.add(event);
+ }
}
return events;
}