aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/geocoder
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/geocoder')
-rw-r--r--src/main/java/org/traccar/geocoder/BanGeocoder.java5
-rw-r--r--src/main/java/org/traccar/geocoder/BingMapsGeocoder.java5
-rw-r--r--src/main/java/org/traccar/geocoder/FactualGeocoder.java5
-rw-r--r--src/main/java/org/traccar/geocoder/GeoapifyGeocoder.java5
-rw-r--r--src/main/java/org/traccar/geocoder/GeocodeFarmGeocoder.java6
-rw-r--r--src/main/java/org/traccar/geocoder/GeocodeXyzGeocoder.java5
-rw-r--r--src/main/java/org/traccar/geocoder/GisgraphyGeocoder.java5
-rw-r--r--src/main/java/org/traccar/geocoder/GoogleGeocoder.java5
-rw-r--r--src/main/java/org/traccar/geocoder/HereGeocoder.java6
-rw-r--r--src/main/java/org/traccar/geocoder/JsonGeocoder.java9
-rw-r--r--src/main/java/org/traccar/geocoder/MapQuestGeocoder.java5
-rw-r--r--src/main/java/org/traccar/geocoder/MapTilerGeocoder.java5
-rw-r--r--src/main/java/org/traccar/geocoder/MapboxGeocoder.java5
-rw-r--r--src/main/java/org/traccar/geocoder/MapmyIndiaGeocoder.java5
-rw-r--r--src/main/java/org/traccar/geocoder/NominatimGeocoder.java6
-rw-r--r--src/main/java/org/traccar/geocoder/OpenCageGeocoder.java6
-rw-r--r--src/main/java/org/traccar/geocoder/PositionStackGeocoder.java5
-rw-r--r--src/main/java/org/traccar/geocoder/TomTomGeocoder.java5
18 files changed, 60 insertions, 38 deletions
diff --git a/src/main/java/org/traccar/geocoder/BanGeocoder.java b/src/main/java/org/traccar/geocoder/BanGeocoder.java
index b1f0900a4..f878a8bab 100644
--- a/src/main/java/org/traccar/geocoder/BanGeocoder.java
+++ b/src/main/java/org/traccar/geocoder/BanGeocoder.java
@@ -22,11 +22,12 @@ package org.traccar.geocoder;
import javax.json.JsonArray;
import javax.json.JsonObject;
+import javax.ws.rs.client.Client;
public class BanGeocoder extends JsonGeocoder {
- public BanGeocoder(int cacheSize, AddressFormat addressFormat) {
- super("https://api-adresse.data.gouv.fr/reverse/?lat=%f&lon=%f", cacheSize, addressFormat);
+ public BanGeocoder(Client client, int cacheSize, AddressFormat addressFormat) {
+ super(client, "https://api-adresse.data.gouv.fr/reverse/?lat=%f&lon=%f", cacheSize, addressFormat);
}
@Override
diff --git a/src/main/java/org/traccar/geocoder/BingMapsGeocoder.java b/src/main/java/org/traccar/geocoder/BingMapsGeocoder.java
index 32a26ee0c..01e33c2ea 100644
--- a/src/main/java/org/traccar/geocoder/BingMapsGeocoder.java
+++ b/src/main/java/org/traccar/geocoder/BingMapsGeocoder.java
@@ -18,11 +18,12 @@ package org.traccar.geocoder;
import javax.json.JsonArray;
import javax.json.JsonObject;
+import javax.ws.rs.client.Client;
public class BingMapsGeocoder extends JsonGeocoder {
- public BingMapsGeocoder(String url, String key, int cacheSize, AddressFormat addressFormat) {
- super(url + "/Locations/%f,%f?key=" + key + "&include=ciso2", cacheSize, addressFormat);
+ public BingMapsGeocoder(Client client, String url, String key, int cacheSize, AddressFormat addressFormat) {
+ super(client, url + "/Locations/%f,%f?key=" + key + "&include=ciso2", cacheSize, addressFormat);
}
@Override
diff --git a/src/main/java/org/traccar/geocoder/FactualGeocoder.java b/src/main/java/org/traccar/geocoder/FactualGeocoder.java
index f540eb8fe..384f46b0e 100644
--- a/src/main/java/org/traccar/geocoder/FactualGeocoder.java
+++ b/src/main/java/org/traccar/geocoder/FactualGeocoder.java
@@ -17,6 +17,7 @@
package org.traccar.geocoder;
import javax.json.JsonObject;
+import javax.ws.rs.client.Client;
public class FactualGeocoder extends JsonGeocoder {
@@ -28,8 +29,8 @@ public class FactualGeocoder extends JsonGeocoder {
return url;
}
- public FactualGeocoder(String url, String key, int cacheSize, AddressFormat addressFormat) {
- super(formatUrl(url, key), cacheSize, addressFormat);
+ public FactualGeocoder(Client client, String url, String key, int cacheSize, AddressFormat addressFormat) {
+ super(client, formatUrl(url, key), cacheSize, addressFormat);
}
@Override
diff --git a/src/main/java/org/traccar/geocoder/GeoapifyGeocoder.java b/src/main/java/org/traccar/geocoder/GeoapifyGeocoder.java
index ef0e4c8bd..4748d6a2c 100644
--- a/src/main/java/org/traccar/geocoder/GeoapifyGeocoder.java
+++ b/src/main/java/org/traccar/geocoder/GeoapifyGeocoder.java
@@ -17,6 +17,7 @@ package org.traccar.geocoder;
import javax.json.JsonArray;
import javax.json.JsonObject;
+import javax.ws.rs.client.Client;
public class GeoapifyGeocoder extends JsonGeocoder {
@@ -31,8 +32,8 @@ public class GeoapifyGeocoder extends JsonGeocoder {
return url;
}
- public GeoapifyGeocoder(String key, String language, int cacheSize, AddressFormat addressFormat) {
- super(formatUrl(key, language), cacheSize, addressFormat);
+ public GeoapifyGeocoder(Client client, String key, String language, int cacheSize, AddressFormat addressFormat) {
+ super(client, formatUrl(key, language), cacheSize, addressFormat);
}
@Override
diff --git a/src/main/java/org/traccar/geocoder/GeocodeFarmGeocoder.java b/src/main/java/org/traccar/geocoder/GeocodeFarmGeocoder.java
index 39a3300a0..2af95910f 100644
--- a/src/main/java/org/traccar/geocoder/GeocodeFarmGeocoder.java
+++ b/src/main/java/org/traccar/geocoder/GeocodeFarmGeocoder.java
@@ -16,6 +16,7 @@
package org.traccar.geocoder;
import javax.json.JsonObject;
+import javax.ws.rs.client.Client;
public class GeocodeFarmGeocoder extends JsonGeocoder {
@@ -30,8 +31,9 @@ public class GeocodeFarmGeocoder extends JsonGeocoder {
}
return url;
}
- public GeocodeFarmGeocoder(String key, String language, int cacheSize, AddressFormat addressFormat) {
- super(formatUrl(key, language), cacheSize, addressFormat);
+ public GeocodeFarmGeocoder(
+ Client client, String key, String language, int cacheSize, AddressFormat addressFormat) {
+ super(client, formatUrl(key, language), cacheSize, addressFormat);
}
@Override
diff --git a/src/main/java/org/traccar/geocoder/GeocodeXyzGeocoder.java b/src/main/java/org/traccar/geocoder/GeocodeXyzGeocoder.java
index aca360c3d..96491ece3 100644
--- a/src/main/java/org/traccar/geocoder/GeocodeXyzGeocoder.java
+++ b/src/main/java/org/traccar/geocoder/GeocodeXyzGeocoder.java
@@ -16,6 +16,7 @@
package org.traccar.geocoder;
import javax.json.JsonObject;
+import javax.ws.rs.client.Client;
public class GeocodeXyzGeocoder extends JsonGeocoder {
@@ -27,8 +28,8 @@ public class GeocodeXyzGeocoder extends JsonGeocoder {
return url;
}
- public GeocodeXyzGeocoder(String key, int cacheSize, AddressFormat addressFormat) {
- super(formatUrl(key), cacheSize, addressFormat);
+ public GeocodeXyzGeocoder(Client client, String key, int cacheSize, AddressFormat addressFormat) {
+ super(client, formatUrl(key), cacheSize, addressFormat);
}
@Override
diff --git a/src/main/java/org/traccar/geocoder/GisgraphyGeocoder.java b/src/main/java/org/traccar/geocoder/GisgraphyGeocoder.java
index b4881a006..0589eb000 100644
--- a/src/main/java/org/traccar/geocoder/GisgraphyGeocoder.java
+++ b/src/main/java/org/traccar/geocoder/GisgraphyGeocoder.java
@@ -16,6 +16,7 @@
package org.traccar.geocoder;
import javax.json.JsonObject;
+import javax.ws.rs.client.Client;
public class GisgraphyGeocoder extends JsonGeocoder {
@@ -27,8 +28,8 @@ public class GisgraphyGeocoder extends JsonGeocoder {
return url;
}
- public GisgraphyGeocoder(String url, int cacheSize, AddressFormat addressFormat) {
- super(formatUrl(url), cacheSize, addressFormat);
+ public GisgraphyGeocoder(Client client, String url, int cacheSize, AddressFormat addressFormat) {
+ super(client, formatUrl(url), cacheSize, addressFormat);
}
@Override
diff --git a/src/main/java/org/traccar/geocoder/GoogleGeocoder.java b/src/main/java/org/traccar/geocoder/GoogleGeocoder.java
index 9494cab45..4d9ec8f36 100644
--- a/src/main/java/org/traccar/geocoder/GoogleGeocoder.java
+++ b/src/main/java/org/traccar/geocoder/GoogleGeocoder.java
@@ -18,6 +18,7 @@ package org.traccar.geocoder;
import javax.json.JsonArray;
import javax.json.JsonObject;
import javax.json.JsonString;
+import javax.ws.rs.client.Client;
public class GoogleGeocoder extends JsonGeocoder {
@@ -32,8 +33,8 @@ public class GoogleGeocoder extends JsonGeocoder {
return url;
}
- public GoogleGeocoder(String key, String language, int cacheSize, AddressFormat addressFormat) {
- super(formatUrl(key, language), cacheSize, addressFormat);
+ public GoogleGeocoder(Client client, String key, String language, int cacheSize, AddressFormat addressFormat) {
+ super(client, formatUrl(key, language), cacheSize, addressFormat);
}
@Override
diff --git a/src/main/java/org/traccar/geocoder/HereGeocoder.java b/src/main/java/org/traccar/geocoder/HereGeocoder.java
index 40390e65b..eb639995e 100644
--- a/src/main/java/org/traccar/geocoder/HereGeocoder.java
+++ b/src/main/java/org/traccar/geocoder/HereGeocoder.java
@@ -16,6 +16,7 @@
package org.traccar.geocoder;
import javax.json.JsonObject;
+import javax.ws.rs.client.Client;
public class HereGeocoder extends JsonGeocoder {
@@ -35,8 +36,9 @@ public class HereGeocoder extends JsonGeocoder {
}
public HereGeocoder(
- String url, String id, String key, String language, int cacheSize, AddressFormat addressFormat) {
- super(formatUrl(url, id, key, language), cacheSize, addressFormat);
+ Client client, String url, String id, String key, String language,
+ int cacheSize, AddressFormat addressFormat) {
+ super(client, formatUrl(url, id, key, language), cacheSize, addressFormat);
}
@Override
diff --git a/src/main/java/org/traccar/geocoder/JsonGeocoder.java b/src/main/java/org/traccar/geocoder/JsonGeocoder.java
index f20aa79d6..0262de18c 100644
--- a/src/main/java/org/traccar/geocoder/JsonGeocoder.java
+++ b/src/main/java/org/traccar/geocoder/JsonGeocoder.java
@@ -17,13 +17,12 @@ 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.WebApplicationException;
-import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.Client;
import javax.ws.rs.client.InvocationCallback;
import java.util.AbstractMap;
import java.util.Collections;
@@ -34,12 +33,14 @@ public abstract class JsonGeocoder implements Geocoder {
private static final Logger LOGGER = LoggerFactory.getLogger(JsonGeocoder.class);
+ private final Client client;
private final String url;
private final AddressFormat addressFormat;
private Map<Map.Entry<Double, Double>, String> cache;
- public JsonGeocoder(String url, final int cacheSize, AddressFormat addressFormat) {
+ public JsonGeocoder(Client client, String url, final int cacheSize, AddressFormat addressFormat) {
+ this.client = client;
this.url = url;
this.addressFormat = addressFormat;
if (cacheSize > 0) {
@@ -101,7 +102,7 @@ public abstract class JsonGeocoder implements Geocoder {
Main.getInjector().getInstance(StatisticsManager.class).registerGeocoderRequest();
}
- Invocation.Builder request = Context.getClient().target(String.format(url, latitude, longitude)).request();
+ var request = client.target(String.format(url, latitude, longitude)).request();
if (callback != null) {
request.async().get(new InvocationCallback<JsonObject>() {
diff --git a/src/main/java/org/traccar/geocoder/MapQuestGeocoder.java b/src/main/java/org/traccar/geocoder/MapQuestGeocoder.java
index 8dc3f76f0..3f2554c6e 100644
--- a/src/main/java/org/traccar/geocoder/MapQuestGeocoder.java
+++ b/src/main/java/org/traccar/geocoder/MapQuestGeocoder.java
@@ -18,6 +18,7 @@ package org.traccar.geocoder;
import javax.json.JsonArray;
import javax.json.JsonObject;
+import javax.ws.rs.client.Client;
public class MapQuestGeocoder extends JsonGeocoder {
@@ -29,8 +30,8 @@ public class MapQuestGeocoder extends JsonGeocoder {
return url;
}
- public MapQuestGeocoder(String url, String key, int cacheSize, AddressFormat addressFormat) {
- super(formatUrl(url, key), cacheSize, addressFormat);
+ public MapQuestGeocoder(Client client, String url, String key, int cacheSize, AddressFormat addressFormat) {
+ super(client, formatUrl(url, key), cacheSize, addressFormat);
}
@Override
diff --git a/src/main/java/org/traccar/geocoder/MapTilerGeocoder.java b/src/main/java/org/traccar/geocoder/MapTilerGeocoder.java
index 6b688a6e8..203f5f99b 100644
--- a/src/main/java/org/traccar/geocoder/MapTilerGeocoder.java
+++ b/src/main/java/org/traccar/geocoder/MapTilerGeocoder.java
@@ -17,11 +17,12 @@ package org.traccar.geocoder;
import javax.json.JsonArray;
import javax.json.JsonObject;
+import javax.ws.rs.client.Client;
public class MapTilerGeocoder extends JsonGeocoder {
- public MapTilerGeocoder(String key, int cacheSize, AddressFormat addressFormat) {
- super("https://api.maptiler.com/geocoding/%2$f,%1$f.json?key=" + key, cacheSize, addressFormat);
+ public MapTilerGeocoder(Client client, String key, int cacheSize, AddressFormat addressFormat) {
+ super(client, "https://api.maptiler.com/geocoding/%2$f,%1$f.json?key=" + key, cacheSize, addressFormat);
}
@Override
diff --git a/src/main/java/org/traccar/geocoder/MapboxGeocoder.java b/src/main/java/org/traccar/geocoder/MapboxGeocoder.java
index 9b987c9d8..72bfb53f5 100644
--- a/src/main/java/org/traccar/geocoder/MapboxGeocoder.java
+++ b/src/main/java/org/traccar/geocoder/MapboxGeocoder.java
@@ -18,6 +18,7 @@ package org.traccar.geocoder;
import javax.json.JsonArray;
import javax.json.JsonObject;
import javax.json.JsonString;
+import javax.ws.rs.client.Client;
public class MapboxGeocoder extends JsonGeocoder {
@@ -25,8 +26,8 @@ public class MapboxGeocoder extends JsonGeocoder {
return "https://api.mapbox.com/geocoding/v5/mapbox.places/%2$f,%1$f.json?access_token=" + key;
}
- public MapboxGeocoder(String key, int cacheSize, AddressFormat addressFormat) {
- super(formatUrl(key), cacheSize, addressFormat);
+ public MapboxGeocoder(Client client, String key, int cacheSize, AddressFormat addressFormat) {
+ super(client, formatUrl(key), cacheSize, addressFormat);
}
@Override
diff --git a/src/main/java/org/traccar/geocoder/MapmyIndiaGeocoder.java b/src/main/java/org/traccar/geocoder/MapmyIndiaGeocoder.java
index 2b70708a1..dea295cca 100644
--- a/src/main/java/org/traccar/geocoder/MapmyIndiaGeocoder.java
+++ b/src/main/java/org/traccar/geocoder/MapmyIndiaGeocoder.java
@@ -17,11 +17,12 @@ package org.traccar.geocoder;
import javax.json.JsonArray;
import javax.json.JsonObject;
+import javax.ws.rs.client.Client;
public class MapmyIndiaGeocoder extends JsonGeocoder {
- public MapmyIndiaGeocoder(String url, String key, int cacheSize, AddressFormat addressFormat) {
- super(url + "/" + key + "/rev_geocode?lat=%f&lng=%f", cacheSize, addressFormat);
+ public MapmyIndiaGeocoder(Client client, String url, String key, int cacheSize, AddressFormat addressFormat) {
+ super(client, url + "/" + key + "/rev_geocode?lat=%f&lng=%f", cacheSize, addressFormat);
}
@Override
diff --git a/src/main/java/org/traccar/geocoder/NominatimGeocoder.java b/src/main/java/org/traccar/geocoder/NominatimGeocoder.java
index 8db25bf15..b731549f7 100644
--- a/src/main/java/org/traccar/geocoder/NominatimGeocoder.java
+++ b/src/main/java/org/traccar/geocoder/NominatimGeocoder.java
@@ -16,6 +16,7 @@
package org.traccar.geocoder;
import javax.json.JsonObject;
+import javax.ws.rs.client.Client;
public class NominatimGeocoder extends JsonGeocoder {
@@ -33,8 +34,9 @@ public class NominatimGeocoder extends JsonGeocoder {
return url;
}
- public NominatimGeocoder(String url, String key, String language, int cacheSize, AddressFormat addressFormat) {
- super(formatUrl(url, key, language), cacheSize, addressFormat);
+ public NominatimGeocoder(
+ Client client, String url, String key, String language, int cacheSize, AddressFormat addressFormat) {
+ super(client, formatUrl(url, key, language), cacheSize, addressFormat);
}
@Override
diff --git a/src/main/java/org/traccar/geocoder/OpenCageGeocoder.java b/src/main/java/org/traccar/geocoder/OpenCageGeocoder.java
index bbcc00cd0..fb61440aa 100644
--- a/src/main/java/org/traccar/geocoder/OpenCageGeocoder.java
+++ b/src/main/java/org/traccar/geocoder/OpenCageGeocoder.java
@@ -18,6 +18,7 @@ package org.traccar.geocoder;
import javax.json.JsonArray;
import javax.json.JsonObject;
+import javax.ws.rs.client.Client;
public class OpenCageGeocoder extends JsonGeocoder {
@@ -32,8 +33,9 @@ public class OpenCageGeocoder extends JsonGeocoder {
return url;
}
- public OpenCageGeocoder(String url, String key, String language, int cacheSize, AddressFormat addressFormat) {
- super(formatUrl(url, key, language), cacheSize, addressFormat);
+ public OpenCageGeocoder(
+ Client client, String url, String key, String language, int cacheSize, AddressFormat addressFormat) {
+ super(client, formatUrl(url, key, language), cacheSize, addressFormat);
}
@Override
diff --git a/src/main/java/org/traccar/geocoder/PositionStackGeocoder.java b/src/main/java/org/traccar/geocoder/PositionStackGeocoder.java
index 2674a68ca..9778d9eda 100644
--- a/src/main/java/org/traccar/geocoder/PositionStackGeocoder.java
+++ b/src/main/java/org/traccar/geocoder/PositionStackGeocoder.java
@@ -17,6 +17,7 @@ package org.traccar.geocoder;
import javax.json.JsonArray;
import javax.json.JsonObject;
+import javax.ws.rs.client.Client;
public class PositionStackGeocoder extends JsonGeocoder {
@@ -24,8 +25,8 @@ public class PositionStackGeocoder extends JsonGeocoder {
return "http://api.positionstack.com/v1/reverse?access_key=" + key + "&query=%f,%f";
}
- public PositionStackGeocoder(String key, int cacheSize, AddressFormat addressFormat) {
- super(formatUrl(key), cacheSize, addressFormat);
+ public PositionStackGeocoder(Client client, String key, int cacheSize, AddressFormat addressFormat) {
+ super(client, formatUrl(key), cacheSize, addressFormat);
}
@Override
diff --git a/src/main/java/org/traccar/geocoder/TomTomGeocoder.java b/src/main/java/org/traccar/geocoder/TomTomGeocoder.java
index 232b24396..9bb36efc2 100644
--- a/src/main/java/org/traccar/geocoder/TomTomGeocoder.java
+++ b/src/main/java/org/traccar/geocoder/TomTomGeocoder.java
@@ -17,6 +17,7 @@ package org.traccar.geocoder;
import javax.json.JsonArray;
import javax.json.JsonObject;
+import javax.ws.rs.client.Client;
public class TomTomGeocoder extends JsonGeocoder {
@@ -28,8 +29,8 @@ public class TomTomGeocoder extends JsonGeocoder {
return url;
}
- public TomTomGeocoder(String url, String key, int cacheSize, AddressFormat addressFormat) {
- super(formatUrl(url, key), cacheSize, addressFormat);
+ public TomTomGeocoder(Client client, String url, String key, int cacheSize, AddressFormat addressFormat) {
+ super(client, formatUrl(url, key), cacheSize, addressFormat);
}
@Override