diff options
author | Anton Tananaev <anton@traccar.org> | 2023-11-09 07:55:45 -0800 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2023-11-09 07:55:45 -0800 |
commit | cd5413ae082a55e94d46f38a2a73f72eddb92aca (patch) | |
tree | a67bedd81e4e113a60deef516c30e43f6ab02bb4 /src/main/java/org/traccar/geocoder | |
parent | d57af42117c98a0c52d9bd776aa8d24af2dfafeb (diff) | |
download | trackermap-server-cd5413ae082a55e94d46f38a2a73f72eddb92aca.tar.gz trackermap-server-cd5413ae082a55e94d46f38a2a73f72eddb92aca.tar.bz2 trackermap-server-cd5413ae082a55e94d46f38a2a73f72eddb92aca.zip |
Update HERE geocoder
Diffstat (limited to 'src/main/java/org/traccar/geocoder')
-rw-r--r-- | src/main/java/org/traccar/geocoder/HereGeocoder.java | 58 |
1 files changed, 26 insertions, 32 deletions
diff --git a/src/main/java/org/traccar/geocoder/HereGeocoder.java b/src/main/java/org/traccar/geocoder/HereGeocoder.java index 2d1bc1bf4..4767eabad 100644 --- a/src/main/java/org/traccar/geocoder/HereGeocoder.java +++ b/src/main/java/org/traccar/geocoder/HereGeocoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2018 - 2023 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,65 +20,59 @@ import jakarta.ws.rs.client.Client; public class HereGeocoder extends JsonGeocoder { - private static String formatUrl(String url, String id, String key, String language) { + private static String formatUrl(String url, String key, String language) { if (url == null) { - url = "https://reverse.geocoder.ls.hereapi.com/6.2/reversegeocode.json"; + url = "https://revgeocode.search.hereapi.com/v1/revgeocode"; } - url += "?mode=retrieveAddresses&maxresults=1"; - url += "&prox=%f,%f,0"; - url += "&app_id=" + id; - url += "&app_code=" + key; + url += "?types=address&limit=1"; + url += "&at=%f,%f"; url += "&apiKey=" + key; if (language != null) { - url += "&language=" + language; + url += "&lang=" + language; } return url; } public HereGeocoder( - Client client, String url, String id, String key, String language, + Client client, String url, String key, String language, int cacheSize, AddressFormat addressFormat) { - super(client, formatUrl(url, id, key, language), cacheSize, addressFormat); + super(client, formatUrl(url, key, language), cacheSize, addressFormat); } @Override public Address parseAddress(JsonObject json) { JsonObject result = json - .getJsonObject("Response") - .getJsonArray("View") + .getJsonArray("items") .getJsonObject(0) - .getJsonArray("Result") - .getJsonObject(0) - .getJsonObject("Location") - .getJsonObject("Address"); + .getJsonObject("address"); if (result != null) { Address address = new Address(); - if (result.containsKey("Label")) { - address.setFormattedAddress(result.getString("Label")); + if (result.containsKey("label")) { + address.setFormattedAddress(result.getString("label")); } - if (result.containsKey("HouseNumber")) { - address.setHouse(result.getString("HouseNumber")); + if (result.containsKey("houseNumber")) { + address.setHouse(result.getString("houseNumber")); } - if (result.containsKey("Street")) { - address.setStreet(result.getString("Street")); + if (result.containsKey("street")) { + address.setStreet(result.getString("street")); } - if (result.containsKey("City")) { - address.setSettlement(result.getString("City")); + if (result.containsKey("city")) { + address.setSettlement(result.getString("city")); } - if (result.containsKey("District")) { - address.setDistrict(result.getString("District")); + if (result.containsKey("district")) { + address.setDistrict(result.getString("district")); } - if (result.containsKey("State")) { - address.setState(result.getString("State")); + if (result.containsKey("state")) { + address.setState(result.getString("state")); } - if (result.containsKey("Country")) { - address.setCountry(result.getString("Country").toUpperCase()); + if (result.containsKey("countryCode")) { + address.setCountry(result.getString("countryCode").toUpperCase()); } - if (result.containsKey("PostalCode")) { - address.setPostcode(result.getString("PostalCode")); + if (result.containsKey("postalCode")) { + address.setPostcode(result.getString("postalCode")); } return address; |