The route to smart transit

Explore Web sites, mobile applications, open data, and APIs for public transportation

Taking the bus to and from work — or the airport, the mall, or the ball park — is easier than ever, thanks to Web sites like Google Maps and the availability of public transit data for many metropolitan areas. Scott Davis shows how to leverage technology that helps make mass transit the smart way to get around.

Scott Davis, Founder, ThirstyHead.com

Scott DavisScott Davis is an internationally recognized author, speaker, and software developer. He is the founder of ThirstyHead.com, a Groovy and Grails training company. His books include Groovy Recipes: Greasing the Wheels of Java, GIS for Web Developers: Adding Where to Your Application, The Google Maps API, and JBoss At Work. He writes two ongoing article series for IBM developerWorks: Mastering Grails and Practically Groovy.



13 April 2010

Also available in Chinese Japanese Portuguese

What does urban congestion really look like?

One bus can comfortably pack as many as 35 riders into the space taken up by three cars. For a great visualization of the surprising difference that a single bus can make, take a look at "Packing Pavement" (see Resources). As the article says, "What we call urban congestion is not too many people, but too many vehicles in too small an area."

Mass transit reduces traffic congestion and the pollution it generates. And it can lower stress levels and out-of-pocket costs for the people who use it. Many Web sites and mobile applications now help commuters, shoppers, and tourists in cities all over the world be virtuously selfish and take advantage of their transit options. This article shows you some of the slick technology that makes getting where you need to go by bus (or light rail, or the El, or the subway) as easy as a walk in the park. Better yet, you can incorporate some of this technology into your own applications to help make riders more savvy about their transit opportunities.

Interactive Web sites that provide maps and driving directions have been available for several years now. Gone are the days of asking fellow humans for tedious turn-by-turn driving directions; you just plug the start and end addresses into one of these sites, and the online engine does the rest. Google Maps is arguably the most versatile of the mapping sites. Within a few months of its release in February 2005, Web developers had reverse-engineered Google Maps and created mashups that pulled data in from other sites and displayed the results on a Google map. One cheeky hacker combined real-time traffic data from Yahoo! with the driving directions from Google. This led to the release of the formal Google Maps API in June 2005. The Google Maps product manager joked, "We are doing this because they were already doing it" (see Resources).

Google Maps

Mash it up with maps

Check out these developerWorks articles on creating mashups with the Google Maps API:

By releasing an official API, Google shifted the focus of the Web site in a subtle but revolutionary way. It was now less a finished painting than a canvas on which programmers could paint their own pictures. Mashups sprouted up almost overnight that showed where the cheapest gasoline could be found, where the police had speed traps, and all kinds of other information that helped drivers along their way.

This do-it-yourself spirit wasn't lost on several Google employees who preferred taking the bus over driving. In December 2005, the Google Transit Trip Planner was introduced. Being able to choose between driving directions or public transportation is a feature that lives on in Google Maps today — just look for the drop-down list next to the Get Directions button. (You can choose walking and biking directions, as well.)

Take a moment to play around with this feature. Choose two major attractions in your home town — shopping malls, sports arenas, and airports are typically good picks — and get public transit directions between them.

Google Maps allows you to be fairly liberal in what you provide for the starting and ending points. I typed Flat Iron Crossing, Broomfield, CO (a big shopping mall) and Coors Field, Denver, CO (the baseball stadium where the Colorado Rockies play) in the A and B fields, respectively. Both places show up near the top of the list of suggestions from my fuzzy search, and with a single click the pertinent information appears in the appropriate field. Without knowing the exact address of either location, I now have a route between the two, as shown in Figure 1:

Figure 1. Google Maps showing public transit directions
Screen shot of Google Maps showing the map and directions between Flat Iron Crossing and Coors Field

When you choose public transit in Google Maps, you need to provide one additional bit of criteria — the time you want to travel. Since buses and trains follow specific timetables, you need to make sure that you are in the right place at the right time. Click on Show Options to reveal the Depart at and Arrive by fields, and choose either the time you'd like to leave or the time you'd like to arrive. Google Maps will adjust the suggested route accordingly, as shown in Figure 2:

Figure 2. Adjust your travel time in Google Maps
Screen shot showing depart at and arrive by times

After you're done playing around with shopping malls and sports stadiums, try plugging in your home address and your work address. I found that I have a covered Park-and-Ride parking garage just 5 minutes from my house that offers free parking for the day with the purchase of bus fare. An express bus drops me off just a couple of blocks from my office. During rush hour, a bus comes by about every 10 minutes over a 2-hour time span. No stops, no transfers, no waiting, and I have a nearly door-to-door public transportation solution for getting to work every day. Thank you, Google Maps.


