aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-10-30 13:57:03 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-10-30 13:57:03 +1300
commita045472079bb83bb318605d65bac45bb575b29c3 (patch)
tree9da9e32108ba2d1f4fad6ddc0c854707f3e84eef
parentbe088ea967dfe7d1a7de3ec824382afc92aab128 (diff)
downloadtraccar-server-a045472079bb83bb318605d65bac45bb575b29c3.tar.gz
traccar-server-a045472079bb83bb318605d65bac45bb575b29c3.tar.bz2
traccar-server-a045472079bb83bb318605d65bac45bb575b29c3.zip
Add suburb to address class
-rw-r--r--src/org/traccar/geocode/Address.java10
-rw-r--r--src/org/traccar/geocode/AddressFormat.java2
-rw-r--r--src/org/traccar/geocode/NominatimReverseGeocoder.java13
3 files changed, 23 insertions, 2 deletions
diff --git a/src/org/traccar/geocode/Address.java b/src/org/traccar/geocode/Address.java
index 68c41b356..144a49474 100644
--- a/src/org/traccar/geocode/Address.java
+++ b/src/org/traccar/geocode/Address.java
@@ -67,6 +67,16 @@ public class Address {
this.settlement = settlement;
}
+ private String suburb;
+
+ public String getSuburb() {
+ return suburb;
+ }
+
+ public void setSuburb(String suburb) {
+ this.suburb = suburb;
+ }
+
private String street;
public String getStreet() {
diff --git a/src/org/traccar/geocode/AddressFormat.java b/src/org/traccar/geocode/AddressFormat.java
index a90de8c5e..a2a0862bf 100644
--- a/src/org/traccar/geocode/AddressFormat.java
+++ b/src/org/traccar/geocode/AddressFormat.java
@@ -27,6 +27,7 @@ import java.text.ParsePosition;
* %s - state
* %d - district
* %t - settlement (town)
+ * %u - suburb
* %r - street (road)
* %h - house
*
@@ -62,6 +63,7 @@ public class AddressFormat extends Format {
result = replace(result, "%s", address.getState());
result = replace(result, "%d", address.getDistrict());
result = replace(result, "%t", address.getSettlement());
+ result = replace(result, "%u", address.getSuburb());
result = replace(result, "%r", address.getStreet());
result = replace(result, "%h", address.getHouse());
diff --git a/src/org/traccar/geocode/NominatimReverseGeocoder.java b/src/org/traccar/geocode/NominatimReverseGeocoder.java
index 933d9389c..c1481d1cb 100644
--- a/src/org/traccar/geocode/NominatimReverseGeocoder.java
+++ b/src/org/traccar/geocode/NominatimReverseGeocoder.java
@@ -40,15 +40,24 @@ public class NominatimReverseGeocoder extends JsonReverseGeocoder {
if (result.containsKey("road")) {
address.setStreet(result.getString("road"));
}
+ if (result.containsKey("suburb")) {
+ address.setSuburb(result.getString("suburb"));
+ }
+
if (result.containsKey("village")) {
address.setSettlement(result.getString("village"));
- }
- if (result.containsKey("city")) {
+ } else if (result.containsKey("town")) {
+ address.setSettlement(result.getString("town"));
+ } else if (result.containsKey("city")) {
address.setSettlement(result.getString("city"));
}
+
if (result.containsKey("state_district")) {
address.setDistrict(result.getString("state_district"));
+ } else if (result.containsKey("region")) {
+ address.setDistrict(result.getString("region"));
}
+
if (result.containsKey("state")) {
address.setState(result.getString("state"));
}