O'Reilly Hacks
oreilly.comO'Reilly NetworkSafari BookshelfConferences Sign In/My Account | View Cart   
Book List Learning Lab PDFs O'Reilly Gear Newsletters Press Room Jobs  


 
Buy the book!
Yahoo! Hacks
By Paul Bausch
October 2005
More Info

HACK
#39
Monitor Your Commute
Let Yahoo! Local point out construction, accidents, and other potential slow spots on your route
[Discuss (0) | Link to this hack]

If you've ever been stuck in an inexplicable traffic jam, you know how important information can be. Just knowing the reason behind a slowdown can help you estimate how much longer you'll be stuck and make some sense of the sea of cars surrounding you. With a little planning and research, you might be able to avoid those trouble spots entirely.

Scout Your Route

To get a general sense of traffic in your area before you leave the house, try looking up your city at Yahoo! Maps. Browse to http://maps.yahoo.com/traffic and plug in your city. You'll see a map that includes any known construction areas and traffic incidents, along with the general speed of the routes. shows the traffic around San Francisco and southern Marin County.

Figure 1. San Francisco Bay area traffic

The squares on the map indicate areas with construction and triangles with exclamation points indicate a traffic incident. You can get more detail by hovering over these icons. Clicking the icon gives you even more information, as shown in .

Figure 2. Traffic incident detail

As you can see from , the information won't always tell you when an incident will be over, but at least you'll know that the route could be slow.

In addition to the general overview of your city, you can look for problems along a specific route. Any driving directions provided by Yahoo! Maps also include traffic information. Point your browser to http://maps.yahoo.com, click Driving Directions (toward the top of the page), and enter a starting and ending location. The map you get by clicking Get Directions will show you traffic incidents along the route. This is great for routes you might not be familiar with, but if you have a regular commute, there are a few other ways to work this information into your daily routine.

Subscribe to Your Commute

Dashboard is great for Tiger users, but if you're on Windows (or if you're a Mac user who simply hasn't upgraded yet), there's still a way to subscribe to information about your commute with RSS.

Studying the data behind the Yahoo! Local Traffic widget, intrepid developer John Resig found that the widget was getting its data from Yahoo! in the popular RSS format; he posted his findings to his web site: http://ejohn.org/blog/traffic-conditions-data. This means you can create your own specially formatted URL to create an RSS feed of traffic incidents in your area.

Here's a look at the format of the URL:

	http://maps.yahoo.com/traffic.rss?csz=94101&mag=4&minsev=2

The three variables correspond to the preferences you can set in the dashboard widget:

csz

The Zip Code, city, or state.

mag

The magnification of the area—that is, the radius of traffic data from the center of the specified location. Possible values are 3, 4,or 5, which correspond to 4 miles, 10 miles, and 40 miles respectively.

minsev

The minimum severity that should be shown in the feed. A value of 1 sets the minimum to Minor, 2 is Moderate, and 3 is Major.

So, putting all of the variables together, you can set a feed of moderate traffic incidents within 40 miles of San Francisco, like so:

	http://maps.yahoo.com/traffic.rss?csz=94101&mag=5&minsev=2

Now you can add this URL to your favorite RSS newsreader to keep up with any traffic problems in the area. This also means you can add the data to My Yahoo! by visiting http://my.yahoo.com and choosing Add Content from the top of the page. Then click "Add RSS by URL" and plug in your newly created traffic feed. You'll find the new module on your My Yahoo! page, as shown in .

Figure 4. Yahoo! Traffic data in My Yahoo!

Another nice feature is that once this traffic data is available in My Yahoo!, you can view these incidents with your cell phone's browser. So, not only will you be able to check your commute from home or office, but you'll also have something to check when you're stuck in your car dealing with one of these incidents!


O'Reilly Home | Privacy Policy

© 2007 O'Reilly Media, Inc.
Website: | Customer Service: | Book issues:

All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.