aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/events/GeofenceEventHandler.java
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-08-17 10:10:05 +0500
committerAbyss777 <abyss@fox5.ru>2017-08-17 10:10:05 +0500
commit1324c00d0ece6e20545fb75f7775a2c6cee2a391 (patch)
tree775ad2a42ebba160d1e36be38c59384cd1da5a1e /src/org/traccar/events/GeofenceEventHandler.java
parent9476e6be8fae228cda5867750bc4d102b1f9497d (diff)
downloadtrackermap-server-1324c00d0ece6e20545fb75f7775a2c6cee2a391.tar.gz
trackermap-server-1324c00d0ece6e20545fb75f7775a2c6cee2a391.tar.bz2
trackermap-server-1324c00d0ece6e20545fb75f7775a2c6cee2a391.zip
Pass Map<Event, Position> to notifications
Diffstat (limited to 'src/org/traccar/events/GeofenceEventHandler.java')
-rw-r--r--src/org/traccar/events/GeofenceEventHandler.java11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/org/traccar/events/GeofenceEventHandler.java b/src/org/traccar/events/GeofenceEventHandler.java
index 79e5d0f8e..31d82a81e 100644
--- a/src/org/traccar/events/GeofenceEventHandler.java
+++ b/src/org/traccar/events/GeofenceEventHandler.java
@@ -16,8 +16,9 @@
package org.traccar.events;
import java.util.ArrayList;
-import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.traccar.BaseEventHandler;
import org.traccar.Context;
@@ -36,7 +37,7 @@ public class GeofenceEventHandler extends BaseEventHandler {
}
@Override
- protected Collection<Event> analyzePosition(Position position) {
+ protected Map<Event, Position> analyzePosition(Position position) {
Device device = Context.getIdentityManager().getById(position.getDeviceId());
if (device == null) {
return null;
@@ -56,14 +57,14 @@ public class GeofenceEventHandler extends BaseEventHandler {
device.setGeofenceIds(currentGeofences);
- Collection<Event> events = new ArrayList<>();
+ Map<Event, Position> events = new HashMap<>();
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_ENTER, position.getDeviceId(), position.getId());
event.setGeofenceId(geofenceId);
- events.add(event);
+ events.put(event, position);
}
}
for (long geofenceId : oldGeofences) {
@@ -72,7 +73,7 @@ public class GeofenceEventHandler extends BaseEventHandler {
if (calendar == null || calendar.checkMoment(position.getFixTime())) {
Event event = new Event(Event.TYPE_GEOFENCE_EXIT, position.getDeviceId(), position.getId());
event.setGeofenceId(geofenceId);
- events.add(event);
+ events.put(event, position);
}
}
return events;