aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-06-24 14:01:04 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-06-24 14:01:04 +1200
commitf246be19c40bd0d80c845a54f08910e982051f1f (patch)
tree51c0629e0e537fdea45bbe35bf5e81f58bd50f05
parent3525c769141992d754aea45e2a2d6cc576f45842 (diff)
downloadtraccar-server-f246be19c40bd0d80c845a54f08910e982051f1f.tar.gz
traccar-server-f246be19c40bd0d80c845a54f08910e982051f1f.tar.bz2
traccar-server-f246be19c40bd0d80c845a54f08910e982051f1f.zip
Handle no result from Nominatim
-rw-r--r--src/org/traccar/geocode/NominatimReverseGeocoder.java55
1 files changed, 30 insertions, 25 deletions
diff --git a/src/org/traccar/geocode/NominatimReverseGeocoder.java b/src/org/traccar/geocode/NominatimReverseGeocoder.java
index 6777f5a82..27c241c66 100644
--- a/src/org/traccar/geocode/NominatimReverseGeocoder.java
+++ b/src/org/traccar/geocode/NominatimReverseGeocoder.java
@@ -39,35 +39,40 @@ public class NominatimReverseGeocoder extends JsonReverseGeocoder {
@Override
protected Address parseAddress(JsonObject json) {
- Address address = new Address();
JsonObject result = json.getJsonObject("address");
- if (result.containsKey("house_number")) {
- address.setHouse(result.getString("house_number"));
- }
- if (result.containsKey("road")) {
- address.setStreet(result.getString("road"));
- }
- if (result.containsKey("village")) {
- address.setSettlement(result.getString("village"));
- }
- if (result.containsKey("city")) {
- address.setSettlement(result.getString("city"));
- }
- if (result.containsKey("state_district")) {
- address.setDistrict(result.getString("state_district"));
- }
- if (result.containsKey("state")) {
- address.setState(result.getString("state"));
- }
- if (result.containsKey("country_code")) {
- address.setCountry(result.getString("country_code").toUpperCase());
- }
- if (result.containsKey("postcode")) {
- address.setPostcode(result.getString("postcode"));
+ if (result != null) {
+ Address address = new Address();
+
+ if (result.containsKey("house_number")) {
+ address.setHouse(result.getString("house_number"));
+ }
+ if (result.containsKey("road")) {
+ address.setStreet(result.getString("road"));
+ }
+ if (result.containsKey("village")) {
+ address.setSettlement(result.getString("village"));
+ }
+ if (result.containsKey("city")) {
+ address.setSettlement(result.getString("city"));
+ }
+ if (result.containsKey("state_district")) {
+ address.setDistrict(result.getString("state_district"));
+ }
+ if (result.containsKey("state")) {
+ address.setState(result.getString("state"));
+ }
+ if (result.containsKey("country_code")) {
+ address.setCountry(result.getString("country_code").toUpperCase());
+ }
+ if (result.containsKey("postcode")) {
+ address.setPostcode(result.getString("postcode"));
+ }
+
+ return address;
}
- return address;
+ return null;
}
}