Closed pixrr closed 4 years ago
Hello @pixrr ,
We could/should indeed use town
and county
as fallback if city
is not defined!
In what order/priority, would you define city
, town
, and county
?
Hello @jbelien,
I check the documentation of LocationIQ Query Parameters (specific parameters section), it seems we can add parameter to normalize city value if missing.
with the parameter normalizecity=1
:
For responses with no city value in the address section, the next available element in this order:
city_district, locality, town, borough, municipality, village, hamlet, quarter, neighbourhood
from the address section will be normalized to city.
I think, they have many properties as fallback when the city value is missing and we are not always aware of what properties we get after a request. :thinking:
For the order/priority, I think it's better to refer to the order specified by LocationIQ
normalizecity
parameter looks interesting!
Could you paste here the response of your previous query with the normalizecity=1
?
GET https://locationiq.com/v1/search.php?key=YOUR_PRIVATE_TOKEN&q=12%20rue%20Beziel&format=json&addressdetails=1&normalizecity=1
By passing normalizecity
parameter in query, we can have the following response for the address section:
{
"house_number": "12",
"road": "Rue Béziel",
"town": "Rambouillet",
"county": "Rambouillet",
"state": "Île-de-France",
"country": "France",
"postcode": "78120",
"country_code": "fr",
"city": "Rambouillet"
}
Okay, this seems the best way to tackle this issue! I'll create a PR ASAP !
Great ! Thank you :smile:
@jbelien
I checked with the xml format and city attribute is missing in xml
GET https://locationiq.com/v1/search.php?key=YOUR_PRIVATE_TOKEN&q=12%20rue%20Beziel&format=xml&addressdetails=1&normalizecity=1
<place place_id="68552314" osm_type="node" osm_id="5877009334" place_rank="30" boundingbox="48.6453873,48.6454873,1.8319807,1.8320807" lat="48.6454373" lon="1.8320307" display_name="12, Rue Béziel, Rambouillet, Yvelines, Île-de-France, France métropolitaine, 78120, France" class="place" type="house" importance="0.211">
<house_number>12</house_number>
<road>Rue Béziel</road>
<town>Rambouillet</town>
<county>Rambouillet</county>
<state>Île-de-France</state>
<country>France</country>
<postcode>78120</postcode>
<country_code>fr</country_code>
</place>
And when I use xmlv1.1
as format
GET https://locationiq.com/v1/search.php?key=YOUR_PRIVATE_TOKEN&q=12%20rue%20Beziel&format=xmlv1.1&addressdetails=1&normalizecity=1
<place place_id="68552314" boundingbox="48.6453873,48.6454873,1.8319807,1.8320807" lat="48.6454373" lon="1.8320307" display_name="12, Rue Béziel, Rambouillet, Yvelines, Île-de-France, France métropolitaine, 78120, France" class="place" type="house" importance="0.211">
<house_number>12</house_number>
<road>Rue Béziel</road>
<town>Rambouillet</town>
<county>Rambouillet</county>
<state>Île-de-France</state>
<country>France</country>
<postcode>78120</postcode>
<country_code>fr</country_code>
<city>Rambouillet</city>
</place>
@pixrr New version 1.0.1
is released 🎉
Thanks for the notice!
Hi,
I use the LocationIQ provider and I'm unable to retrieve the city when I get the
Location
object by callinggeocodeQuery
method for the following address: '12 rue Beziel' (french address).So I checked the raw response for this address in the LocationIQ API geocode endpoint url (doc: https://locationiq.com/docs-html/index.html#search-forward-geocoding) and I got this for the address details:
It seems some properties are missing with this address.
In LocationIQ.php file,
town
andcounty
for example are not used when the Location object is built. There is a way to have a fallback if thecity
property name is missing ?Many thanks!