aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/geocoder
diff options
context:
space:
mode:
authorChristoph Krey <c@ckrey.de>2018-04-16 10:45:11 +0200
committerGitHub <noreply@github.com>2018-04-16 10:45:11 +0200
commit3a602dd133b533cc69d5986d64a00fb3ed670f75 (patch)
tree97ff753db310a49ae7e53240b1db07fb8475679e /src/org/traccar/geocoder
parent232de5f0daef98f31b28d177d991fdbfa191f195 (diff)
parent6d4b8df25c7e942b9ad594db9444fe15bcb16be9 (diff)
downloadtrackermap-server-3a602dd133b533cc69d5986d64a00fb3ed670f75.tar.gz
trackermap-server-3a602dd133b533cc69d5986d64a00fb3ed670f75.tar.bz2
trackermap-server-3a602dd133b533cc69d5986d64a00fb3ed670f75.zip
Merge pull request #4 from traccar/master
upgrade to current master
Diffstat (limited to 'src/org/traccar/geocoder')
-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.java4
-rw-r--r--src/org/traccar/geocoder/OpenCageGeocoder.java3
8 files changed, 44 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..c0142ae27 100644
--- a/src/org/traccar/geocoder/NominatimGeocoder.java
+++ b/src/org/traccar/geocoder/NominatimGeocoder.java
@@ -44,6 +44,10 @@ 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"));
}