Click here to Skip to main content
15,887,027 members
Articles / Desktop Programming / MFC
Article

Yahoo! Weather Viewer

Rate me:
Please Sign up or sign in to vote.
4.56/5 (9 votes)
31 Aug 2007CPOL2 min read 58.4K   4.4K   21   4
An article on retrieving the weather data using Yahoo! Weather RSS feed

Introduction

This article is about a small non-MFC Win32 application that uses Yahoo! Weather RSS feeds to parse and show the weather information to the user. These RSS 2.0 feeds are represented by a small XML file with a very simple inner structure which makes it easy to the 3rd party applications to parse and show weather information all around the world and at any time. You can find more info about developing the custom application which uses these feeds on the following web site: Yahoo! developer's corner.

Using the Code (Application)

To use the application just open the compiled Yahoo Weather Viewer.exe file in the Debug or in the Release folder of the project directory. One will also find the Countries folder which holds data about different countries (for easier access). I have built these data files using Yahoo! Weather web site for most European countries. They are plain text files so one will have no difficulties to understand them.

The application sends a simple HTTP GET request to the Yahoo! Weather service. It has the following form:

http://weather.yahooapis.com/forecastrss?p=YIXX0027&u=c

The parameter p here stands for location ID or a ZIP code (US only). The second parameter u stands for units (Celsius or Fahrenheit degrees, miles or kilometers, etc). The returned file has a simple RSS 2.0 structure shown below:

  • XML
  • RSS
    • CHANNEL
      • title
      • link
      • description
      • ...weather info...
      • IMAGE
        • title
        • width
        • height
        • link
        • URL
      • ITEM
        • title
        • link
        • description
        • ...weather info...

So, this web service response needs to be parsed and weather information has to be extracted. This feed covers information considering the following:

  • Location info (city, region and country)
  • Units info (temperature, distance, pressure and speed)
  • Wind info (chill, direction and speed)
  • Atmosphere info (humidity, visibility and pressure)
  • Astronomy info (sunrise and sunset)
  • Conditions info (description, temperature and date)
  • Forecast info (day, lowest temperature, highest temperature, description and date)

On the other hand, to obtain the satellite or any other kind of map with weather conditions, one will have to look for it on the special image locations (Yahoo! Weather service periodically updates these images). See links below for examples:

After downloading, these JPEG files can be converted and shown to the user.

Points of Interest

I had a very good time building this application and I hope people will find it useful.

History

  • August, 2007 - Yahoo! Weather Viewer v1.0

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Elektromehanika d.o.o. Nis
Serbia Serbia
He has a master degree in Computer Science at Faculty of Electronics in Nis (Serbia), and works as a C++/C# application developer for Windows platforms since 2001. He likes traveling, reading and meeting new people and cultures.

Comments and Discussions

 
GeneralKorea Pin
john wallis1-Sep-07 20:17
john wallis1-Sep-07 20:17 
GeneralRe: Korea Pin
darkoman1-Sep-07 23:54
darkoman1-Sep-07 23:54 
NewsAlso see... Pin
Ravi Bhavnani31-Aug-07 8:07
professionalRavi Bhavnani31-Aug-07 8:07 
GeneralRe: Also see... Pin
darkoman31-Aug-07 12:23
darkoman31-Aug-07 12:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.