Closed reynaldichernando closed 1 month ago
I think the issue is right here when trying to construct the cityName
, the value is undefined, because there is no field in the address
object that is called "city", "town", "village", "province" or "municipality".
At least for the sample location I picked above, the field is "hamlet" (See above)
Ideally we don't have to guess what kind of field there is in the address
, and just use this name
field for the cityName
.
Although it is also possible to find the name in the address
, but we could determine the field name by checking the addresstype
, for example the above addresstype
is hamlet
, which is also the field name used in the address
object.
But not sure why we wanna do this (?)
Also fun fact, I found this the OSM API docs, it shows all the possible field that can appear in address
.
https://nominatim.org/release-docs/latest/api/Output/#addressdetails
Thanks for this investigation!
Ideally we don't have to guess what kind of field there is in the address, and just use this name field for the cityName.
I think you are right on this.
The problem with cities needs a big change anyway.
Indeed today users are unable to select a given city if its name exists several times in a country.
What I had in mind to fix this is to switch URLs from /city/${countryCode}-${cityName}
to /city/${lat}-${long}/${cityName}
.
Today ${countryCode}-${cityName}
is the city id, but when this change occur it will be ${lat}-${long}
.
The nice thing with this is that ${cityName}
could be anything as it'll just be cosmetic in the URL.
Also, I changed the title of the issue because the problem your pointing out is related to not being able to find cities with some address types that are not supported. Not cities with diacritics not being able to load properly.
Here is an example of the latter: meet.hn/city/no-Tromsø And I think the problem is that here selectedCity is undefined. I didn't test the hypothesis though.
Fixed with commit: https://github.com/borisghidaglia/meet-hn/commit/2ec73c8ae0bf47cdbbea54995e5d2e74ce10ccaf
Starting at this commit, meet.hn supports location search. Any location working on OpenStreetMap should work now.
I'm creating a separate issue to discuss the cities with diacritics not loading properly as shared in https://github.com/borisghidaglia/meet-hn/issues/6#issuecomment-2356415988.
I did try with the following location
Kaupō, United States
and it showedCity not found
.However, checking the OSM API call, it seems that the location was found, but it was just failing to do split on
cityName
.