aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2024-07-26 19:12:47 -0700
committerGitHub <noreply@github.com>2024-07-26 19:12:47 -0700
commit77ef23b40f71098ab5ff1f24e93189f2de622349 (patch)
tree66333d8cacb36fc5efa2fd49dc1322dadd3981eb /src
parent62f1cb5cd3374ac0012c9c054f3556c5e43a8549 (diff)
parentb0ccb8127a92fe72191050cae6ad9c83af24e458 (diff)
downloadtrackermap-server-77ef23b40f71098ab5ff1f24e93189f2de622349.tar.gz
trackermap-server-77ef23b40f71098ab5ff1f24e93189f2de622349.tar.bz2
trackermap-server-77ef23b40f71098ab5ff1f24e93189f2de622349.zip
Merge pull request #5371 from mujeerhashmi/feat_olamaps_geocoder
geocoder: Implement OlaMaps Reverse geocoder
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/MainModule.java2
-rw-r--r--src/main/java/org/traccar/geocoder/GoogleGeocoder.java11
-rw-r--r--src/test/java/org/traccar/geocoder/GeocoderTest.java2
3 files changed, 9 insertions, 6 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..174ef66c8 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,9 @@ 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
diff --git a/src/test/java/org/traccar/geocoder/GeocoderTest.java b/src/test/java/org/traccar/geocoder/GeocoderTest.java
index 3e65d20c7..2aa7ab77c 100644
--- a/src/test/java/org/traccar/geocoder/GeocoderTest.java
+++ b/src/test/java/org/traccar/geocoder/GeocoderTest.java
@@ -20,7 +20,7 @@ public class GeocoderTest {
@Disabled
@Test
public void testGoogle() {
- Geocoder geocoder = new GoogleGeocoder(client, null, null, 0, new AddressFormat());
+ Geocoder geocoder = new GoogleGeocoder(client, null, null, null, 0, new AddressFormat());
String address = geocoder.getAddress(31.776797, 35.211489, null);
assertEquals("1 Ibn Shaprut St, Jerusalem, Jerusalem District, IL", address);
}