problem with italian city names

  • 1
  • Problem
  • Updated 5 years ago
Hi

I am trying to query informations for cities in italy. The city names comes from a user request, so the cities are not choosen in advance.

I am using this format:
http://api.wunderground.com/api//geol...
So i query for [Country (in english)]/[city_name]

The problem is with "city name", because I need to use the italian name. If I use the english name, it will not always work: it will work for Rome, Venice, Milan but it will not work for Turin. If i use the italian name it will work always. Works for "Venezia", but not for Torino, Roma, Genova, etc

Moreover, when the Italian name does not fit I have a response field in which I can find a useful zmw code. But this is not the case for "Roma" (there is no Roma in Italy, but one in sweden, one in texas, etc. So I cannot use it to asj the user to refine his/her query.

Anu ideas?
Photo of Enrico Luciano

Enrico Luciano

  • 3 Posts
  • 0 Reply Likes
  • concerned

Posted 5 years ago

  • 1
Photo of afelicioni

afelicioni

  • 227 Posts
  • 43 Reply Likes
Is the user request a hand typed input? If so, you need to consume large units of geolookup requests: I hope you're caching data in your project.

Since I can assume you're focusing on italian reach, why don't query using the /lang:IT/ setting? Using this and italian strings, I see all above cities have at least one zmw code for geolookups responses.
Photo of Enrico Luciano

Enrico Luciano

  • 3 Posts
  • 0 Reply Likes
http://api.wunderground.com/api//fore...

and

http://api.wunderground.com/api//fore...

both don't report any result for Roma. They all provide the same alternative cities for Roma all over the world, but no Roma seems to exist in italy.

The same is for geolookup: http://api.wunderground.com/api//geol...

For all queries the result is following

{
"response": {
"version": "0.1",
"termsofService": "http://www.wunderground.com/weather/a...",
"features": {
"forecast10day": 1,
"conditions": 1
},
"results": [
{
"name": "Roma",
"city": "Roma",
"state": "QU",
"country": "AU",
"country_iso3166": "AU",
"country_name": "",
"zmw": "00000.1.94515",
"l": "/q/zmw:00000.1.94515"
},
{
"name": "Roma",
"city": "Roma",
"state": "",
"country": "RO",
"country_iso3166": "RO",
"country_name": "Romania",
"zmw": "00000.13.15020",
"l": "/q/zmw:00000.13.15020"
},
{
"name": "Roma Kungsgård",
"city": "Roma Kungsgård",
"state": "",
"country": "SN",
"country_iso3166": "SE",
"country_name": "Svezia",
"zmw": "00000.1.02595",
"l": "/q/zmw:00000.1.02595"
},
{
"name": "Roma",
"city": "Roma",
"state": "TX",
"country": "US",
"country_iso3166": "US",
"country_name": "Stati Uniti d'America",
"zmw": "78584.1.99999",
"l": "/q/zmw:78584.1.99999"
}
]
}
}
Photo of afelicioni

afelicioni

  • 227 Posts
  • 43 Reply Likes
The query still needs the country, localized to the lang setting


http://api.wunderground.com/api/APIKEY/geolookup/lang:IT/q/Italia/Roma.json


returns



{
"response": {
"version": "0.1"
,"termsofService": "http://www.wunderground.com/weather/api/d/terms.html"
,"features": {
"geolookup": 1
}
, "results": [
{
"name": "Roma",
"city": "Roma",
"state": "",
"country": "IY",
"country_iso3166":"IT",
"country_name":"Italia",
"zmw": "00000.1.16239",
"l": "/q/zmw:00000.1.16239"
}
,
{
"name": "Roma",
"city": "Roma",
"state": "",
"country": "IY",
"country_iso3166":"IT",
"country_name":"Italia",
"zmw": "00000.1.16240",
"l": "/q/zmw:00000.1.16240"
}
,
{
"name": "Roma",
"city": "Roma",
"state": "",
"country": "IY",
"country_iso3166":"IT",
"country_name":"Italia",
"zmw": "00000.1.16239",
"l": "/q/zmw:00000.1.16239"
}
,
{
"name": "Roma",
"city": "Roma",
"state": "",
"country": "IY",
"country_iso3166":"IT",
"country_name":"Italia",
"zmw": "00000.1.16240",
"l": "/q/zmw:00000.1.16240"
}
]
}
}
Photo of Enrico Luciano

Enrico Luciano

  • 3 Posts
  • 0 Reply Likes
Thank you.
This works but is not documented... It can be useful to know this.

However this solves geolookup.
If I query directly using:
http://api.wunderground.com/api/KEY/f...
(so Italian fot country and city and lang:IT) I get the same geolookup results, not conditions and forecasts.

So everytime I need two pass: geolookup and then a query using the ZMW.

There are alternatives to his behavior?

Thank you
Photo of afelicioni

afelicioni

  • 227 Posts
  • 43 Reply Likes
Ah, this is the weird side of WU API, so expecially for large cities multiple results appear to be overlapped, or multiplied... this is also poorly covered in documentation, just a mention for "Ambiguous Results".

I don't know any ultimate formula for this scenario, I'm afraid you have to make your by yourself.