ropensci / opencage

:globe_with_meridians: R package for the OpenCage API -- both forward and reverse geocoding :globe_with_meridians:
https://docs.ropensci.org/opencage
87 stars 11 forks source link

issue with `address_only`? #160

Open dpprdan opened 4 months ago

dpprdan commented 4 months ago

@freyfogle I am seeing some diverging API responses to queries in the {opencage} tests. That by itself is not very surprising, considering that some tests are > 2 years old.

However, regarding the address_only parameter I am seeing some unexpected results:

  1. https://api.opencagedata.com/geocode/v1/json?q=47.21835%2C-1.55439&no_annotations=1&address_only=1&key=OPENCAGE_KEY returns "formatted": "Hôtel Rosmadec, Rue de la Commune, 44000 Nantes, France",
  2. similarly https://api.opencagedata.com/geocode/v1/json?q=34.05369%2C-118.242767&no_annotations=1&address_only=1&key=OPENCAGE_KEY returns "formatted": "Los Angeles City Hall, 200 North Spring Street, Los Angeles, CA 90012, United States of America",
  3. or https://api.opencagedata.com/geocode/v1/json?q=47.21947%2C-1.54754&no_annotations=1&address_only=1&key=OPENCAGE_KEY returns "formatted": "Le Palais, 37 Rue Gambetta, 44000 Nantes, France"

All three seem to contain a POI in the formatted field, which they shouldn't, I'd expect, because address_only=1.

Conversely there are some places where I would expect a POI, where there is none returned. E.g. judging from the {opencage} tests there was one at https://api.opencagedata.com/geocode/v1/json?q=47.21864%2C-1.554136&no_annotations=1&key=OPENCAGE_KEY (probably "Hôtel de Ville" or something similar), and for https://api.opencagedata.com/geocode/v1/json?q=47.21611%2C-1.54931&no_annotations=1&key=OPENCAGE_KEY I'd expect "Château des Ducs de Bretagne".

My expectations might be wrong, of course.

FWIW the "Goethes Gartenhaus" example from the API docs works as described there.

freyfogle commented 4 months ago

many thanks for the detailed examples. Will investigate, but am on holiday this week, so may be a few days.

More soon

freyfogle commented 4 months ago

Hi, finally had a chance to understand this in detail.

The issue is that in some building have commonly used names (and indeed in some parts of the world buildings have names and no numbers). So for example in this case "Los Angeles City Hall" is tagged in OSM as the name of the building (rather than, for example, being tagged something like office=Los Angeles City Hall. It is the same with the hotel in France. It is tagged as the name of the building rather than hotel=

We have now adapted our code so that if address_only=1 is set and we have a house number we just use the house number. Note though that the hotel at 47.21835, -1.55439 we do not have a building number, so we keep the building name in the address. If it is actually a working hotel it should be tagged a such. Possibly it once was a hotel, no longer is, but is still simply refered to as the hotel as its "address".

We have also clarified this in the documentation.

Thanks for the examples and making us aware of this issue.