aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-02-15 21:50:18 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2020-02-15 21:50:18 -0800
commitb6fe2bd75a3541d6fe63a6b6161ed04b773e37a6 (patch)
tree0e81721d5fe8279968c6a7c916a8c28a9f2f300f /src/main
parent81858280f7477da619aaf1adca972827847b47cb (diff)
downloadtraccar-server-b6fe2bd75a3541d6fe63a6b6161ed04b773e37a6.tar.gz
traccar-server-b6fe2bd75a3541d6fe63a6b6161ed04b773e37a6.tar.bz2
traccar-server-b6fe2bd75a3541d6fe63a6b6161ed04b773e37a6.zip
Provide default URL
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/traccar/geocoder/OpenCageGeocoder.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/geocoder/OpenCageGeocoder.java b/src/main/java/org/traccar/geocoder/OpenCageGeocoder.java
index 822b6e91e..56161e52c 100644
--- a/src/main/java/org/traccar/geocoder/OpenCageGeocoder.java
+++ b/src/main/java/org/traccar/geocoder/OpenCageGeocoder.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 OpenCageGeocoder extends JsonGeocoder {
+ private static String formatUrl(String url, String key) {
+ if (url == null) {
+ url = "https://api.opencagedata.com/geocode/v1";
+ }
+ url += "/json?q=%f,%f&no_annotations=1&key=" + key;
+ return url;
+ }
+
public OpenCageGeocoder(String url, String key, int cacheSize, AddressFormat addressFormat) {
- super(url + "/json?q=%f,%f&no_annotations=1&key=" + key, cacheSize, addressFormat);
+ super(formatUrl(url, key), cacheSize, addressFormat);
}
@Override