Stuttgart Germany returns multiple locations instead of weather data

  • 1
  • Problem
  • Updated 5 years ago
Hi,

When I try to get weather data for Stuttgart, Germany using the query .../q/Germany/Stuttgart.json (full URL below), I get location results instead of weather. It seems that the only difference in the location data is the zmw field. These identically named locations are causing a valid city query to fail. Can something be done about this?

The full URL is:

http://api.wunderground.com/api/api_k...

The return is:

{
"response": {
"version":"0.1",
"termsofService":"http://www.wunderground.com/weather/a...",
"features": {
"geolookup": 1
,
"conditions": 1
,
"forecast": 1
,
"astronomy": 1
,
"almanac": 1
}
, "results": [
{
"name": "Stuttgart",
"city": "Stuttgart",
"state": "",
"country": "DL",
"country_iso3166":"DE",
"country_name":"Germany",
"zmw": "00000.3.10738",
"l": "/q/zmw:00000.3.10738"
}
,
{
"name": "Stuttgart",
"city": "Stuttgart",
"state": "",
"country": "DL",
"country_iso3166":"DE",
"country_name":"Germany",
"zmw": "00000.1.10739",
"l": "/q/zmw:00000.1.10739"
}
]
}
}
Photo of John Belmonte

John Belmonte

  • 18 Posts
  • 1 Reply Like

Posted 5 years ago

  • 1
Photo of Brendan Hayes

Brendan Hayes, Official Rep

  • 962 Posts
  • 122 Reply Likes
This happens sometimes when we have 2 records and WMO's in our db for a location. Use the ZMW as the search parameter instead when that happens.

http://api.wunderground.com/api/api_k...
Photo of John Belmonte

John Belmonte

  • 18 Posts
  • 1 Reply Like
I guess I did not make myself clear. The real question is why there would be two records and WMO's in your database for a location? This seems like a naming problem for the records. Shouldn't there be a single default record for a country/city combination? The query ../q/France/Paris.json returns weather data. I'm sure there is more than one Paris record, but I bet those other records are named differently so the search returns data.

Using the ZMW data is fine, but doing so would require a second call to the API.

In any event, thanks for the reply. Also, I don't want to give the wrong impression. My experience with the API so far has been overwhelmingly positive. There were just a couple of minor things.
Photo of Brendan Hayes

Brendan Hayes, Official Rep

  • 962 Posts
  • 122 Reply Likes
It happens when a WMO code changes and we don't get rid of the old one because we still have records associated with it. The trouble with housing years of historical data based on key IDs. Someday we will be using more of the weather.com LocationID system which handles changes a little bit better.
Photo of John Belmonte

John Belmonte

  • 18 Posts
  • 1 Reply Like
Thanks for taking the time to explain this to me. Light finally dawns on Marblehead.

I will use the ZMW data as you suggest. The ZMW data is also available in the "l" field of the location when weather data is returned. So I can cache it for future requests.
Photo of Brendan Hayes

Brendan Hayes, Official Rep

  • 962 Posts
  • 122 Reply Likes
Beware caching ZMW, it works most of the time, but when we update the DB the Magic (the M in ZMW) can change. DB updates happen when we add or remove locations or zip codes. For the most part ZMW is fine, but be aware that it has the potential to be updated. If the ZMW stops working, just go a /geolookup/ on the location and get the new ZMW.
Photo of John Belmonte

John Belmonte

  • 18 Posts
  • 1 Reply Like
Rather than caching the ZMW, should I use the ZMW the first time and then cache the latitude and longitude that is returned with the weather data? I could then use the latitude and longitude in subsequent requests for a specific location.