From 57b5aa9ada42f1c113dc0cef8f259b55b6f9ea69 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 13 Apr 2021 19:26:17 -0700 Subject: Event geocoding only on notifications --- .../java/org/traccar/database/NotificationManager.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/main/java/org/traccar/database/NotificationManager.java') diff --git a/src/main/java/org/traccar/database/NotificationManager.java b/src/main/java/org/traccar/database/NotificationManager.java index c4fc48ebf..9f9a83cd2 100644 --- a/src/main/java/org/traccar/database/NotificationManager.java +++ b/src/main/java/org/traccar/database/NotificationManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2020 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2021 Anton Tananaev (anton@traccar.org) * Copyright 2016 - 2018 Andrey Kunitsyn (andrey@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -41,7 +41,7 @@ public class NotificationManager extends ExtendedObjectManager { private static final Logger LOGGER = LoggerFactory.getLogger(NotificationManager.class); - private boolean geocodeOnRequest; + private final boolean geocodeOnRequest; public NotificationManager(DataManager dataManager) { super(dataManager, Notification.class); @@ -70,11 +70,6 @@ public class NotificationManager extends ExtendedObjectManager { LOGGER.warn("Event save error", error); } - if (position != null && geocodeOnRequest && Context.getGeocoder() != null && position.getAddress() == null) { - position.setAddress(Context.getGeocoder() - .getAddress(position.getLatitude(), position.getLongitude(), null)); - } - long deviceId = event.getDeviceId(); Set users = Context.getPermissionsManager().getDeviceUsers(deviceId); Set usersToForward = null; @@ -108,6 +103,13 @@ public class NotificationManager extends ExtendedObjectManager { } } } + + if (position != null && position.getAddress() == null + && geocodeOnRequest && Context.getGeocoder() != null) { + position.setAddress(Context.getGeocoder() + .getAddress(position.getLatitude(), position.getLongitude(), null)); + } + for (String notificator : notificators) { Context.getNotificatorManager().getNotificator(notificator).sendAsync(userId, event, position); } -- cgit v1.2.3