geocoder-php / geocoder-php/Geocoder
[OpenCage] configure guessing order
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 4k
- Forks
- 525
- Avg merge
- 8m
- Merged PRs (30d)
- 1
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the locality orders in conf/countries/worldwide.yaml with the code that uses the $localityKeys array. Make the guessing order configurable without losing the country-specific behavior, and verify that the example resolves Sankt Augustin rather than Rhein-Sieg-Kreis as the city.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100