diff options
author | Abyss777 <abyss@fox5.ru> | 2016-12-14 17:34:34 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2016-12-14 18:02:17 +0500 |
commit | fff8f0c792606daff151624479d9ae9dc54187d5 (patch) | |
tree | 97e0ab38de08aba1a7b7adf90283df82d850a3ad /src/org/traccar/events | |
parent | 4557cf912fada1dc249333aa05215b0116b8ebab (diff) | |
download | trackermap-server-fff8f0c792606daff151624479d9ae9dc54187d5.tar.gz trackermap-server-fff8f0c792606daff151624479d9ae9dc54187d5.tar.bz2 trackermap-server-fff8f0c792606daff151624479d9ae9dc54187d5.zip |
Calendars implementation
Diffstat (limited to 'src/org/traccar/events')
-rw-r--r-- | src/org/traccar/events/GeofenceEventHandler.java | 20 |
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; } |