aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/traccar/geocoder/FactualGeocoder.java12
-rw-r--r--src/main/java/org/traccar/geocoder/GisgraphyGeocoder.java12
-rw-r--r--src/main/java/org/traccar/geocoder/MapQuestGeocoder.java12
-rw-r--r--src/test/java/org/traccar/geocoder/GeocoderTest.java2
4 files changed, 29 insertions, 9 deletions
diff --git a/src/main/java/org/traccar/geocoder/FactualGeocoder.java b/src/main/java/org/traccar/geocoder/FactualGeocoder.java
index c7a68c293..f540eb8fe 100644
--- a/src/main/java/org/traccar/geocoder/FactualGeocoder.java
+++ b/src/main/java/org/traccar/geocoder/FactualGeocoder.java
@@ -1,6 +1,6 @@
/*
* Copyright 2014 - 2015 Stefaan Van Dooren (stefaan.vandooren@gmail.com)
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2020 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.
@@ -20,8 +20,16 @@ import javax.json.JsonObject;
public class FactualGeocoder extends JsonGeocoder {
+ private static String formatUrl(String url, String key) {
+ if (url == null) {
+ url = "https://api.factual.com/geotag";
+ }
+ url += "?latitude=%f&longitude=%f&KEY=" + key;
+ return url;
+ }
+
public FactualGeocoder(String url, String key, int cacheSize, AddressFormat addressFormat) {
- super(url + "?latitude=%f&longitude=%f&KEY=" + key, cacheSize, addressFormat);
+ super(formatUrl(url, 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 3a173f985..b4881a006 100644
--- a/src/main/java/org/traccar/geocoder/GisgraphyGeocoder.java
+++ b/src/main/java/org/traccar/geocoder/GisgraphyGeocoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2020 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.
@@ -19,12 +19,16 @@ import javax.json.JsonObject;
public class GisgraphyGeocoder extends JsonGeocoder {
- public GisgraphyGeocoder(AddressFormat addressFormat) {
- this("http://services.gisgraphy.com/reversegeocoding/search", 0, addressFormat);
+ private static String formatUrl(String url) {
+ if (url == null) {
+ url = "http://services.gisgraphy.com/reversegeocoding/search";
+ }
+ url += "?format=json&lat=%f&lng=%f&from=1&to=1";
+ return url;
}
public GisgraphyGeocoder(String url, int cacheSize, AddressFormat addressFormat) {
- super(url + "?format=json&lat=%f&lng=%f&from=1&to=1", cacheSize, addressFormat);
+ super(formatUrl(url), cacheSize, addressFormat);
}
@Override
diff --git a/src/main/java/org/traccar/geocoder/MapQuestGeocoder.java b/src/main/java/org/traccar/geocoder/MapQuestGeocoder.java
index 4029e3f07..8dc3f76f0 100644
--- a/src/main/java/org/traccar/geocoder/MapQuestGeocoder.java
+++ b/src/main/java/org/traccar/geocoder/MapQuestGeocoder.java
@@ -1,6 +1,6 @@
/*
* Copyright 2014 - 2015 Stefaan Van Dooren (stefaan.vandooren@gmail.com)
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2020 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.
@@ -21,8 +21,16 @@ import javax.json.JsonObject;
public class MapQuestGeocoder extends JsonGeocoder {
+ private static String formatUrl(String url, String key) {
+ if (url == null) {
+ url = "http://www.mapquestapi.com/geocoding/v1/reverse";
+ }
+ url += "?key=" + key + "&location=%f,%f";
+ return url;
+ }
+
public MapQuestGeocoder(String url, String key, int cacheSize, AddressFormat addressFormat) {
- super(url + "?key=" + key + "&location=%f,%f", cacheSize, addressFormat);
+ super(formatUrl(url, key), cacheSize, addressFormat);
}
@Override
diff --git a/src/test/java/org/traccar/geocoder/GeocoderTest.java b/src/test/java/org/traccar/geocoder/GeocoderTest.java
index 9f59d0b23..e70719b89 100644
--- a/src/test/java/org/traccar/geocoder/GeocoderTest.java
+++ b/src/test/java/org/traccar/geocoder/GeocoderTest.java
@@ -32,7 +32,7 @@ public class GeocoderTest {
@Ignore
@Test
public void testGisgraphy() {
- Geocoder geocoder = new GisgraphyGeocoder(new AddressFormat());
+ Geocoder geocoder = new GisgraphyGeocoder(null, 0, new AddressFormat());
String address = geocoder.getAddress(48.8530000, 2.3400000, null);
assertEquals("Rue du Jardinet, Paris, Île-de-France, FR", address);
}