aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/geocode/MapQuestReverseGeocoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/geocode/MapQuestReverseGeocoder.java')
-rw-r--r--src/org/traccar/geocode/MapQuestReverseGeocoder.java58
1 files changed, 27 insertions, 31 deletions
diff --git a/src/org/traccar/geocode/MapQuestReverseGeocoder.java b/src/org/traccar/geocode/MapQuestReverseGeocoder.java
index e1ed18918..a815ca40f 100644
--- a/src/org/traccar/geocode/MapQuestReverseGeocoder.java
+++ b/src/org/traccar/geocode/MapQuestReverseGeocoder.java
@@ -30,39 +30,35 @@ public class MapQuestReverseGeocoder extends JsonReverseGeocoder {
@Override
protected Address parseAddress(JsonObject json) {
- JsonArray result = json.getJsonArray("results");
+ JsonArray result = json.getJsonArray("results");
if (result != null) {
- JsonObject result1 = result.getJsonObject(0);
- JsonArray location = result1.getJsonArray("locations");
- if (location != null) {
- JsonObject location1 = location.getJsonObject(0);
-
- Address address = new Address();
+ JsonArray locations = result.getJsonObject(0).getJsonArray("locations");
+ if (locations != null) {
+ JsonObject location = locations.getJsonObject(0);
+
+ Address address = new Address();
- if (location1.containsKey("street")) {
- address.setStreet(location1.getString("street"));
- }
-
- if (location1.containsKey("adminArea5")) {
- address.setSettlement(location1.getString("adminArea5"));
- }
-
- if (location1.containsKey("adminArea4")) {
- address.setDistrict(location1.getString("adminArea4"));
- }
-
- if (location1.containsKey("adminArea3")) {
- address.setState(location1.getString("adminArea3"));
- }
-
- if (location1.containsKey("adminArea1")) {
- address.setCountry(location1.getString("adminArea1").toUpperCase());
- }
-
- if (location1.containsKey("postalCode")) {
- address.setPostcode(location1.getString("postalCode"));
- } return address;
- }
+ if (location.containsKey("street")) {
+ address.setStreet(location.getString("street"));
+ }
+ if (location.containsKey("adminArea5")) {
+ address.setSettlement(location.getString("adminArea5"));
+ }
+ if (location.containsKey("adminArea4")) {
+ address.setDistrict(location.getString("adminArea4"));
+ }
+ if (location.containsKey("adminArea3")) {
+ address.setState(location.getString("adminArea3"));
+ }
+ if (location.containsKey("adminArea1")) {
+ address.setCountry(location.getString("adminArea1").toUpperCase());
+ }
+ if (location.containsKey("postalCode")) {
+ address.setPostcode(location.getString("postalCode"));
+ }
+
+ return address;
+ }
}
return null;
}