aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/geocoder/Address.java10
-rw-r--r--src/org/traccar/geocoder/AddressFormat.java1
-rw-r--r--src/org/traccar/geocoder/BingMapsGeocoder.java3
-rw-r--r--src/org/traccar/geocoder/GeocodeFarmGeocoder.java28
-rw-r--r--src/org/traccar/geocoder/GisgraphyGeocoder.java3
-rw-r--r--src/org/traccar/geocoder/GoogleGeocoder.java4
-rw-r--r--src/org/traccar/geocoder/NominatimGeocoder.java5
-rw-r--r--src/org/traccar/geocoder/OpenCageGeocoder.java3
8 files changed, 45 insertions, 12 deletions
diff --git a/src/org/traccar/geocoder/Address.java b/src/org/traccar/geocoder/Address.java
index d542d1b19..fe39da8e1 100644
--- a/src/org/traccar/geocoder/Address.java
+++ b/src/org/traccar/geocoder/Address.java
@@ -97,4 +97,14 @@ public class Address {
this.house = house;
}
+ private String formattedAddress;
+
+ public String getFormattedAddress() {
+ return formattedAddress;
+ }
+
+ public void setFormattedAddress(String formattedAddress) {
+ this.formattedAddress = formattedAddress;
+ }
+
}
diff --git a/src/org/traccar/geocoder/AddressFormat.java b/src/org/traccar/geocoder/AddressFormat.java
index 0800d6dcc..220f268f1 100644
--- a/src/org/traccar/geocoder/AddressFormat.java
+++ b/src/org/traccar/geocoder/AddressFormat.java
@@ -66,6 +66,7 @@ public class AddressFormat extends Format {
result = replace(result, "%u", address.getSuburb());
result = replace(result, "%r", address.getStreet());
result = replace(result, "%h", address.getHouse());
+ result = replace(result, "%f", address.getFormattedAddress());
result = result.replaceAll("^[, ]*", "");
diff --git a/src/org/traccar/geocoder/BingMapsGeocoder.java b/src/org/traccar/geocoder/BingMapsGeocoder.java
index fbfb5394a..32a26ee0c 100644
--- a/src/org/traccar/geocoder/BingMapsGeocoder.java
+++ b/src/org/traccar/geocoder/BingMapsGeocoder.java
@@ -51,6 +51,9 @@ public class BingMapsGeocoder extends JsonGeocoder {
if (location.containsKey("postalCode")) {
address.setPostcode(location.getString("postalCode"));
}
+ if (location.containsKey("formattedAddress")) {
+ address.setFormattedAddress(location.getString("formattedAddress"));
+ }
return address;
}
}
diff --git a/src/org/traccar/geocoder/GeocodeFarmGeocoder.java b/src/org/traccar/geocoder/GeocodeFarmGeocoder.java
index 4fb956af9..39a3300a0 100644
--- a/src/org/traccar/geocoder/GeocodeFarmGeocoder.java
+++ b/src/org/traccar/geocoder/GeocodeFarmGeocoder.java
@@ -41,23 +41,27 @@ public class GeocodeFarmGeocoder extends JsonGeocoder {
JsonObject result = json
.getJsonObject("geocoding_results")
.getJsonArray("RESULTS")
- .getJsonObject(0)
- .getJsonObject("ADDRESS");
+ .getJsonObject(0);
- if (result.containsKey("street_number")) {
- address.setStreet(result.getString("street_number"));
+ JsonObject resultAddress = result.getJsonObject("ADDRESS");
+
+ if (result.containsKey("formatted_address")) {
+ address.setFormattedAddress(result.getString("formatted_address"));
+ }
+ if (resultAddress.containsKey("street_number")) {
+ address.setStreet(resultAddress.getString("street_number"));
}
- if (result.containsKey("street_name")) {
- address.setStreet(result.getString("street_name"));
+ if (resultAddress.containsKey("street_name")) {
+ address.setStreet(resultAddress.getString("street_name"));
}
- if (result.containsKey("locality")) {
- address.setSettlement(result.getString("locality"));
+ if (resultAddress.containsKey("locality")) {
+ address.setSettlement(resultAddress.getString("locality"));
}
- if (result.containsKey("admin_1")) {
- address.setState(result.getString("admin_1"));
+ if (resultAddress.containsKey("admin_1")) {
+ address.setState(resultAddress.getString("admin_1"));
}
- if (result.containsKey("country")) {
- address.setCountry(result.getString("country"));
+ if (resultAddress.containsKey("country")) {
+ address.setCountry(resultAddress.getString("country"));
}
return address;
diff --git a/src/org/traccar/geocoder/GisgraphyGeocoder.java b/src/org/traccar/geocoder/GisgraphyGeocoder.java
index a0c831966..3a173f985 100644
--- a/src/org/traccar/geocoder/GisgraphyGeocoder.java
+++ b/src/org/traccar/geocoder/GisgraphyGeocoder.java
@@ -45,6 +45,9 @@ public class GisgraphyGeocoder extends JsonGeocoder {
if (result.containsKey("countryCode")) {
address.setCountry(result.getString("countryCode"));
}
+ if (result.containsKey("formatedFull")) {
+ address.setFormattedAddress(result.getString("formatedFull"));
+ }
return address;
}
diff --git a/src/org/traccar/geocoder/GoogleGeocoder.java b/src/org/traccar/geocoder/GoogleGeocoder.java
index 235ea9ea9..af9b58a90 100644
--- a/src/org/traccar/geocoder/GoogleGeocoder.java
+++ b/src/org/traccar/geocoder/GoogleGeocoder.java
@@ -46,6 +46,10 @@ public class GoogleGeocoder extends JsonGeocoder {
JsonObject result = (JsonObject) results.get(0);
JsonArray components = result.getJsonArray("address_components");
+ if (result.containsKey("formatted_address")) {
+ address.setFormattedAddress(result.getString("formatted_address"));
+ }
+
for (JsonObject component : components.getValuesAs(JsonObject.class)) {
String value = component.getString("short_name");
diff --git a/src/org/traccar/geocoder/NominatimGeocoder.java b/src/org/traccar/geocoder/NominatimGeocoder.java
index 75d2e9f99..39ab07fae 100644
--- a/src/org/traccar/geocoder/NominatimGeocoder.java
+++ b/src/org/traccar/geocoder/NominatimGeocoder.java
@@ -44,6 +44,11 @@ public class NominatimGeocoder extends JsonGeocoder {
if (result != null) {
Address address = new Address();
+
+ if (json.containsKey("display_name")) {
+ address.setFormattedAddress(json.getString("display_name"));
+ }
+
if (result.containsKey("house_number")) {
address.setHouse(result.getString("house_number"));
}
diff --git a/src/org/traccar/geocoder/OpenCageGeocoder.java b/src/org/traccar/geocoder/OpenCageGeocoder.java
index 894397ee3..c21d5562a 100644
--- a/src/org/traccar/geocoder/OpenCageGeocoder.java
+++ b/src/org/traccar/geocoder/OpenCageGeocoder.java
@@ -33,6 +33,9 @@ public class OpenCageGeocoder extends JsonGeocoder {
if (location != null) {
Address address = new Address();
+ if (result.getJsonObject(0).containsKey("formatted")) {
+ address.setFormattedAddress(result.getJsonObject(0).getString("formatted"));
+ }
if (location.containsKey("building")) {
address.setHouse(location.getString("building"));
}