aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/api/resource
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-10 07:56:49 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-10 07:56:49 -0700
commitbbe84d6a751fdc840e4201ef9027a96527006049 (patch)
tree4165d09a134eb1c1c61438b17fe44f5a1fcd0654 /src/main/java/org/traccar/api/resource
parentc03b4a2ace925e6a0d7c43ce59e14ddb9cbf18a9 (diff)
downloadtrackermap-server-bbe84d6a751fdc840e4201ef9027a96527006049.tar.gz
trackermap-server-bbe84d6a751fdc840e4201ef9027a96527006049.tar.bz2
trackermap-server-bbe84d6a751fdc840e4201ef9027a96527006049.zip
Inject report utils
Diffstat (limited to 'src/main/java/org/traccar/api/resource')
-rw-r--r--src/main/java/org/traccar/api/resource/ServerResource.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/api/resource/ServerResource.java b/src/main/java/org/traccar/api/resource/ServerResource.java
index 51a26825b..18230a2b3 100644
--- a/src/main/java/org/traccar/api/resource/ServerResource.java
+++ b/src/main/java/org/traccar/api/resource/ServerResource.java
@@ -18,6 +18,7 @@ package org.traccar.api.resource;
import org.traccar.Context;
import org.traccar.api.BaseResource;
import org.traccar.database.MailManager;
+import org.traccar.geocoder.Geocoder;
import org.traccar.helper.LogAction;
import org.traccar.model.Server;
import org.traccar.storage.Storage;
@@ -25,6 +26,7 @@ import org.traccar.storage.StorageException;
import org.traccar.storage.query.Columns;
import org.traccar.storage.query.Request;
+import javax.annotation.Nullable;
import javax.annotation.security.PermitAll;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
@@ -50,6 +52,10 @@ public class ServerResource extends BaseResource {
@Inject
private MailManager mailManager;
+ @Inject
+ @Nullable
+ private Geocoder geocoder;
+
@PermitAll
@GET
public Server get() throws StorageException {
@@ -69,8 +75,8 @@ public class ServerResource extends BaseResource {
@Path("geocode")
@GET
public String geocode(@QueryParam("latitude") double latitude, @QueryParam("longitude") double longitude) {
- if (Context.getGeocoder() != null) {
- return Context.getGeocoder().getAddress(latitude, longitude, null);
+ if (geocoder != null) {
+ return geocoder.getAddress(latitude, longitude, null);
} else {
throw new RuntimeException("Reverse geocoding is not enabled");
}