Google Transit

If the public transit option doesn't appear in Google Maps for your town, it's because your local transit authority isn't submitting its schedule to Google for inclusion. You can visit the Google Transit site, shown in Figure 3, to see if your town is on the list:

Figure 3. See if your transit authority is listed in Google Transit
Screen shot of Google Transit's Web site

To be included in Google Maps, the transit authority simply needs to provide its route data in the General Transit Feed Specification (GTFS) format, host it at a publicly available URL, and let Google know where to find it (see Resources). After that, Google will periodically download the files to ensure that the latest information is used to calculate routes.

The GTFS format is a related set of comma-separated value (CSV) files. For example, Figure 4 shows some sample data for the agency, stops, and routes:

Figure 4. A simple example of the GTFS format
Screen shot example of a Web page showing GTFS formatted data useful to transit authorities

If you are an experienced programmer, you might be surprised that Google chose to use CSV files instead of newer formats like XML or JavaScript Object Notation (JSON). A ZIP file of CSV text sitting at a fixed URL won't win any awards for being cutting edge, but it removes nearly any possible technology barriers for participating in the program. We, as an industry, seem to argue endlessly about the relative merits of complex solutions to Web services, like SOAP versus REST and XML versus JSON; this bare-bones solution reminds us that there is elegance in simplicity, as well.

A quick Web search for "rtd gtfs" points me to the page, shown in Figure 5, where the Denver transit authority (RTD) hosts its GTFS files. With the latitude/longitude points for each stop in hand, I now have the raw material for writing my own killer Google Maps mashup.

Figure 5. The Denver RTD GTFS Web page
Screen shot of the Denver RTD GTFS Web page

If you want to be notified each time a transit authority updates its GTFS files, you can subscribe to an RSS feed, which you can optionally limit to a specific transit authority (see Resources). For example, I can see in the results shown in Figure 6 that RTD last updated its GTFS files about three weeks ago. Based on the history of the feed, it looks like RTD posts updates roughly once a quarter.

Figure 6. The GTFS Exchange Web site
Screen shot of the Denver RTD's Web page on the GTFS Data Exchange Web site

City-Go-Round

The City-Go-Round Web site came online in December 2009 (see Resources). In addition to being an advocacy Web site for open transit data — as of this writing, 108 U.S. transit authorities offer open data while 677 do not — it is a great clearinghouse for transit-related Web sites and mobile applications. Figure 7 shows the City-Go-Round home page:

Figure 7. The City-Go-Round Web site
Screen shot of the City-Go-Round Web site

Click on the Agencies link at the top of the page. From there, you can choose your state and quickly see who provides public transportation in your area. You can also see whether or not they offer open data.

If you scroll to the bottom of the page, you'll see that the information can be exported as CSV or JSON. This data includes latitude/longitude points for each transit authority — more fodder for your own transit mashup. In Figure 8, for example, I'm finding Colorado's public transit options:

Figure 8. Finding the public transit options in Colorado
Screen shot of City-Go-Round's Colorado public transit options Web page

The About page at City-Go-Round offers an interesting visualization of open transit data, shown in Figure 9:

Figure 9. Visualizing open transit data
Visualizing open transit data

The size of each bubble in Figure 9 indicates the relative size of the transit authority. The darker bubbles are the agencies that offer open data.

If you click on the chart on the About page, it takes you to the ManyEyes data-visualization Web site on IBM alphaWorks. The ManyEyes application — implemented as an interactive Java™ applet — allows you to click on the various bubbles to get more information.


Mobile phone apps

Get started with Android

Learn more about the Android environment for mobile applications:

The Web sites I've mentioned so far are great resources for planning your trip while you are still sitting at home. But what about when you are standing on the street corner? Thankfully, there is a vibrant ecosystem of transit-related mobile phone applications. If you click on the Apps link at the top of City-Go-Round, you'll see mobile applications optimized for the iPhone, Android, BlackBerry, and more.

Typing in Denver, CO shortens the list to applications that will help me out in my area, as shown in Figure 10:

Figure 10. Mobile applications for Denver, Colorado
Screen shot of City-Go-Round Web page of applications for Denver, CO

Click to see larger image

Figure 10. Mobile applications for Denver, Colorado

Screen shot of City-Go-Round Web page of applications for Denver, CO

