diff options
author | Ed Freyfogle <freyfogle@users.noreply.github.com> | 2022-03-24 11:28:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-24 11:28:14 +0100 |
commit | c84ab2c13e5529c34e0acf48304618659b427985 (patch) | |
tree | 3c9f477fba53334d71dcedd9755df670757305ec /src/main | |
parent | 2c5d65c30159b620eebce8dd7b8a768c06271031 (diff) | |
download | trackermap-server-c84ab2c13e5529c34e0acf48304618659b427985.tar.gz trackermap-server-c84ab2c13e5529c34e0acf48304618659b427985.tar.bz2 trackermap-server-c84ab2c13e5529c34e0acf48304618659b427985.zip |
support language param, if null defaults to "en"
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/traccar/geocoder/OpenCageGeocoder.java | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/geocoder/OpenCageGeocoder.java b/src/main/java/org/traccar/geocoder/OpenCageGeocoder.java index 56161e52c..18cf3a715 100644 --- a/src/main/java/org/traccar/geocoder/OpenCageGeocoder.java +++ b/src/main/java/org/traccar/geocoder/OpenCageGeocoder.java @@ -21,16 +21,21 @@ import javax.json.JsonObject; public class OpenCageGeocoder extends JsonGeocoder { - private static String formatUrl(String url, String key) { + private static String formatUrl(String url, String key, String language) { if (url == null) { url = "https://api.opencagedata.com/geocode/v1"; } url += "/json?q=%f,%f&no_annotations=1&key=" + key; + if (language != null) { + url += "&language=" + language; + } else { + url += "&language=en"; + } return url; } - public OpenCageGeocoder(String url, String key, int cacheSize, AddressFormat addressFormat) { - super(formatUrl(url, key), cacheSize, addressFormat); + public OpenCageGeocoder(String url, String key, String language, int cacheSize, AddressFormat addressFormat) { + super(formatUrl(url, key, language), cacheSize, addressFormat); } @Override |