Geocoder icon indicating copy to clipboard operation
Geocoder copied to clipboard

[OpenCage] configure guessing order

Open eschricker opened this issue 4 years ago • 0 comments

It would be great, if the guessing order could be configured instead of being hard coded.

For example for this result in Germany: '53757, Sankt Augustin, Grantham Allee 20, Deutschland' the returned components are:

"components": {
        "ISO_3166-1_alpha-2": "DE",
        "ISO_3166-1_alpha-3": "DEU",
        "_category": "commerce",
        "_type": "shop",
        "city": "Rhein-Sieg-Kreis",
        "continent": "Europe",
        "country": "Deutschland",
        "country_code": "de",
        "county": "Rhein-Sieg-Kreis",
        "house_number": "20",
        "political_union": "European Union",
        "postcode": "53757",
        "road": "Grantham-Allee",
        "shop": "Druckpunkt",
        "state": "Nordrhein-Westfalen",
        "state_code": "NW",
        "suburb": "Mülldorf",
        "town": "Sankt Augustin"
      }

Due to the current locality order 'Rhein-Sieg-Kreis' will be returned as city, but 'Sankt Augustin' would be correct. In comparison to the formatted field of the OpenCage-result "Druckpunkt, Grantham-Allee 20, 53757 Sankt Augustin, Deutschland" where the city is set properly.

https://github.com/OpenCageData/address-formatting/blob/master/conf/countries/worldwide.yaml

shows different orders depending for different countries.

In my opinion a simple solution could be to make the $localityKeys array public and static.

eschricker avatar Jan 21 '21 14:01 eschricker