aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org
diff options
context:
space:
mode:
authorSyed Mujeer Hashmi <mujeerhashmi@4csolutions.in>2024-07-25 22:06:25 +0530
committerSyed Mujeer Hashmi <mujeerhashmi@4csolutions.in>2024-07-26 23:11:16 +0530
commitadeb0ef3de976d185b6f61668f0cbd9fdffee801 (patch)
treefa0e8c65df459200277ce026752a56707156eb11 /src/main/java/org
parent4620fc2db16f05bcd3578b4f5a3239b229d7c99f (diff)
downloadtrackermap-server-adeb0ef3de976d185b6f61668f0cbd9fdffee801.tar.gz
trackermap-server-adeb0ef3de976d185b6f61668f0cbd9fdffee801.tar.bz2
trackermap-server-adeb0ef3de976d185b6f61668f0cbd9fdffee801.zip
geocoder: custom url for google based geocoder
Signed-off-by: Syed Mujeer Hashmi <mujeerhashmi@4csolutions.in>
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/traccar/MainModule.java2
-rw-r--r--src/main/java/org/traccar/geocoder/GoogleGeocoder.java10
2 files changed, 7 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/MainModule.java b/src/main/java/org/traccar/MainModule.java
index c7b74d049..945bb8bc2 100644
--- a/src/main/java/org/traccar/MainModule.java
+++ b/src/main/java/org/traccar/MainModule.java
@@ -226,7 +226,7 @@ public class MainModule extends AbstractModule {
case "maptiler" -> new MapTilerGeocoder(client, key, cacheSize, addressFormat);
case "geoapify" -> new GeoapifyGeocoder(client, key, language, cacheSize, addressFormat);
case "geocodejson" -> new GeocodeJsonGeocoder(client, url, key, language, cacheSize, addressFormat);
- default -> new GoogleGeocoder(client, key, language, cacheSize, addressFormat);
+ default -> new GoogleGeocoder(client, url, key, language, cacheSize, addressFormat);
};
geocoder.setStatisticsManager(statisticsManager);
return geocoder;
diff --git a/src/main/java/org/traccar/geocoder/GoogleGeocoder.java b/src/main/java/org/traccar/geocoder/GoogleGeocoder.java
index 93f128b46..40951742f 100644
--- a/src/main/java/org/traccar/geocoder/GoogleGeocoder.java
+++ b/src/main/java/org/traccar/geocoder/GoogleGeocoder.java
@@ -22,8 +22,10 @@ import jakarta.ws.rs.client.Client;
public class GoogleGeocoder extends JsonGeocoder {
- private static String formatUrl(String key, String language) {
- String url = "https://maps.googleapis.com/maps/api/geocode/json?latlng=%f,%f";
+ private static String formatUrl(String url, String key, String language) {
+ if (url == null) {
+ url = "https://maps.googleapis.com/maps/api/geocode/json?latlng=%f,%f";
+ }
if (key != null) {
url += "&key=" + key;
}
@@ -33,8 +35,8 @@ public class GoogleGeocoder extends JsonGeocoder {
return url;
}
- public GoogleGeocoder(Client client, String key, String language, int cacheSize, AddressFormat addressFormat) {
- super(client, formatUrl(key, language), cacheSize, addressFormat);
+ public GoogleGeocoder(Client client, String url, String key, String language, int cacheSize, AddressFormat addressFormat) {
+ super(client, formatUrl(url, key, language), cacheSize, addressFormat);
}
@Override