aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/geolocation/OpenCellIdGeolocationProvider.java
diff options
context:
space:
mode:
authorcasswarry0 <casswarry0@gmail.com>2023-01-17 17:14:53 -0700
committercasswarry0 <casswarry0@gmail.com>2023-01-17 17:14:53 -0700
commit7338b8730949ed027b3f8b31d7dca20687ebbb8b (patch)
treec2d171e6121818ab511460a786f69aab97a2a628 /src/main/java/org/traccar/geolocation/OpenCellIdGeolocationProvider.java
parentcdecd3fa4427a382c0b09f8ad9d69ec14388960a (diff)
parent85501f9cf4918d5eee345f83aed7a31eecb26b8d (diff)
downloadtrackermap-server-7338b8730949ed027b3f8b31d7dca20687ebbb8b.tar.gz
trackermap-server-7338b8730949ed027b3f8b31d7dca20687ebbb8b.tar.bz2
trackermap-server-7338b8730949ed027b3f8b31d7dca20687ebbb8b.zip
Merge branch 'master' into develop
Diffstat (limited to 'src/main/java/org/traccar/geolocation/OpenCellIdGeolocationProvider.java')
-rw-r--r--src/main/java/org/traccar/geolocation/OpenCellIdGeolocationProvider.java12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/geolocation/OpenCellIdGeolocationProvider.java b/src/main/java/org/traccar/geolocation/OpenCellIdGeolocationProvider.java
index 2535970d3..82fcf42ab 100644
--- a/src/main/java/org/traccar/geolocation/OpenCellIdGeolocationProvider.java
+++ b/src/main/java/org/traccar/geolocation/OpenCellIdGeolocationProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2022 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,18 +15,20 @@
*/
package org.traccar.geolocation;
-import org.traccar.Context;
import org.traccar.model.CellTower;
import org.traccar.model.Network;
import javax.json.JsonObject;
+import javax.ws.rs.client.Client;
import javax.ws.rs.client.InvocationCallback;
public class OpenCellIdGeolocationProvider implements GeolocationProvider {
- private String url;
+ private final Client client;
+ private final String url;
- public OpenCellIdGeolocationProvider(String url, String key) {
+ public OpenCellIdGeolocationProvider(Client client, String url, String key) {
+ this.client = client;
if (url == null) {
url = "http://opencellid.org/cell/get";
}
@@ -41,7 +43,7 @@ public class OpenCellIdGeolocationProvider implements GeolocationProvider {
String request = String.format(url, cellTower.getMobileCountryCode(), cellTower.getMobileNetworkCode(),
cellTower.getLocationAreaCode(), cellTower.getCellId());
- Context.getClient().target(request).request().async().get(new InvocationCallback<JsonObject>() {
+ client.target(request).request().async().get(new InvocationCallback<JsonObject>() {
@Override
public void completed(JsonObject json) {
if (json.containsKey("lat") && json.containsKey("lon")) {