No address with reverse geocoding

yashbhat7 years ago

I used to use the default Google reverse geocoder with an API key. It resulted in too many calls which became expensive so I changed to locationIQ. However, locationIQ isn't working at all and giving reverse geocoding error and then when I switched back to google even that isn't working. THis is the image of requests and as you can see, lately no requests are being made at all.
Geocoding API requests

Anton Tananaev7 years ago

Possible reasons:

  1. Your configuration is wrong or you forgot to restart service
  2. Google doesn't accept requests anymore
yashbhat7 years ago
  1. Didn't forget to restart service
  2. I have tried with LocationIQ tooConfiguration

The configuration is as shown above and the key is correct.

Anton Tananaev7 years ago

Well, to use LocationIQ you need a key. You haven't provided any. Please be more careful and double check everything yourself before asking for help.

yashbhat7 years ago

I'm sorry. ? Coffee driven development is a bad idea. Coffee is no substitute to sleep. I was constantly reading geolocation key as geocoder key.

Jens6 years ago

Tried to use LocationIQ for reversed geocoding.
So far no success.

<entry key='geocoder.enable'>true</entry>
<entry key='geocoder.type'>nominatim</entry>
<entry key='geocoder.url'>https://eu1.locationiq.com/v1/reverse.php</entry>
<entry key='geocoder.key'>MY_KEY</entry>

Any idea what I am doing wrong?
Thanks in advance for your help.

chris d5 years ago

Dear Anton,

I have a LocationIQ key, and put the configuration from there geolocation with my key into traccar.xml . I stopped and restarted the server, but I don't get any reverse geocoding and the following error in the log:

Geocoding failed - Empty address - GeocoderException (JsonGeocoder:68 < *:31 < *:96 < *:93 < ...)

This happend right from the beginning when I initially put my API key, so it should not be related to limitation of requests of my free LocationIQ account.

Any help what am I doing wrong?

Anton Tananaev5 years ago

Geolocation and geocoding are two completely different things.

chris d5 years ago

Sorry, I put the wrong link in my previous post. I am talking of reverse geocoding.
So using this configuration in traccar.xml

<entry key='geocoder.enable'>true</entry>
<entry key='geocoder.type'>nominatim</entry>
<entry key='geocoder.url'>https://eu1.locationiq.com/v1/reverse.php</entry>
<entry key='geocoder.key'>xxxxx my API KEY xxxxx</entry>

gives no address and the following error in the log

WARN: Geocoding failed - Empty address - GeocoderException (JsonGeocoder:68 < *:31 < *:96 < *:93 < ...)
Anton Tananaev5 years ago

The error means that server doesn't return an address.

chris d5 years ago

I checked now a direct GET request with LocationIQ using this query string:

https://eu1.locationiq.com/v1/reverse.php?key=my_key_here&lat=4.7&lon=-74.0&format=json

It works well and gives me the following answer

{"place_id":"94078124","licence":"https:\/\/locationiq.com\/attribution","osm_type":"way","osm_id":"59282502","lat":"4.69990776498286","lon":"-74.0002672351387","display_name":"Vereda San Rafael, La Calera, Cundinamarca, 110211, Kolumbien","address":{"city":"Vereda San Rafael","county":"La Calera","state":"Cundinamarca","postcode":"110211","country":"Kolumbien","country_code":"co"},"boundingbox":["4.694006","4.7052604","-74.0019285","-73.997672"]}

So there is no problem with my API-Key or the LocationIQ service in general. But I still get in the traccar log the error

2019-02-06 09:54:57  WARN: Geocoding failed - Empty address - GeocoderException (JsonGeocoder:68 < *:31 < *:96 < *:93 < ...)

Could it be that the query string traccar is using for the request is not in the right format? Where can I find the GET query string traccar is sending?

Anton Tananaev5 years ago

You can find it in the code. You can also debug the code to figure out what the issue is.

chris d5 years ago

I had a look at the code on github, but I am not an expert at all in programming... I believe the following piece of code in NominatimGeocoder.java is responsible for my error

    private static String formatUrl(String url, String key, String language) {
        if (url == null) {
            url = "https://nominatim.openstreetmap.org/reverse";
        }
        url += "?format=json&lat=%f&lon=%f&zoom=18&addressdetails=1";
        if (key != null) {
            url += "&key=" + key;
        }
        if (language != null) {
            url += "&accept-language=" + language;
        }
        return url;
    }

I believe the wrong query url is created here

        url += "?format=json&lat=%f&lon=%f&zoom=18&addressdetails=1";
        if (key != null) {
            url += "&key=" + key;
        }

since the query key for LocationIQ according to the API documentation should read

?key=api_key&lat=LATITUDE&lon=LONGITUDE&format=json

, I believe the last java code snippet above should be replaced with

        if (key != null) {
            url += "?key=" + key;
        }
        url += "&lat=%f&lon=%f&format=json&zoom=18&addressdetails=1";

I do not have the possibility to compile and debug this on my own right now. Furthermore, this will most probably work only for LocationIQ not for other nominatim based queries (or without passing a key) and I don't know how to switch between these different cases. I have no github account and I am not familiar with its use to put my opinion there. Anton, can you confirm what I am guessing and could you put it into github?

Anton Tananaev5 years ago

The order of query parameters doesn't matter.

chris d5 years ago

I finally figured out what was the problem. I realized today, that there is a new version since 5 days. I reinstalled in the hope of solving this error. The error was not solved, but with the identical configuration the error message now was different:

WARN: Geocoding failed - Empty address. Error: The provided API key is invalid. - GeocoderException (JsonGeocoder:69 < *:31 < *:97 < *:94 < ...)

This led me to the solution. My API key was definitely right. Checking all my configurations I realized that further below the section for reverse geocoding came the geolocation section and here the API key was overwritten by assigning it a different value namely my key for OpenCellID. The same happened to the value of geocoder.type.

I was surprised and found out that my error came actually from following the documentation for Reverse-Geocoding and LBS-Geolocation word by word. Since I use different services for Reverse-Geocoding and LBS-Geolocation, I accidentally have overwritten one configuration.
checking the Configuration File Docu once again, I realized that the LBS-Geolocation docu seems to have a copy/paste typo and should read

<entry key='geolocation.enable'>true</entry>
<entry key='geolocation.type'>opencellid</entry>
<entry key='geolocation.key'>YOUR API KEY</entry>

and analog for the other geolocation provider examples.