Changing the order of the "nearby_weather_stations"

  • 2
  • Question
  • Updated 7 years ago
Hello,
I'd like to know if there is a way to change the order of the "nearby_weather_stations" when calling an API?
For instance when I call: http://api.wunderground.com/api/42c42...
when looking at the "nearby_weather_stations" section I've got:
"nearby_weather_stations": {
"airport": {
"station": [
{ "city":"Montelimar", "state":"", "country":"France", "icao":"LFLQ", "lat":"44.58333206", "lon":"4.73333311" },
{ "city":"Montelimar", "state":"", "country":"FR", "icao":"LFLQ", "lat":"44.58000183", "lon":"4.73000002" },
{ "city":"Orange", "state":"", "country":"FR", "icao":"LFMO", "lat":"44.13000107", "lon":"4.82999992" },
{ "city":"Caumont Avignon", "state":"", "country":"FR", "icao":"LFMV", "lat":"43.90999985", "lon":"4.90000010" }
]
I would like to have Orange set as default at the first place. It would be nice to be able to choose. Thanks.
Photo of Laurent

Laurent

  • 3 Posts
  • 0 Reply Likes

Posted 7 years ago

  • 2
Photo of juanbond

juanbond

  • 20 Posts
  • 8 Reply Likes
If you mean that you want to get weather data from the Orange airport station (LFMO), then simply request it directly, like this:

http://api.wunderground.com/api/42c42418682c42bf/geolookup/conditions/forecast/q/LMFO.json

If you mean that you just want the "station" array to be in a different order, then you're probably going to have to pull out each element in your code and reorder the data yourself.
Photo of Laurent

Laurent

  • 3 Posts
  • 0 Reply Likes
Hi juanbond, thanks for your answer.
You're right, I would like the station array to be in a different order, but how can I do that in the api itself?
I also thought of doing two different api calls in one but it doesn't work. Are there any code samples?
Thank you.
Photo of juanbond

juanbond

  • 20 Posts
  • 8 Reply Likes
As far as I know, you cannot request that the API order the stations in a different way. You'll simply have to re-order them on your side once you retrieve the data. I'm unsure why you'd need to do this, but you can simply do it in code once you parse the JSON. If you can explain the bigger picture of what you're trying to accomplish by re-ordering the stations, perhaps I can help more.
Photo of Laurent

Laurent

  • 3 Posts
  • 0 Reply Likes
Hi,
What I would like to achieve is fairly simple: I would like to pick up Orange airport sky conditions only, but display the temperature from my own PWS.
The reason: I'm approximately half way between Montelimar and Orange. Montelimar is closer from my place, but the sky conditions in my place more often match the ones from Orange and not the ones from Montelimar.
Now I achieved doing that by requesting: http://api.wunderground.com/api/42c42...
and by retrieving my own data from Cumulus.Though I havn't tested it thouroughly yet, it seems to work and to work cross domains!
My aim is to make a small kind of widget, where anyone could display my weather on their site. As there are many cross domain issues, I was wondering initially if it was possible to change the order of the stations in the API itself.
It's probably possible to make a double request in the API but I didn't manage to do it. The only way I managed to do it is as you can see here: http://meteoardeche.pagesperso-orange...
It's in french of course but you can see on this page the sky conditions from Orange and the temperature from my PWS. The sky conditions come from the API, and the temperature from Cumulus variables which are written in Delphi I think.
Thanks for your help.