From 03a5a0c17cb03a558011c8e817f023d0030ac6ab Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 25 Apr 2021 21:13:28 -0700 Subject: Register all geocoding requests --- src/main/java/org/traccar/MainModule.java | 5 ++--- src/main/java/org/traccar/geocoder/JsonGeocoder.java | 4 ++++ src/main/java/org/traccar/handler/GeocoderHandler.java | 8 +------- 3 files changed, 7 insertions(+), 10 deletions(-) (limited to 'src/main/java/org') diff --git a/src/main/java/org/traccar/MainModule.java b/src/main/java/org/traccar/MainModule.java index 2b7fa5c61..350af6bd7 100644 --- a/src/main/java/org/traccar/MainModule.java +++ b/src/main/java/org/traccar/MainModule.java @@ -286,10 +286,9 @@ public class MainModule extends AbstractModule { @Singleton @Provides public static GeocoderHandler provideGeocoderHandler( - Config config, @Nullable Geocoder geocoder, IdentityManager identityManager, - StatisticsManager statisticsManager) { + Config config, @Nullable Geocoder geocoder, IdentityManager identityManager) { if (geocoder != null) { - return new GeocoderHandler(config, geocoder, identityManager, statisticsManager); + return new GeocoderHandler(config, geocoder, identityManager); } return null; } diff --git a/src/main/java/org/traccar/geocoder/JsonGeocoder.java b/src/main/java/org/traccar/geocoder/JsonGeocoder.java index 8c442def3..4f34fb973 100644 --- a/src/main/java/org/traccar/geocoder/JsonGeocoder.java +++ b/src/main/java/org/traccar/geocoder/JsonGeocoder.java @@ -18,6 +18,8 @@ package org.traccar.geocoder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.traccar.Context; +import org.traccar.Main; +import org.traccar.database.StatisticsManager; import javax.json.JsonObject; import javax.ws.rs.ClientErrorException; @@ -95,6 +97,8 @@ public abstract class JsonGeocoder implements Geocoder { } } + Main.getInjector().getInstance(StatisticsManager.class).registerGeocoderRequest(); + Invocation.Builder request = Context.getClient().target(String.format(url, latitude, longitude)).request(); if (callback != null) { diff --git a/src/main/java/org/traccar/handler/GeocoderHandler.java b/src/main/java/org/traccar/handler/GeocoderHandler.java index b96f01b3a..92f09ba71 100644 --- a/src/main/java/org/traccar/handler/GeocoderHandler.java +++ b/src/main/java/org/traccar/handler/GeocoderHandler.java @@ -35,16 +35,14 @@ public class GeocoderHandler extends ChannelInboundHandlerAdapter { private final Geocoder geocoder; private final IdentityManager identityManager; - private final StatisticsManager statisticsManager; private final boolean ignorePositions; private final boolean processInvalidPositions; private final int geocoderReuseDistance; public GeocoderHandler( - Config config, Geocoder geocoder, IdentityManager identityManager, StatisticsManager statisticsManager) { + Config config, Geocoder geocoder, IdentityManager identityManager) { this.geocoder = geocoder; this.identityManager = identityManager; - this.statisticsManager = statisticsManager; ignorePositions = Context.getConfig().getBoolean(Keys.GEOCODER_IGNORE_POSITIONS); processInvalidPositions = config.getBoolean(Keys.GEOCODER_PROCESS_INVALID_POSITIONS); geocoderReuseDistance = config.getInteger(Keys.GEOCODER_REUSE_DISTANCE, 0); @@ -65,10 +63,6 @@ public class GeocoderHandler extends ChannelInboundHandlerAdapter { } } - if (statisticsManager != null) { - statisticsManager.registerGeocoderRequest(); - } - geocoder.getAddress(position.getLatitude(), position.getLongitude(), new Geocoder.ReverseGeocoderCallback() { @Override -- cgit v1.2.3