From 655d7cba4a63db2058d08f04fe5a7cdcb4067017 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 13 Mar 2016 23:58:47 +1300 Subject: Improve OpenCage reverse decoder --- src/org/traccar/geocode/BingMapsReverseGeocoder.java | 4 ---- src/org/traccar/geocode/FactualReverseGeocoder.java | 4 ---- src/org/traccar/geocode/MapQuestReverseGeocoder.java | 4 ---- src/org/traccar/geocode/OpenCageReverseGeocoder.java | 14 ++++++++++---- 4 files changed, 10 insertions(+), 16 deletions(-) (limited to 'src/org/traccar') diff --git a/src/org/traccar/geocode/BingMapsReverseGeocoder.java b/src/org/traccar/geocode/BingMapsReverseGeocoder.java index a5ebbd420..69148875a 100644 --- a/src/org/traccar/geocode/BingMapsReverseGeocoder.java +++ b/src/org/traccar/geocode/BingMapsReverseGeocoder.java @@ -20,10 +20,6 @@ import javax.json.JsonObject; public class BingMapsReverseGeocoder extends JsonReverseGeocoder { - public BingMapsReverseGeocoder() { - this("http://dev.virtualearth.net/REST/v1", "ABCDE", 0); - } - public BingMapsReverseGeocoder(String url, String key, int cacheSize) { super(url + "/Locations/%f,%f?key=" + key + "&include=ciso2", cacheSize); } diff --git a/src/org/traccar/geocode/FactualReverseGeocoder.java b/src/org/traccar/geocode/FactualReverseGeocoder.java index 6e5a48423..15211f74a 100644 --- a/src/org/traccar/geocode/FactualReverseGeocoder.java +++ b/src/org/traccar/geocode/FactualReverseGeocoder.java @@ -19,10 +19,6 @@ import javax.json.JsonObject; public class FactualReverseGeocoder extends JsonReverseGeocoder { - public FactualReverseGeocoder() { - this("https://api.factual.com/geotag", "ABCDE", 0); - } - public FactualReverseGeocoder(String url, String key, int cacheSize) { super(url + "?latitude=%f&longitude=%f&KEY=" + key, cacheSize); } diff --git a/src/org/traccar/geocode/MapQuestReverseGeocoder.java b/src/org/traccar/geocode/MapQuestReverseGeocoder.java index be3f51b04..93edfdd09 100644 --- a/src/org/traccar/geocode/MapQuestReverseGeocoder.java +++ b/src/org/traccar/geocode/MapQuestReverseGeocoder.java @@ -20,10 +20,6 @@ import javax.json.JsonObject; public class MapQuestReverseGeocoder extends JsonReverseGeocoder { - public MapQuestReverseGeocoder() { - this("http://www.mapquestapi.com/geocoding/v1/reverse", "ABCDE", 0); - } - public MapQuestReverseGeocoder(String url, String key, int cacheSize) { super(url + "?key=" + key + "&location=%f,%f", cacheSize); } diff --git a/src/org/traccar/geocode/OpenCageReverseGeocoder.java b/src/org/traccar/geocode/OpenCageReverseGeocoder.java index 3104cb56a..b5b31179e 100644 --- a/src/org/traccar/geocode/OpenCageReverseGeocoder.java +++ b/src/org/traccar/geocode/OpenCageReverseGeocoder.java @@ -1,5 +1,6 @@ /* * Copyright 2014 - 2015 Stefaan Van Dooren (stefaan.vandooren@gmail.com) + * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,10 +21,6 @@ import javax.json.JsonObject; public class OpenCageReverseGeocoder extends JsonReverseGeocoder { - public OpenCageReverseGeocoder() { - this("https://api.opencagedata.com/geocode/v1", "ABCDE", 0); - } - public OpenCageReverseGeocoder(String url, String key, int cacheSize) { super(url + "/json?q=%f,%f&key=" + key, cacheSize); } @@ -36,12 +33,21 @@ public class OpenCageReverseGeocoder extends JsonReverseGeocoder { if (location != null) { Address address = new Address(); + if (location.containsKey("building")) { + address.setHouse(location.getString("building")); + } if (location.containsKey("house_number")) { address.setHouse(location.getString("house_number")); } if (location.containsKey("road")) { address.setStreet(location.getString("road")); } + if (location.containsKey("suburb")) { + address.setSuburb(location.getString("suburb")); + } + if (location.containsKey("city")) { + address.setSettlement(location.getString("city")); + } if (location.containsKey("city_district")) { address.setSettlement(location.getString("city_district")); } -- cgit v1.2.3