Navigating Bus Stops with Open Data and Windows Phone 7

In a recent post I talked about Bringing Azure+OData+Silverlight Goodness to Open Data Apps in Ottawa.  To do this, I imported standardized transportation data (that I found for the city of Ottawa) into a SQL database and exposed it as OData using WCF Data Services on an Entity Framework model.  I subsequently published a sample database to Windows Azure to demonstrate use of the data in an adapted Silverlight application that uses the Open Data Application Framework.

The OData information is accessible through a RESTful interface.  Here are the root entities displayed in IE.

20100606 odata

Last Thursday evening, I did a presentation on building Silverlight applications for Windows Phone 7.  Given that there’s an OData client library CTP available for Windows Phone 7, I knocked up a Bus Stop ulity application to demonstrate to my audience.  To get started with Silverlight applications on WP7 you can download the free developer tools (vs. the designer tools which are extensions for Blend 4 RC currently) currently the April CTP version.  The developer tools also include the XNA Game Studio for creating XNA-based games.

Here’s are the two main features I set up…

20100606 menu

Do create my menu I went with the list-based project template and then replaced the listbox content with manual entries with tag values.  These tags are then used as the names of the XAML files to load.  Quick and dirty, but it works…

20100606 listcode

Selecting the first option brings up a screen that allows the user to enter a bus stop (by its number as displayed on bus stop signs in Ottawa) and then lookup the trip heading and time of the the next 10 buses stopping at that stop.

When declaring the text box to enter the number, the attribute settings InputScope="Number" is used to default the standard input panel to the number entry mode.  The "TelephoneNumber" value may have also been acceptable (to bring up the phone keypad keyboard with bigger numbers) since many people request this kind of information using their telephone and its keypad.

20100606 entry

The application then uses a proxy class derived from DataServiceContext (and created using the DataSvcUtil command line tool since the WP7 add-in for VS2010 Pro does not currently provide an Add Service Reference option on a project) to query the OData service (running locally or on Azure).

The results come back and use the very flexible ListViewItem control (with its Metro styling) to display the results, making use of Layout="TextAndDetails".

20100606 times

If the user had gone to the other main menu option, they’d be presented with this screen.

20100606 nearby

This shows their ‘current’ location and the bus stops nearby.  Again this calls the OData service using filter parameters to bring back only bus stops that are within a 1km block of the location.  The map shown is the Bing Maps Silverlight control set to Road mode – the same one as used for desktop Silverlight apps – and the bus stop icons are added as children to the map control with attached properties specifying their locations.  The navigation controls where turned off to maximise space, so I added two Windows Phone 7 Applicaiton Bar to allow the user to zoom in and out.  The user can pan around with their finger of course.  The bus stop icons could easily be made actionable in some way. 

Since the WP7 emulator has no GPS, the location was hard coded in.  One of the samples in the WP7 SDK shows how to use Reactive Extensions to simulate location information in a way that is easily switched later to real device data. 

While this kind of application needs fairly accurate location data, others don’t.  Perhaps just knowing the city would be enough if one had just landed in that city and wanted general information.  The location APIs for WP7 allow the developer to easily make a choice between slow and accurate (while the device GPS locks on to satellites) or quick and less accurate (by using available Wifi and mobile network information in conjunction with Microsoft’s cloud-based location services).

Once WP7 devices are released, and the city officially publishes this data set I’d expect a fleshed out and polished application of this kind to be quickly available😉.

5 thoughts on “Navigating Bus Stops with Open Data and Windows Phone 7

  1. Great Michael. There’s quite a journey to get the city to officially expose this data, but I think it will be worth the wait and a few $$ for many travelers.

  2. I had an iPhone that would include bus data (even ferry schedule data!) but now that I see the windows hd7 doesn’t do that I’m almost ready to take it back. Please make this app! Your features look even more handy! Please make this app and please make it work in Los Angeles!

Comments are closed.