aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/Context.java2
-rw-r--r--src/org/traccar/geocoder/GeocodeFarmGeocoder.java10
-rw-r--r--src/org/traccar/geocoder/NominatimGeocoder.java1
-rw-r--r--test/org/traccar/geocoder/GeocoderTest.java2
-rw-r--r--test/org/traccar/protocol/PricolProtocolDecoderTest.java3
5 files changed, 13 insertions, 5 deletions
diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java
index 27e61d32d..daabb8c32 100644
--- a/src/org/traccar/Context.java
+++ b/src/org/traccar/Context.java
@@ -232,7 +232,7 @@ public final class Context {
geocoder = new FactualGeocoder(url, key, cacheSize);
break;
case "geocodefarm":
- geocoder = new GeocodeFarmGeocoder(key, cacheSize);
+ geocoder = new GeocodeFarmGeocoder(key, language, cacheSize);
break;
default:
geocoder = new GoogleGeocoder(key, language, cacheSize);
diff --git a/src/org/traccar/geocoder/GeocodeFarmGeocoder.java b/src/org/traccar/geocoder/GeocodeFarmGeocoder.java
index db23aab79..73ff85aa4 100644
--- a/src/org/traccar/geocoder/GeocodeFarmGeocoder.java
+++ b/src/org/traccar/geocoder/GeocodeFarmGeocoder.java
@@ -19,15 +19,19 @@ import javax.json.JsonObject;
public class GeocodeFarmGeocoder extends JsonGeocoder {
- private static String formatUrl(String key) {
+ private static String formatUrl(String key, String language) {
String url = "https://www.geocode.farm/v3/json/reverse/";
+ url += "?lat=%f&lon=%f&country=us&count=1";
if (key != null) {
url += "&key=" + key;
}
+ if (language != null) {
+ url += "&lang=" + language;
+ }
return url;
}
- public GeocodeFarmGeocoder(String key, int cacheSize) {
- super(formatUrl(key), cacheSize);
+ public GeocodeFarmGeocoder(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 c10a1414e..4f33468fd 100644
--- a/src/org/traccar/geocoder/NominatimGeocoder.java
+++ b/src/org/traccar/geocoder/NominatimGeocoder.java
@@ -23,6 +23,7 @@ public class NominatimGeocoder extends JsonGeocoder {
if (url == null) {
url = "http://nominatim.openstreetmap.org/reverse";
}
+ url += "?format=json&lat=%f&lon=%f&zoom=18&addressdetails=1";
if (key != null) {
url += "&key=" + key;
}
diff --git a/test/org/traccar/geocoder/GeocoderTest.java b/test/org/traccar/geocoder/GeocoderTest.java
index a5aecc8cf..6f4fc1710 100644
--- a/test/org/traccar/geocoder/GeocoderTest.java
+++ b/test/org/traccar/geocoder/GeocoderTest.java
@@ -94,7 +94,7 @@ public class GeocoderTest {
}
public void testGeocodeFarm() throws InterruptedException {
- Geocoder geocoder = new GeocodeFarmGeocoder(null, 0);
+ Geocoder geocoder = new GeocodeFarmGeocoder(null, null, 0);
geocoder.getAddress(new AddressFormat(), 34.116302, -118.051519, new Geocoder.ReverseGeocoderCallback() {
@Override
diff --git a/test/org/traccar/protocol/PricolProtocolDecoderTest.java b/test/org/traccar/protocol/PricolProtocolDecoderTest.java
index 3826d56c4..0c792a8ec 100644
--- a/test/org/traccar/protocol/PricolProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/PricolProtocolDecoderTest.java
@@ -10,6 +10,9 @@ public class PricolProtocolDecoderTest extends ProtocolTest {
PricolProtocolDecoder decoder = new PricolProtocolDecoder(new PricolProtocol());
+ verifyPosition(decoder, binary(
+ "3c5052493030303350020000011402110b222b0455152e4e001de819ca450000000000000003820249000000000000000000000000000000000000000040003e"));
+
verifyNotNull(decoder, binary(
"3c544553303030324b02000000000000000000000000000000000000000000000000000000037c01f4000000000000000000000000000000000000000000003e"));