Some of the apps limit themselves to the RTD Light Rail. Others focus on specific destinations, such as bus routes to the airport. The ratings, reviews, and screen shots for each application help you determine which one best fits your needs.

An important consideration when evaluating mobile applications — or creating your own — is whether they store the data locally or pull the information over the air. This is especially important for subway riders who frequently lose cell service while underground. Using locally stored data tends to yield quicker response times, but the application should offer periodic updates to ensure that the user isn't looking at stale information.

For some inspiration for your own mobile transit apps (and so you don't reinvent the proverbial wheel), be sure to check out these free or low-cost standouts on City-Go-Round (see Resources for links to their pages).

UniBus

UniBus is an iPhone application that offers support for all cities that, not surprisingly, also offer open data in the GTFS format. Since I travel a lot, having all of the transit information in a consistent format right in my pocket is a pretty appealing prospect. The data is stored locally, so I can research bus and train routes while I am still on the airplane. The app also provides Google Maps visualizations, estimated arrival times, the ability to save "favorite" routes, and much more.

Acrossair

Acrossair is an iPhone application that uses the built-in video camera to provide a real-time augmented reality view of where you are standing. Hold the phone up, look through it, and you'll see an overlay of which bus route you are on or where the nearest subway stop is. It doesn't work in every city, but if you are in New York, Washington, D.C., Chicago, or San Francisco and have a 3GS iPhone, you'll have your very own public transit-enabled heads-up display.

One Bus Away

One Bus Away provides a real-time display of where all of the buses in a transit system are at any given moment. Only a handful of transit authorities now provide real-time bus location to the public; Seattle's King County Metro is one of them. Right now One Bus Away only works in Seattle and its environs, but as more transit authorities offer their real-time data, independent applications will inevitably sprout up.

As I was standing under an awning in the pouring rain on a recent trip to Redmond, I could look at my iPhone and see a Google Map that showed exactly how close my bus was to arriving. The tiny icons representing individual buses update their location on the map every 10 to 15 seconds. Once I was on the bus, I used the application to gauge how close I was to my final destination. I could see all of the scheduled stops along the way, so I knew exactly when to pull the "Stop Requested" cord. It was my first time on the bus, but I already felt like a seasoned pro.


Conclusion

Whether your intentions are altruistic or selfish (or both), you owe it to yourself to explore the public transit options available to you in your city. Familiar Web sites, like Google Maps, make it easy to get started, and advocacy sites like City-Go-Round give you the mobile tools you need to make it convenient. They can be indispensable resources when you begin designing your own transit applications.

For a higher-level perspective on the intersection between community planning and technology, you can explore The Open Planning Project (TOPP) (see Resources). A "technology-driven social enterprise," TOPP is one of the largest organizations in the world dedicated to producing open source software. Transportation reform is one of TOPP's major initiatives. For example, when Portland, Oregon's award-winning TriMet transit system wanted to overhaul its interactive system map and integrate it with its existing trip planner, TriMet partnered with TOPP to switch out proprietary components for open source alternatives. (Full disclosure: I served as a consultant on the project.) Another great TOPP project is Streetsblog — a news source, online community, and political mobilizer for individuals and organizations who want to to transform cities by reducing dependence on automobiles and improving conditions for cyclists, pedestrians, and transit riders (see Resources).

Resources

Learn

  • "Packing Pavement" (Jim Beamguard, Tampa Bay Online, July 1999): Cars, not transit systems, create urban congestion.
  • Google Maps: Find your way to the Google Maps site.
  • "Map Hacks on Crack" (Wired, July 2005): Read about the release of the Google Maps API.
  • GTFS: This page explains the types of files that comprise a GTFS transit feed and defines the fields used in those files.
  • GTFS Data Exchange: Transit districts can upload their GTFS data here. This is also where you can subscribe to an RSS feed to get GTFS data updates.
  • City-Go-Round: City-Go-Round helps people find transit applications and encourages public transit agencies to open their data to software developers.
  • Learn more about the three mobile apps described in this article:
  • The Open Planning Project: Find out how TOPPS helps build better tools for transit, including Portland's TriMet, with open source software.
  • Streetsblog: Check out Streetsblog for New York, Los Angeles, San Francisco, and Washington, D.C.
  • Technology bookstore: Browse for books on these and other technical topics.

Discuss

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into Java technology on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Java technology, Industries
ArticleID=481339
ArticleTitle=The route to smart transit
publish-date=04132010