diff options
author | jon-stumpf <jon.stumpf@gmail.com> | 2017-02-20 10:54:34 -0500 |
---|---|---|
committer | jon-stumpf <jon.stumpf@gmail.com> | 2017-02-20 10:54:34 -0500 |
commit | 888c392af40187f3a0ecc3395495db9acd85b827 (patch) | |
tree | beb74dff8b8052ffb4a7d3c894b2b4e5a4434973 /src/org/traccar/geocoder | |
parent | 38249673287b908c0ca55847a35ca16a7b6a0c50 (diff) | |
parent | 2449895139fa658d082c1085185003a001225bc3 (diff) | |
download | trackermap-server-888c392af40187f3a0ecc3395495db9acd85b827.tar.gz trackermap-server-888c392af40187f3a0ecc3395495db9acd85b827.tar.bz2 trackermap-server-888c392af40187f3a0ecc3395495db9acd85b827.zip |
Resolved conflict with master;
Diffstat (limited to 'src/org/traccar/geocoder')
-rw-r--r-- | src/org/traccar/geocoder/GeocodeFarmGeocoder.java | 13 | ||||
-rw-r--r-- | src/org/traccar/geocoder/GoogleGeocoder.java | 19 | ||||
-rw-r--r-- | src/org/traccar/geocoder/NominatimGeocoder.java | 16 |
3 files changed, 27 insertions, 21 deletions
diff --git a/src/org/traccar/geocoder/GeocodeFarmGeocoder.java b/src/org/traccar/geocoder/GeocodeFarmGeocoder.java index 585095606..db23aab79 100644 --- a/src/org/traccar/geocoder/GeocodeFarmGeocoder.java +++ b/src/org/traccar/geocoder/GeocodeFarmGeocoder.java @@ -19,14 +19,15 @@ import javax.json.JsonObject; public class GeocodeFarmGeocoder extends JsonGeocoder { - private static final String URL = "https://www.geocode.farm/v3/json/reverse/"; - - public GeocodeFarmGeocoder(int cacheSize) { - super(URL + "?lat=%f&lon=%f&country=us&lang=en&count=1", cacheSize); + private static String formatUrl(String key) { + String url = "https://www.geocode.farm/v3/json/reverse/"; + if (key != null) { + url += "&key=" + key; + } + return url; } - public GeocodeFarmGeocoder(String key, int cacheSize) { - super(URL + "?lat=%f&lon=%f&country=us&lang=en&count=1&key=" + key, cacheSize); + super(formatUrl(key), cacheSize); } @Override diff --git a/src/org/traccar/geocoder/GoogleGeocoder.java b/src/org/traccar/geocoder/GoogleGeocoder.java index 0506e701a..b38870c8f 100644 --- a/src/org/traccar/geocoder/GoogleGeocoder.java +++ b/src/org/traccar/geocoder/GoogleGeocoder.java @@ -21,16 +21,19 @@ import javax.json.JsonString; public class GoogleGeocoder extends JsonGeocoder { - public GoogleGeocoder() { - this(0); - } - - public GoogleGeocoder(int cacheSize) { - super("http://maps.googleapis.com/maps/api/geocode/json?latlng=%f,%f", cacheSize); + private static String formatUrl(String key, String language) { + String url = "https://maps.googleapis.com/maps/api/geocode/json?latlng=%f,%f"; + if (key != null) { + url += "&key=" + key; + } + if (language != null) { + url += "&language=" + language; + } + return url; } - public GoogleGeocoder(String key, int cacheSize) { - super("https://maps.googleapis.com/maps/api/geocode/json?latlng=%f,%f&key=" + key, cacheSize); + public GoogleGeocoder(String key, String language, int cacheSize) { + super(formatUrl(key, language), cacheSize); } @Override diff --git a/src/org/traccar/geocoder/NominatimGeocoder.java b/src/org/traccar/geocoder/NominatimGeocoder.java index b0ee39c6a..c10a1414e 100644 --- a/src/org/traccar/geocoder/NominatimGeocoder.java +++ b/src/org/traccar/geocoder/NominatimGeocoder.java @@ -19,16 +19,18 @@ import javax.json.JsonObject; public class NominatimGeocoder extends JsonGeocoder { - public NominatimGeocoder() { - this("http://nominatim.openstreetmap.org/reverse", 0); - } - - public NominatimGeocoder(String url, int cacheSize) { - super(url + "?format=json&lat=%f&lon=%f&zoom=18&addressdetails=1", cacheSize); + private static String formatUrl(String url, String key) { + if (url == null) { + url = "http://nominatim.openstreetmap.org/reverse"; + } + if (key != null) { + url += "&key=" + key; + } + return url; } public NominatimGeocoder(String url, String key, int cacheSize) { - super(url + "?format=json&lat=%f&lon=%f&zoom=18&addressdetails=1&key=" + key, cacheSize); + super(formatUrl(url, key), cacheSize); } @Override |